Hello, no native English speaker here, I have an api that gives me data of two components that form one device, let say something like:
So after some preprocessing in python I get the following json structure:
My first try was to add all data at once (component a and b) but this don't work, so i followed this method:
- First modify the output of python preprocessing to only send one component data at once.
- Use an item to catch all data of each component.
- Use discovery rule with the previous item to generate a host for each one of the components and assign them another template for discover each characteristic of the json and filter the response to match only the actual host id.
- In the template assigned to each new discovered host i have item prototypes that get the data using a script with the macro value (I know maybe this isn't the best method)
- This work somehow but for the items that have an array in the json i can't get the array only the macro value.
- In the "cache" item i get the right value
Can anyone guide me to make this work?
In addition to this, I have the problem that the API generates multiple outputs for each component, but zabbix only gets the first match for each component. Is there a method to use the "additional" outputs as new data inputs on already created hosts? Or should I limit the data to the first occurrence in the preprocessing part?
Code:
| ----------------------- | || component A || | ----------------------- | ====> API call ===> JSON response || component B || | ----------------------- | Device A
Code:
[
{
"{#DEVICETYPE}": "a",
"{#UTCTIMESTAMPNS}": #################,
"{#DEVICEID}": "ID-#################",
...
...
"{#ACTIVEALERTS}": [
##,
##,
##
],
"{#LATLNG}": [
Lat,
Lng
]
},
{
"{#DEVICETYPE}": "b",
"{#UTCTIMESTAMPNS}": #################,
"{#DEVICEID}": "ID-#################",
...
...
"{#DEVICEAID}": "ID-#################"
}
]
- First modify the output of python preprocessing to only send one component data at once.
- Use an item to catch all data of each component.
- Use discovery rule with the previous item to generate a host for each one of the components and assign them another template for discover each characteristic of the json and filter the response to match only the actual host id.
- In the template assigned to each new discovered host i have item prototypes that get the data using a script with the macro value (I know maybe this isn't the best method)
Code:
var test = JSON.parse(value); var alarms = test.valor; return alarms;
- In the "cache" item i get the right value
Can anyone guide me to make this work?
In addition to this, I have the problem that the API generates multiple outputs for each component, but zabbix only gets the first match for each component. Is there a method to use the "additional" outputs as new data inputs on already created hosts? Or should I limit the data to the first occurrence in the preprocessing part?