mqtt2prometheus
mqtt2prometheus copied to clipboard
Map json prop as labels
Hi,
It would be nice to be able to map some properties as labels to help identify devices which publish to a single topic.
I have a use case with rtl_433 which is collecting weather station data into a single topic at rtl_433/{hostname}/events
Here is an example json:
{
"time":"2021-11-11 14:18:45",
"model":"Fineoffset-WHx080",
"subtype":0,
"id":196,
"battery_ok":1,
"temperature_C":13.1,
"humidity":90,
"wind_dir_deg":135,
"wind_avg_km_h":1.224,
"wind_max_km_h":3.672,
"rain_mm":58.5,
"mic":"CRC"
}
It would be useful to be able to map id or model to labels to help identify the device event.
- prom_name: temperature
mqtt_name: temperature_C
type: gauge
labels:
- model
- id
- subtype
I can relate to that use case. I welcome a PR adding this functionality. If I have enough spare time, I may implement it myself, but I can not give any time estimates on that.
I don't have much experience with Go but I can try to give it a shot if I get a chance..