hikhvar/mqtt2prometheus

Data extraction issue

kylhuk opened this issue · 3 comments

Hey there,

I freshly set up mqtt2prometheus with all the proper configs, and everything seems to work just fine. Somehow I'm not able to find the metrics I try to extract inside prometheus.

Extract of config.yaml

topic_path: home/ruuvi/+/sensor/+
device_id_regex: "home/ruuvi/(?P<deviceid>.*)/sensor/(?P<metricname>.*)"
metrics:
  - prom_name: temperature
    mqtt_name: temperature
    type: gauge
    const_labels:
      sensor_type: ruuvitag

Debug message of mqtt2prometheus:

2021-08-04T20:35:29Z	debug	metrics/ingest.go:42	Got message	{"topic": "home/ruuvi/FD-A6-86-79-13-C0/sensor/temperature", "payload": "21.34"}

Message visible in /metrics of prometheus

received_messages{status="success",topic="home/ruuvi/FD-A6-86-79-13-C0/sensor/temperature"} 99

And yet I'm not able to find any mqtt2prometheus-metrics on prometheus. The only metric available is mqtt2prometheus_connected

Any hints where I did a mistake?

Using regex capture groups for both device ID and metric name requires a bit different syntax:

  topic_path: shellies/+/sensor/+
  device_id_regex: "shellies/(?P<deviceid>.*)/sensor"
  metric_per_topic_config:
    metric_name_regex: "shellies/(?P<deviceid>.*)/sensor/(?P<metricname>.*)"
...
metrics:

Take a look at the ReadMe file here:

https://github.com/hikhvar/mqtt2prometheus/tree/master/hack

I've not used this myself, but good luck!

@genkobar is correct. That is the correct solution. Did you had any success @kylhuk?

@genkobar thanks for your suggestion. Unfortunately I have switched to a different project now, which solved all my problems. So I'm closing this issue now and hope, this helps someone else in the future.