Hi,
So I have a Item which returns me a JSON.
This is the JSON I'm getting (here in formatted version)
{
"peers":[
{
"id":0,
"server":"172.16.X.22:80",
"name":"172.16.X.22:80",
"backup":false,
"weight":1,
"state":"up",
"active":0,
"requests":0,
"responses":{
"1xx":0,
"2xx":0,
"3xx":0,
"4xx":0,
"5xx":0,
"total":0
},
"sent":0,
"received":0,
"fails":0,
"unavail":0,
"health_checks":{
"checks":15193,
"fails":0,
"unhealthy":0,
"last_passed":true
},
"downtime":0
},
{
"id":1,
"server":"172.16.X.23:80",
"name":"172.16.X.23:80",
"backup":false,
"weight":1,
"state":"up",
"active":0,
"requests":0,
"responses":{
"1xx":0,
"2xx":0,
"3xx":0,
"4xx":0,
"5xx":0,
"total":0
},
"sent":0,
"received":0,
"fails":0,
"unavail":0,
"health_checks":{
"checks":15194,
"fails":0,
"unhealthy":0,
"last_passed":true
},
"downtime":0
},
{
"id":2,
"server":"172.16.X.24:80",
"name":"172.16.X.24:80",
"backup":false,
"weight":1,
"state":"up",
"active":0,
"requests":0,
"responses":{
"1xx":0,
"2xx":0,
"3xx":0,
"4xx":0,
"5xx":0,
"total":0
},
"sent":0,
"received":0,
"fails":0,
"unavail":0,
"health_checks":{
"checks":15193,
"fails":0,
"unhealthy":0,
"last_passed":true
},
"downtime":0
}
],
"keepalive":0,
"zombies":0,
"zone":"ca-prod-80"
}
What I do is that I want to extract from that JSON values like sent, received.
So in the Dependant Item I choose JSONPath in the preprocessing and I do $.peers[0].sent
At least that is my conclusion how I should access data from zabbix documentation.
But then zabbix gives me a finger with a following error:
21931:20181206:112716.686 [Z3005] query failed: [1452] Cannot add or update a child row: a foreign key constraint fails (`zabbix`.`item_preproc`, CONSTRAINT `c_item_preproc_1` FOREIGN KEY (`itemid`) REFERENCES `items` (`itemid`) ON DELETE CASCADE) [insert into item_preproc (item_preprocid,itemid,step,type,params) values (539790,null,2,12,'$.peers[0].sent'),(539791,null,2,12,'$.peers[0].sent'),(539792,null,2,12,'$.peers[0].sent'),(539793,null,2,12,'$.peers[0].sent'),(539794,null,2,12,'$.peers[0].sent'),(539795,null,2,12,'$.peers[0].sent'),(539796,null,2,12,'$.peers[0].sent'),(539797,773857,2,12,'$.peers[0].sent'),(539798,773858,2,12,'$.peers[0].sent'),(539799,773859,2,12,'$.peers[0].sent'),(539800,773860,2,12,'$.peers[0].sent'),(539801,773861,2,12,'$.peers[0].sent'),(539802,773862,2,12,'$.peers[0].sent'),(539803,773863,2,12,'$.peers[0].sent');
]
What I do wrong ?
When I have simple JSONs without several nested levels, JSONPath works OK, but when there is a nested multiple level, then zabbix is crying.
Zabbix version I use is 3.4.6
So I have a Item which returns me a JSON.
This is the JSON I'm getting (here in formatted version)
{
"peers":[
{
"id":0,
"server":"172.16.X.22:80",
"name":"172.16.X.22:80",
"backup":false,
"weight":1,
"state":"up",
"active":0,
"requests":0,
"responses":{
"1xx":0,
"2xx":0,
"3xx":0,
"4xx":0,
"5xx":0,
"total":0
},
"sent":0,
"received":0,
"fails":0,
"unavail":0,
"health_checks":{
"checks":15193,
"fails":0,
"unhealthy":0,
"last_passed":true
},
"downtime":0
},
{
"id":1,
"server":"172.16.X.23:80",
"name":"172.16.X.23:80",
"backup":false,
"weight":1,
"state":"up",
"active":0,
"requests":0,
"responses":{
"1xx":0,
"2xx":0,
"3xx":0,
"4xx":0,
"5xx":0,
"total":0
},
"sent":0,
"received":0,
"fails":0,
"unavail":0,
"health_checks":{
"checks":15194,
"fails":0,
"unhealthy":0,
"last_passed":true
},
"downtime":0
},
{
"id":2,
"server":"172.16.X.24:80",
"name":"172.16.X.24:80",
"backup":false,
"weight":1,
"state":"up",
"active":0,
"requests":0,
"responses":{
"1xx":0,
"2xx":0,
"3xx":0,
"4xx":0,
"5xx":0,
"total":0
},
"sent":0,
"received":0,
"fails":0,
"unavail":0,
"health_checks":{
"checks":15193,
"fails":0,
"unhealthy":0,
"last_passed":true
},
"downtime":0
}
],
"keepalive":0,
"zombies":0,
"zone":"ca-prod-80"
}
What I do is that I want to extract from that JSON values like sent, received.
So in the Dependant Item I choose JSONPath in the preprocessing and I do $.peers[0].sent
At least that is my conclusion how I should access data from zabbix documentation.
But then zabbix gives me a finger with a following error:
21931:20181206:112716.686 [Z3005] query failed: [1452] Cannot add or update a child row: a foreign key constraint fails (`zabbix`.`item_preproc`, CONSTRAINT `c_item_preproc_1` FOREIGN KEY (`itemid`) REFERENCES `items` (`itemid`) ON DELETE CASCADE) [insert into item_preproc (item_preprocid,itemid,step,type,params) values (539790,null,2,12,'$.peers[0].sent'),(539791,null,2,12,'$.peers[0].sent'),(539792,null,2,12,'$.peers[0].sent'),(539793,null,2,12,'$.peers[0].sent'),(539794,null,2,12,'$.peers[0].sent'),(539795,null,2,12,'$.peers[0].sent'),(539796,null,2,12,'$.peers[0].sent'),(539797,773857,2,12,'$.peers[0].sent'),(539798,773858,2,12,'$.peers[0].sent'),(539799,773859,2,12,'$.peers[0].sent'),(539800,773860,2,12,'$.peers[0].sent'),(539801,773861,2,12,'$.peers[0].sent'),(539802,773862,2,12,'$.peers[0].sent'),(539803,773863,2,12,'$.peers[0].sent');
]
What I do wrong ?
When I have simple JSONs without several nested levels, JSONPath works OK, but when there is a nested multiple level, then zabbix is crying.
Zabbix version I use is 3.4.6
Comment