Skip to content

Publishes Prometheus Alertmanager webhook messages to MQTT

Notifications You must be signed in to change notification settings

uhlig-it/alertmanager-mqtt-bridge

Repository files navigation

Alertmanager MQTT Bridge

This is a Webhook server converting Prometheus Alertmanager webhook messages into MQTT messages.

The MQTT topic is taken from the MQTT_URL's path, and the alert name is appended.

Example: With MQTT_URL=mqtts://user:password@mqtt.example.com/alerts/grafana, an alert named "My Alert" is published to /alerts/grafana/My Alert.

Deployment

$ (cd deployment && ansible-playbook playbook.yml)

Development

  • Iterate with entr:

    $ find . -name '*.go' -or -name '*.tmpl' -type f | entr -r go run . --verbose
  • Listen to MQTT messages:

    $ mosquitto_sub --url 'mqtts://user:password@mqtt.example.com/alerts/grafana/#' -F %J | jq
  • Post a fixture to the running server:

    $ curl -v localhost:8031 -d @fixtures/alert.json

    If the server is running on a remote host and if it is listening to localhost only, a self-closing SSH tunnel helps:

    $ ssh alice@example.com -L 8031:localhost:8031 -f sleep 10 && curl -v localhost:8031 -d @fixtures/alert.json

Check .tmuxinator.yml for an ready-to-launch configuration of the above.