For the complete documentation index, see llms.txt. This page is also available as Markdown.

MQTT Integration

Connect MQTT-based systems to ilert by forwarding alerts from monitoring tools or IoT backends to notify on-call teams of device or data anomalies.

MQTT is a lightweight, publish-subscribe, machine-to-machine network protocol for message queue/message queuing service. It is designed for connections with remote locations that have devices with resource constraints or limited network bandwidth, such as in the Internet of Things. While ilert doesn't directly support an MQTT broker to accept the publishing of messages, it supports integrations specifically meant to connect MQTT topics to ilert events and provides the ilagent tool to connect your MQTT brokers to ilert without actually writing the code yourself.

In ilert: Create an MQTT alert source

  1. Go to Alerting → Alert sources and click Create new alert source.

  2. Search for MQTT, click its tile, and click Next.

  3. Give your alert source a name, optionally assign teams, and click Next.

  4. Choose who gets notified: select Use existing escalation policy and pick a policy, or Generate new escalation policy to start with a basic one that notifies you first. Click Next.

    The escalation step of the ilert alert source wizard, headed Who should be notified about alerts, with an escalation policy selected and a preview of its escalation rules below.
    Pick an existing escalation policy, or generate a basic one without leaving the wizard.
  5. Select Default grouping and click Continue setup. It groups events by the alert key the integration sets; the other grouping options are easier to judge once events are arriving.

  6. The next page shows more settings, such as notification priority and alert templates. Click Finish setup for now; you can change them later.

  7. On the final page, ilert shows the integration key and URL for this alert source. You will need them later in this guide.

    The Settings tab of a MQTT alert source in ilert, showing the integration type, the masked integration key, and the MQTT URL.

In your environment

Foreword: you are free to use any MQTT client to subscribe to your topics and wire them into an API call to POST api.ilert.com/api/v1/mqtt/{your-key-here} (the endpoint accepts the payload of our generic event API. See also this eventing guide).

However, if you don't wish to write your own software to wire subscriber and POST request, you may use our swiss-army-knife tool ilagent which supports an MQTT mode where it subscribes to a specific MQTT topic to deliver events or heartbeats to ilert; it automatically buffers the messages in a local database to support retries as well. It is open source and can be found on GitHub.

While you may compile the binary locally, we also support an official Docker image ilert/ilagent which can be used to get started quickly.

Consume a topic and turn messages into events

You can always check docker run ilert/ilagent --help for a full list of arguments. e.g. username and password for the MQTT broker.

If you don't want to provide the integrationKey in every message, you can overwrite it with the --event_key 'il1api123...' argument.

Transform any kind of message into events

The ilagent also supports basic event key overwrites so that you can map any message top-level keys into an event payload.

The top sample code will subscribe to ALL MQTT topics and filter every message for message.type == 'ALERT' it will then map the field message.state: SET => ALERT, ACK => ACCEPT and CLR => RESOLVE to the event.eventType additionally message.mCode will be used as event.alertKey and message.comment as event.summary.

With these flexible arguments, you may quickly prototype or start your alert management without the need to write and deploy a custom mapper.

If you are using this subscriber bridge for critical scenarios, make sure to read the section on MQTT at least once delivery guarantee in the ilagent readme.

FAQ

My local docker ilert/ilagent does not connect to my broker

In case your broker is running in docker as well, you cannot simply use localhost to connect; you will need to link your broker to your ilagent container with --link broker-container-name:broker-container-name then provide -m broker-container-name so that your ilagent actually connects to your broker.

Last updated

Was this helpful?