|
| 1 | +--- |
| 2 | +canonical: https://grafana.com/docs/grafana/latest/alerting/configure-notifications/manage-contact-points/integrations/configure-mqtt/ |
| 3 | +description: Configure the MQTT notifier integration for Alerting |
| 4 | +keywords: |
| 5 | + - grafana |
| 6 | + - alerting |
| 7 | + - guide |
| 8 | + - contact point |
| 9 | + - mqtt |
| 10 | +labels: |
| 11 | + products: |
| 12 | + - cloud |
| 13 | + - enterprise |
| 14 | + - oss |
| 15 | +menuTitle: MQTT notifier |
| 16 | +title: Configure the MQTT notifier for Alerting |
| 17 | +weight: 80 |
| 18 | +--- |
| 19 | + |
| 20 | +# Configure the MQTT notifier for Alerting |
| 21 | + |
| 22 | +Use the Grafana Alerting - MQTT integration to send notifications to an MQTT broker when your alerts are firing. |
| 23 | + |
| 24 | +## Procedure |
| 25 | + |
| 26 | +To configure the MQTT integration for Alerting, complete the following steps. |
| 27 | + |
| 28 | +1. In the left-side menu, click **Alerts & IRM** and then **Alerting**. |
| 29 | +1. On the **Contact Points** tab, click **+ Add contact point**. |
| 30 | +1. Enter a descriptive name for the contact point. |
| 31 | +1. From the Integration list, select **MQTT**. |
| 32 | +1. Enter your broker URL in the **Broker URL** field. Supports `tcp`, `ssl`, `mqtt`, `mqtts`, `ws`, `wss` schemes. For example: `tcp://127.0.0.1:1883`. |
| 33 | +1. Enter the MQTT topic name in the **Topic** field. |
| 34 | +1. In **Optional MQTT settings**, specify additional settings for the MQTT integration if needed. |
| 35 | +1. Click **Test** to check that your integration works. |
| 36 | + A test alert notification should be sent to the MQTT broker. |
| 37 | +1. Click **Save** contact point. |
| 38 | + |
| 39 | +The integration sends data in JSON format by default. You can change that using **Message format** field in the **Optional MQTT settings** section. There are two supported formats: |
| 40 | + |
| 41 | +- **JSON**: Sends the alert notification in JSON format. |
| 42 | +- **Text**: Sends the rendered alert notification message in plain text format. |
| 43 | + |
| 44 | +## MQTT JSON payload |
| 45 | + |
| 46 | +If the JSON message format is selected in **Optional MQTT settings**, the payload is sent in the following structure. |
| 47 | + |
| 48 | +```json |
| 49 | +{ |
| 50 | + "receiver": "My MQTT integration", |
| 51 | + "status": "firing", |
| 52 | + "orgId": 1, |
| 53 | + "alerts": [ |
| 54 | + { |
| 55 | + "status": "firing", |
| 56 | + "labels": { |
| 57 | + "alertname": "High memory usage", |
| 58 | + "team": "blue", |
| 59 | + "zone": "us-1" |
| 60 | + }, |
| 61 | + "annotations": { |
| 62 | + "description": "The system has high memory usage", |
| 63 | + "runbook_url": "https://myrunbook.com/runbook/1234", |
| 64 | + "summary": "This alert was triggered for zone us-1" |
| 65 | + }, |
| 66 | + "startsAt": "2021-10-12T09:51:03.157076+02:00", |
| 67 | + "endsAt": "0001-01-01T00:00:00Z", |
| 68 | + "generatorURL": "https://play.grafana.org/alerting/1afz29v7z/edit", |
| 69 | + "fingerprint": "c6eadffa33fcdf37", |
| 70 | + "silenceURL": "https://play.grafana.org/alerting/silence/new?alertmanager=grafana&matchers=alertname%3DT2%2Cteam%3Dblue%2Czone%3Dus-1", |
| 71 | + "dashboardURL": "", |
| 72 | + "panelURL": "", |
| 73 | + "values": { |
| 74 | + "B": 44.23943737541908, |
| 75 | + "C": 1 |
| 76 | + } |
| 77 | + }, |
| 78 | + { |
| 79 | + "status": "firing", |
| 80 | + "labels": { |
| 81 | + "alertname": "High CPU usage", |
| 82 | + "team": "blue", |
| 83 | + "zone": "eu-1" |
| 84 | + }, |
| 85 | + "annotations": { |
| 86 | + "description": "The system has high CPU usage", |
| 87 | + "runbook_url": "https://myrunbook.com/runbook/1234", |
| 88 | + "summary": "This alert was triggered for zone eu-1" |
| 89 | + }, |
| 90 | + "startsAt": "2021-10-12T09:56:03.157076+02:00", |
| 91 | + "endsAt": "0001-01-01T00:00:00Z", |
| 92 | + "generatorURL": "https://play.grafana.org/alerting/d1rdpdv7k/edit", |
| 93 | + "fingerprint": "bc97ff14869b13e3", |
| 94 | + "silenceURL": "https://play.grafana.org/alerting/silence/new?alertmanager=grafana&matchers=alertname%3DT1%2Cteam%3Dblue%2Czone%3Deu-1", |
| 95 | + "dashboardURL": "", |
| 96 | + "panelURL": "", |
| 97 | + "values": { |
| 98 | + "B": 44.23943737541908, |
| 99 | + "C": 1 |
| 100 | + } |
| 101 | + } |
| 102 | + ], |
| 103 | + "groupLabels": {}, |
| 104 | + "commonLabels": { |
| 105 | + "team": "blue" |
| 106 | + }, |
| 107 | + "commonAnnotations": {}, |
| 108 | + "externalURL": "https://play.grafana.org/", |
| 109 | + "version": "1", |
| 110 | + "groupKey": "{}:{}", |
| 111 | + "message": "**Firing**\n\nLabels:\n - alertname = T2\n - team = blue\n - zone = us-1\nAnnotations:\n - description = This is the alert rule checking the second system\n - runbook_url = https://myrunbook.com\n - summary = This is my summary\nSource: https://play.grafana.org/alerting/1afz29v7z/edit\nSilence: https://play.grafana.org/alerting/silence/new?alertmanager=grafana&matchers=alertname%3DT2%2Cteam%3Dblue%2Czone%3Dus-1\n\nLabels:\n - alertname = T1\n - team = blue\n - zone = eu-1\nAnnotations:\nSource: https://play.grafana.org/alerting/d1rdpdv7k/edit\nSilence: https://play.grafana.org/alerting/silence/new?alertmanager=grafana&matchers=alertname%3DT1%2Cteam%3Dblue%2Czone%3Deu-1\n" |
| 112 | +} |
| 113 | +``` |
| 114 | + |
| 115 | +### Payload fields |
| 116 | + |
| 117 | +Each notification payload contains the following fields. |
| 118 | + |
| 119 | +| Key | Type | Description | |
| 120 | +| ----------------- | ------------------------------------------- | ------------------------------------------------------------------------------- | |
| 121 | +| receiver | string | Name of the contact point | |
| 122 | +| status | string | Current status of the alert, `firing` or `resolved` | |
| 123 | +| orgId | number | ID of the organization related to the payload | |
| 124 | +| alerts | array of [alert instances](#alert-instance) | Alerts that are triggering | |
| 125 | +| groupLabels | object | Labels that are used for grouping, map of string keys to string values | |
| 126 | +| commonLabels | object | Labels that all alarms have in common, map of string keys to string values | |
| 127 | +| commonAnnotations | object | Annotations that all alarms have in common, map of string keys to string values | |
| 128 | +| externalURL | string | External URL to the Grafana instance sending this webhook | |
| 129 | +| version | string | Version of the payload | |
| 130 | +| groupKey | string | Key that is used for grouping | |
| 131 | +| message | string | Rendered message of the alerts | |
| 132 | + |
| 133 | +### Alert instance |
| 134 | + |
| 135 | +Each alert instance in the `alerts` array has the following fields. |
| 136 | + |
| 137 | +| Key | Type | Description | |
| 138 | +| ------------ | ------ | ---------------------------------------------------------------------------------- | |
| 139 | +| status | string | Current status of the alert, `firing` or `resolved` | |
| 140 | +| labels | object | Labels that are part of this alert, map of string keys to string values | |
| 141 | +| annotations | object | Annotations that are part of this alert, map of string keys to string values | |
| 142 | +| startsAt | string | Start time of the alert | |
| 143 | +| endsAt | string | End time of the alert, default value when not resolved is `0001-01-01T00:00:00Z` | |
| 144 | +| values | object | Values that triggered the current status | |
| 145 | +| generatorURL | string | URL of the alert rule in the Grafana UI | |
| 146 | +| fingerprint | string | The labels fingerprint, alarms with the same labels will have the same fingerprint | |
| 147 | +| silenceURL | string | URL to silence the alert rule in the Grafana UI | |
| 148 | +| dashboardURL | string | **Deprecated. It will be removed in a future release.** | |
| 149 | +| panelURL | string | **Deprecated. It will be removed in a future release.** | |
| 150 | +| imageURL | string | URL of a screenshot of a panel assigned to the rule that created this notification | |
| 151 | + |
| 152 | +{{< admonition type="note" >}} |
| 153 | +Alert rules are not coupled to dashboards anymore. The fields related to dashboards `dashboardId` and `panelId` have been removed. |
| 154 | +{{< /admonition >}} |
0 commit comments