[ZBXNEXT-5422] Add types autoconversion in JSONPath aggregations Created: 2019 Sep 12  Updated: 2024 Apr 10  Resolved: 2019 Dec 09

Status: Closed
Project: ZABBIX FEATURE REQUESTS
Component/s: Proxy (P), Server (S)
Affects Version/s: 4.2.5, 4.4.0alpha2
Fix Version/s: 4.0.14rc1, 4.2.8rc1, 4.4.0rc1, 4.4 (plan)

Type: Change Request Priority: Minor
Reporter: Vitaly Zhuravlev Assignee: Andrejs Tumilovics
Resolution: Fixed Votes: 3
Labels: jsonpath, preprocessing
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: PNG File number-format.png    
Team: Team C
Sprint: Sprint 56 (Sep 2019), Sprint 57 (Oct 2019), Sprint 58 (Nov 2019)
Story Points: 0.5

 Description   

--ZBXNEXT-4502-- brings very powerful aggregation functions such as sum(), min(), max() to be used with numbers.

But the problem is, sometimes numeric values are still wrapped in quotes in JSON, so actually of type JSON string. For example, "value" attribute returned from 'Prometheus to JSON'

Adding simple attempt to autoconvert such values would make extremely easy to aggregate such values on fly with JSONPath.

Simple example:

 

[
{"value":"123"},
{"value":"123"}
]

 and JSONPath $.*['value'].sum() gives error now.

Expected:

Values sum is returned.

 

Prometheus to JSON example:

[{"name":"node_cpu_seconds_total","value":"69659.16","line_raw":"node_cpu_seconds_total{cpu=\"0\",mode=\"idle\"} 69659.16","labels":{"cpu":"0","mode":"idle"},"type":"counter","help":"Seconds the cpus spent in each mode."},{"name":"node_cpu_seconds_total","value":"69581.05","line_raw":"node_cpu_seconds_total{cpu=\"1\",mode=\"idle\"} 69581.05","labels":{"cpu":"1","mode":"idle"},"type":"counter","help":"Seconds the cpus spent in each mode."}]

 and JSONPath $.*['value'].sum() gives error now.

Expected:

Values (cpu idle time) sum is returned.



 Comments   
Comment by Andrejs Tumilovics [ 2019 Oct 01 ]

Available in:

Comment by Alexander Vladishev [ 2019 Dec 09 ]

Updated documentation:

Generated at Fri Apr 26 07:38:04 EEST 2024 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.