Hi.
I'm trying to count the number of JSON objects that are returned from a query where their name contains a specific string, and trying to do it in a cleanish way for the Zabbix Operator so that I'm not ending up with loads of misc items underneath it.
I can't seem to get it working at all; and i'm pretty sure that it's my Regex that's failing, but not 100% sure, so thought i'd ask here!
Sample:
[
{"Name": "Alpha, Beta, Gamma", "Param": "1,3,99,128,512"},
{"Name": "Beta", "Param":"56,59"},
{"Name": "Kilo, Phi", "Param": "17,109,123"},
{"Name": "Omega, Gamma, Phi", "Param": "78"},
{"Name": "Zeta", "Param": "91,561"}
]
In this instance, i've got TotalObjects as an Host.Item, which is preprocessed using JSONPath to $.length(), which correctly reports 5
But i also want to get :
Total number of objects where name contains Beta
Total number of objects where name contains Phi.
Is there an easy/recommended way to do this? I don't need any of the details of the Parameters, just the names themselves, and the string i'm looking for won't appear anywhere else in each object other than the name, so I could just count the number of instances of each "Alpha" etc string.
I've not yet delved into creating custom user javascript etc macro functions, and would prefer not to if i can help it!
Thanks in advance!
I'm trying to count the number of JSON objects that are returned from a query where their name contains a specific string, and trying to do it in a cleanish way for the Zabbix Operator so that I'm not ending up with loads of misc items underneath it.
I can't seem to get it working at all; and i'm pretty sure that it's my Regex that's failing, but not 100% sure, so thought i'd ask here!
Sample:
[
{"Name": "Alpha, Beta, Gamma", "Param": "1,3,99,128,512"},
{"Name": "Beta", "Param":"56,59"},
{"Name": "Kilo, Phi", "Param": "17,109,123"},
{"Name": "Omega, Gamma, Phi", "Param": "78"},
{"Name": "Zeta", "Param": "91,561"}
]
In this instance, i've got TotalObjects as an Host.Item, which is preprocessed using JSONPath to $.length(), which correctly reports 5
But i also want to get :
Total number of objects where name contains Beta
Total number of objects where name contains Phi.
Is there an easy/recommended way to do this? I don't need any of the details of the Parameters, just the names themselves, and the string i'm looking for won't appear anywhere else in each object other than the name, so I could just count the number of instances of each "Alpha" etc string.
I've not yet delved into creating custom user javascript etc macro functions, and would prefer not to if i can help it!
Thanks in advance!
Comment