Open kunkka234 opened 3 years ago
Try this:
'{$[?(@.status=="running")]}'
Try this:
'{$[?(@.status=="running")]}'
thanks for your reply, but it's not working. and the error message doesn't change as well
level=error ts=2021-06-08T03:28:16.722Z caller=collector.go:128 msg="Failed to execute jsonpath" err="map[status:running] is not array or slice and cannot be filtered" path="{$[?(@.status==\"running\")]}" data="{\n \"status\": \"running\"\n}\n"
level=error ts=2021-06-08T03:28:16.723Z caller=collector.go:69 msg="Failed to extract json objects for metric" err="map[status:running] is not array or slice and cannot be filtered" metric="Desc{fqName: \"test_active\", help: \"test\", constLabels: {}, variableLabels: [label]}"
level=error ts=2021-06-08T03:28:16.723Z caller=collector.go:128 msg="Failed to execute jsonpath" err="map[status:running] is not array or slice and cannot be filtered" path="{$[?(@.status==\"stopped\")]}" data="{\n \"status\": \"running\"\n}\n"
level=error ts=2021-06-08T03:28:16.723Z caller=collector.go:69 msg="Failed to extract json objects for metric" err="map[status:running] is not array or slice and cannot be filtered" metric="Desc{fqName: \"test_active\", help: \"test\", constLabels: {}, variableLabels: [label]}"
@kunkka234
I had the same issue today, no solution after 1 hour of struggling. Did you find a way to solve this ?
+1 Also having this issue
+1 The same issue.
+1 The same issue.
+1 The same issue.
+1 The same issue.
anyone find the answer to this? Wasn't able to figure it out :(
+1 The same issue.
Anyone has been able to figure this out yet?
Any updates here?
Given the same example.json
{
"status": "running"
}
I was able to extract status and apply it as label as suggested here
My config.yml
looks like this:
---
modules:
health:
metrics:
- name: service_status
type: object
help: Service Status
path: '{$}'
labels:
status: '{ .status }'
values:
availability: 1
To the root path in JSONPath is '{$}'
+1 The same issue here. Solution shown above is looking at list structure, not nested objects, which seems to be the main issue for the json-exporter
+1 The same issue.
+1
+1
+1 same here
Hi, i got some problem when trying to use jsonpath filter in root level key-value.
what i want: for the example json:
if
status == "running"
, set static metric = 1 ifstatus == "stopped"
, set static metric = 0my config.yml:
what did i see
http://localhost:7979/probe?target=http://host.docker.internal:8000/status.json
returns me nothing but white screen, and get following error in consoleother info the path
$.[?($.status=="running")]
was tested successfully in https://jsonpath.herokuapp.com/, but failed in https://jsonpath.com/. and i also tried other path like.[?($.status=="running")]
,.[?(@.status=="running")]
, and$.[?(@.status=="running")]
but none of them working but got the same error message. looking for your help and thanks in advance