inovex / mqtt_blackbox_exporter

Prometheus Exporter for MQTT monitoring
Apache License 2.0
77 stars 24 forks source link

Support for message_payload parameter #48

Closed seb-koch closed 4 years ago

seb-koch commented 4 years ago

Please review my tiny PR. It adds support for the optional message_payload directive. It also supports to include %d which will increment over the number of the configured messages. Example log:

20:16:14.289467 main.go:251: Msg payload: [{"sensor_id": "blackbox-test-hd-single", "value": "0"}]
20:16:14.289731 main.go:251: Msg payload: [{"sensor_id": "blackbox-test-hd-single", "value": "1"}]
20:16:14.289884 main.go:251: Msg payload: [{"sensor_id": "blackbox-test-hd-single", "value": "2"}]
20:16:14.290028 main.go:251: Msg payload: [{"sensor_id": "blackbox-test-hd-single", "value": "3"}]
20:16:14.290140 main.go:251: Msg payload: [{"sensor_id": "blackbox-test-hd-single", "value": "4"}]

I am using mqtt_blackbox_exporter to test our MQTT broker which only supports a certain type of JSON formatted payload. This led me to adding support for custom payloads myself. I did a fair amount of testing but have to warn you, that this is my first attempt in GO and the first PR i did ever in Github ;-). Looking forward to feedback, hoping that the code is acceptable.

hikhvar commented 4 years ago

LGTM, Congrats the first PR 🎉

arnisoph commented 4 years ago

🎉