json_exporter icon indicating copy to clipboard operation
json_exporter copied to clipboard

Iterate over map and dynamically assign key as label value

Open panaji opened this issue 3 years ago • 2 comments

Hi, i'm wondering if this is doable? Given this json:

{
    "input": {
        "a": {
            "foo": 2,
            "bar": 0
        }
    },
    "output": {
        "a": {
            "status": {
                "code": 0
            },
            "meta": {
                "foo": 0,
                "bar": 0
            }
        },
	"b": {
            "status": {
                "code": 1
            },
            "meta": {
                "foo": 0,
                "bar": 0
            }
        }
    }
}

I would like to iterate over the output map, and get something like:

output_status_code{name="a"} 0
output_status_code{name="b"} 1

Is it just because of JSONPath limitation? If it's possible, what would be the config like?

panaji avatar Apr 24 '21 01:04 panaji

I do have same problem. Can't figure out, how actually get key values itself, in order to use them as label or whatever later reference all of them later in values/labels.

theerror avatar Dec 16 '22 13:12 theerror

Any news about this issue ?

Alenas-c avatar Mar 13 '24 09:03 Alenas-c