Skip to content

How do I return a substring of a value #354

Open
@ickerh

Description

@ickerh

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions