I have an interesting scenario where an item collects a text value with multiple lines.
Each row has an instance name and a status. Something like this:
My goal is to create 2 items for each row and extract the instance name and its status.
To do this, I've created a discovery rule that has a "CSV to JSON" preprocessing step and it results in a JSON array.
For the discovery LLD Macros, I'm looking for a way to extract the QMNAME and STATUS using JSONPath and regular expressions.
This way, the discovery rule can have 2 LLD macros that are referenced on the item prototypes
I could create "calculated" item prototypes and use regular expressions to extract the values, but I was hoping to use "dependent" item prototypes instead.
Maybe something like $.[?(@ =~ /QMNAMES\((.*)\)\s+STATUS\((.*)\)/)], but with capture groups.
However, there doesn't seem to be any regex capture groups available in JSONPath.
Does anyone know if Zabbix JSONPath supports regex with capture groups?
Or how to further break down the JSON array values?
Each row has an instance name and a status. Something like this:
Code:
QMNAME(NAME1) STATUS(Running) QMNAME(NAME2) STATUS(Running) QMNAME(NAME3) STATUS(Standby)
To do this, I've created a discovery rule that has a "CSV to JSON" preprocessing step and it results in a JSON array.
Code:
[
{
"1": "QMNAME(NAME1) STATUS(Running)"
},
{
"1": "QMNAME(NAME2) STATUS(Running)"
},
{
"1": "QMNAME(NAME3) STATUS(Standby)"
}
]
This way, the discovery rule can have 2 LLD macros that are referenced on the item prototypes
I could create "calculated" item prototypes and use regular expressions to extract the values, but I was hoping to use "dependent" item prototypes instead.
Maybe something like $.[?(@ =~ /QMNAMES\((.*)\)\s+STATUS\((.*)\)/)], but with capture groups.
However, there doesn't seem to be any regex capture groups available in JSONPath.
Does anyone know if Zabbix JSONPath supports regex with capture groups?
Or how to further break down the JSON array values?
Comment