Answer the question
In order to leave comments, you need to log in
Zabbix. How to display data from JSON by key?
There is a key ( Trunk ) that stores the JSON output:
{
"data": [{
"{#TRUNKNAME}": "name1",
"{#LINESNOW}": "15",
"{#LINESMAX}": "32"
}, {
"{#TRUNKNAME}": "name2",
"{#LINESNOW}": "10",
"{#LINESMAX}": "32"
}, {
"{#TRUNKNAME}": "name3",
"{#LINESNOW}": "25",
"{#LINESMAX}": "100"
}]
}
Answer the question
In order to leave comments, you need to log in
I solved my own question...
$array = [
"data" =>
[
"name1" => [
"linesnow" => "15",
"linesmax" => "32"
]
]
];
In general, zabbix is optimized for numeric data, although it can work with strings as well. This JSON is more like optimized for discovery, the {#MACRO} macros are for populating data item prototypes, not data per se. I recommend looking in your API for the ability to extract the required linesnow and linesmax by the name or ID of the trunk, and create element prototypes based on the macro, the names and keys of which will contain the values linesnow in one and linesmax in the other, and then a separate postprocessing (xs, by the way, how, in actually - zabbix can't concatenate strings! https://support.zabbix.com/browse/ZBXNEXT-1911the developers did not seem to understand the request, then someone suggested a user case that dealt with alerts in general, and the idea died out - you can try to push it) to collect the desired string from the elements.
You can parse JSON into components by pushing data into an element of the text type with a third-party script (or in 4.0 an HTTP agent appeared that allows you to parse JSON from an HTTP response), then create several dependent elements from it by concatenating the preprocessing operations of the result of this JSON, specifying JSON first Path, and then write triggers and so on.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question