Open yosefy opened 1 year ago
I came across similar situation:
---
modules:
device_stats:
metrics:
- name: status
help: Connected Switches
type: object
path: '{ @ }'
labels:
status: '{ .status }'
values:
return: 1
- name: list_of_interfaces
help: list interfaces
type: object
path: '{ @.if_stat.* }'
labels:
ifname: '{ .port_id }'
values:
return: 1
JSON:
{
"status": "connected",
"hostname": "X",
"if_stat": {
"em0.0": {
"tx_pkts": 238084479,
"rx_pkts": 187104366,
"rx_bytes": 28492395648,
"port_id": "em0",
"up": true,
"tx_bytes": 144260009035
},
"irb.80": {
"tx_pkts": 133010,
"vlan": 80,
"rx_pkts": 41813989,
"rx_bytes": 14102487191,
"port_id": "irb",
"up": true,
"tx_bytes": 7384805
}
}
}
I tried to iterate the interface however received the errors:
19 error(s) occurred:
* collected metric "list_of_interfaces_return" { label:{name:"ifname" value:"irb"} untyped:{value:1}} was collected before with the same name and label values
* collected metric "list_of_interfaces_return" { label:{name:"ifname" value:"irb"} untyped:{value:1}} was collected before with the same name and label values
* <snipped>
Would it be possible or is there a way that if we can iterate the nested object so that the metric comes like below?
list_of_interfaces_return{ifname="em0"} 1
list_of_interfaces_return{ifname="irb.80"} 1
Has anyone found any solution for this problem? It seems the simplest solution would be to get the key of each object during iteration. But it looks like this is not possible with the current jsonpath library.
@rustycl0ck, @SuperQ could you help with this?
hi we have this from nginx unit state