[ZBX-15832] HTTP Agent json path doesn't allow to get keys with dots Created: 2019 Mar 15  Updated: 2019 Mar 20  Resolved: 2019 Mar 20

Status: Closed
Project: ZABBIX BUGS AND ISSUES
Component/s: Server (S)
Affects Version/s: 4.0.5
Fix Version/s: None

Type: Incident report Priority: Trivial
Reporter: RG Assignee: Arturs Lontons
Resolution: Won't fix Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: PNG File image-2019-03-18-15-06-07-925.png     PNG File image-2019-03-18-15-08-35-042.png    

 Description   

I'm using HTTP agent to get the our Rundeck health state throught its dedicated endpoint. As a code, this is

}}{{➜  ~ curl -sL 'https://rundeck.company.com/api/27/metrics/healthcheck?authtoken=MYUSERTPOKEN'{{                                              }}
{"dataSource.connection.time":{"healthy":true,"message":"Datasource connection healthy with timeout 5 seconds"},"quartz.scheduler.threadPool":{"healthy":true%  }}

 

As you can see, there are two keys with dots, dataSource.connection.time to begin with. As per JSON path spec, I should be able to get the sub key healthy with

 

   $.['{{dataSource.connection.time'].healthy}}

 

And some peoples in QAs reported being successful (outside of zabbix context) with

 

   $.\"dataSource.connection.time\".healthy

 

Zabbix refuses that, made some tests despecializing characters :  [ and ' and " and \ seems to be illegal for the jsonpath field.

 

Workaround, use an ugly regexpr.



 Comments   
Comment by Glebs Ivanovskis [ 2019 Mar 17 ]

You have a mistake in your JSONPath: $.['dataSource.connection.time'].healthy
In Zabbix you must not use dot to get object member by key, so correct JSONPath is: $['dataSource.connection.time'].healthy

Comment by RG [ 2019 Mar 18 ]

Tried a c/c of your JSONPath, Zabbix said

 

Item preprocessing step #1 failed: cannot extract value from json by path "$['dataSource.connection.time'].healthy": object not found starting with json path: "dataSource.connection.time'].healthy"

 

And I checked the HTTP agent doc for 4.0, Examples in https://www.zabbix.com/documentation/4.0/manual/config/items/itemtypes/http all start with a $. ?

Comment by Glebs Ivanovskis [ 2019 Mar 18 ]

all start with a $.

Perhaps, none of them start with brackets.

Zabbix said...

OK, at least it accepts JSONPath as valid. Now there is something wrong with your data.

Comment by RG [ 2019 Mar 18 ]

Here's the state with the JSONPath you suggested, as I said in my previous message

 

I removed the preprocessing and enforced a new check. Here's the data

As I paste this image I'm wondering, healthy got no quote, it's a JSON boolean, will that be a problem for Zabbix considering the  item "type of information" of this item is Text ? There's no "boolean" choice for "type of information".

 

Comment by Glebs Ivanovskis [ 2019 Mar 18 ]

Which Retrieve mode do you use in HTTP Agent item?

Comment by RG [ 2019 Mar 18 ]

Ok. My bad.

Somehow, somewhen, I checked 'Convert to json'. There was a {"body": ... } in the mix. God, there's way to much stuff to click on in Zabbix for me...

May I suggest adding this example to the doc, with the title "Key with dots" ?

Comment by Arturs Lontons [ 2019 Mar 20 ]

Hi,

Thank you for the suggestion.
The best way to implement this if you create a separate bug report with a type "documentation task" containing your example.

 

Regards,

Arturs.

Generated at Thu Apr 17 05:53:04 EEST 2025 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.