Skip to content

Using device alerts

This guide explains how to view and manage device alerts in the nRF Cloud portal and APIs.

Creating and customizing alerts

To create alerts in a supported sample or application, include the nRF Cloud Alert library, configuration options, and definitions.

Enabling alerts

For REST-based applications, you must enable alerts at compile time.

For applications that use MQTT or CoAP, you can turn alerts on and off in the nRF Cloud portal:

  1. In the left sidebar, select Device Management.
  2. Click Devices.
  3. Click on a device to open its page.
  4. In the Alerts card, click the bell icon.
  5. Turn alerts on or off. You may need to refresh the page to view changes.

The terminal shows the result of changing this configuration.

Managing alerts

This section explains how to view, archive, and restore alerts in the nRF Cloud portal and APIs.

In the nRF Cloud portal

To view all alerts for all devices :

  1. In the left sidebar, select Device Management.

    A panel opens to the right. A red notification badge shows the number of active alerts. 1. Select Alerts.

    The Alerts page opens. The page displays:

    • Device
      • Click the device ID to open the overview page for that device. You can then view that device's alerts from the Alerts card.
    • Alert type
      • To view more information about a single alert, click the Alert type.
    • Description (configured text for the alert)
    • Value, if applicable for the alert type
    • Time received
    • Time created at

From this page, you can select alerts to archive. To view archived alerts, select the tab in the Alerts card.

You can also view alerts for a single device from that device's page, or see alerts for a device group from that group's page.

Through the APIs

This section explains operations related to alerts using the REST API.

Viewing alerts

To view all device alerts, call the ListDeviceAlerts endpoint.

The response contains:

  • Time of creation
  • Device ID
  • Device UUID
  • The original message from the device that triggered an alert
  • Time when the message was received by nRF Cloud
  • Alert status (active or archived)

By default, the response includes all active and archived alerts. Use the status query parameter to filter results.

Example response:

{
"items": [
{
"id": "string",
"deviceId": "b67217f3-c246-4c7c-91b0-214579ce10d0",
"createdAt": "2020-06-25T21:05:12.830Z",
"receivedAt": "2020-06-25T21:05:12.830Z",
"statusChangedAt": "2020-06-25T21:05:12.830Z",
"statusChangedBy": "e84fe74f-2a0c-413d-b0ba-9e6bdc867d3c",
"status": "ACTIVE",
"originalMessage": {
   "appId": "ALERT",
   "ts": 1593119112830,
   "type": 3
   }
}
],
"total": 1,
"pageNextToken": "4bb1f9ab35bd"
}

Archiving alerts

Call the ArchiveDeviceAlert endpoint to archive a selected alert. If you want to archive multiple alerts at once, use the nRF Cloud portal.

Restoring alerts

If you archive an alert by mistake or want to mark it as active again, use the RestoreDeviceAlert endpoint.