Skip to content
This repository has been archived by the owner on Oct 11, 2023. It is now read-only.

Showing a table with the list of alerts

Hector Garcia Tellado edited this page Oct 31, 2017 · 1 revision

How to get all the alerts for the past 24 hours, for a given group of devices.

It's also possible to get all the alerts, skipping step one below, and removing the devices filter in step two.

Step 1: Get the list of devices

The user selects a device group, which implicitly define the query to use to fetch the list of devices. See the Config UI API for more information.

Request

GET {IoT Hub manager endpoint}/devices?query={query}

Response

Content-Type: application/json; charset=utf-8

{
    Count: ...
    Items: [
        { device }
        { device }
        { device }
        ...
    ]
    "$metadata": {
        $type: DevicesList;1
        $uri: {IoT Hub manager endpoint}/devices?query={query}
    }
}

Note that the content of the response might change over time, for instance when devices are added or removed, and when device properties change. For instance a query like "all devices with firmware 1.2" would return a different list over time. The UI decides whether to cache and reuse the query result, or whether to repeat the query to refresh the response.

Step 2: Get the list of alerts for the past 24 hours

Request

Request with GET:

GET {Device Telemetry endpoint}/alerts?from=NOW-PT24H&to=NOW&order=desc&devices=id1,id2,id3,...

Request with POST:

POST {Device Telemetry endpoint}/alerts-query
Content-Type: application/json; charset=utf-8

{
    From: {NOW-PT24H}
    To: {NOW}
    Order: desc
    Devices: [ "id1", "id2", "id3", ..., "id 1000" ]
}

Response

Content-Type: application/json; charset=utf-8

{
    Count: ...
    Items: [
        {
            deviceid, time, description, status, etc.
            $metadata
        },
        {
            deviceid, time, description, status, etc.
            $metadata
        },
        {
            deviceid, time, description, status, etc.
            $metadata
        },
        ...
    ]
    "$metadata": {
        $type: AlertsList;1
        $uri: ...
    }
}