Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do I return a substring of a value #354

Open
ickerh opened this issue Jan 14, 2025 · 0 comments
Open

How do I return a substring of a value #354

ickerh opened this issue Jan 14, 2025 · 0 comments

Comments

@ickerh
Copy link

ickerh commented Jan 14, 2025

Hello
I got a json response like this : {"System":{"state":"GREEN","memory-usage":{"used":"28 %","total":"8192 MB"}}}
I am trying to extract the 'used' value. My config.xml looks like

modules:
default:
headers:
X-Dummy: My-Json-Test
metrics:
- name: memory_used
path: "{$.System.memory-usage}"
type: object
values:
used: "{.used}"
help: Memory used

when I load this into json_exporter I get a parse exception that the value cannot be parsed to float64, which makes sense, because it contains a '%'.
I tried several ways to get a substring from the used field but nothing was working.

Is there a way in json_exporter or jsonpath that I can substring a value?

Thanks a lot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant