-
Notifications
You must be signed in to change notification settings - Fork 206
Closed
Description
With JSONPath it is not possible to reach a parent node afaict. Is there any other way to achieve the following with json_exporter?
Consider this json payload
[
{
"name": "parent-name",
"children": [
{
"name": "child-1"
},
{
"name": "child-2"
}
]
}
]Let say we want to produce metrics like this:
some_metric_vector{name="child-1",parent="parent-name"} 1
some_metric_vector{name="child-2",parent="parent-name"} 1
With this configuration:
metrics:
- name: some_metric
type: object
path: '{[*]}'
labels:
parent: '{.name}'
name: '{.children[*].name}'
values:
vector: 1
only one metric is produced
some_metric_vector{name="child-1 child-2",parent="parent-name"} 1
Changing the path to {[*].children[*]} I get a metric per child, but there is no way of reaching the parent name in the label selector.
Is there any other way to achieve this in json_exporter that I have overlooked? If not, would you be open to such a feature? Since JSONPath doesn't seem to support it, it would need some other solution, maybe having a configuration for parsing the json via go-templates as a step before the metrics path config.
Metadata
Metadata
Assignees
Labels
No labels