-
Notifications
You must be signed in to change notification settings - Fork 35
Coloring markers on a Map using alerts data
[Hui]
In RM1.6, we have the following logic to show color: if a device has alert in the past 10 mins, we show as red (even the alert is closed -- need justification from PM since there is no state for alert in Rm1.6) if a device has alert in the past 1 hour (10mins,1hour], we show as min.
For this purpose, we may want to simplify the API to retrieve the last alert for given deviceId in a given time range.
GET {Device Telemetry endpoint}/alerts?from={time}&to={time}&grouplimit=1&devices=id1,id2,id3,...&fields=deviceid,time
Content-Type: application/json; charset=utf-8
response:
{
Count: ...
Items: [
{
deviceid, time
},
{
deviceid, time
},
...
]
}
[/Hui]
See "Showing devices on a Map" to see how to put devices on a map, and add the following steps.
Get the list of alerts from the Device Telemetry API.
Request with GET:
GET {Device Telemetry endpoint}/alerts?status=open&from={time}&to={time}&grouplimit=1&order=desc&devices=id1,id2,id3,...
Request with POST:
POST {Device Telemetry endpoint}/alerts-query
Content-Type: application/json; charset=utf-8
{
Status: open
From: {time}
To: {time}
Order: desc
GroupLimit: 1
Devices: [ "id 1", "id 2", ..., "id 3" ]
}
Note: the "grouplimit" option is used to retrieve only the most recent alert for each device.
Content-Type: application/json; charset=utf-8
{
Count: ...
Items: [
{
deviceid, time, description, status, etc.
$metadata
},
{
deviceid, time, description, status, etc.
$metadata
},
...
]
"$metadata": {
$type: AlertsList;1
$uri: ...
}
}
Request with GET:
GET {Device Telemetry endpoint}/alerts?status=acknowledged&from={time}&to={time}&grouplimit=1&order=desc&devices=id1,id2,id3,...
Request with POST:
POST {Device Telemetry endpoint}/alerts-query
Content-Type: application/json; charset=utf-8
{
Status: acknowledged
From: {time}
To: {time}
Order: desc
GroupLimit: 1
Devices: [ "id 1", "id 2", ..., "id 3" ]
}
Note: the "grouplimit" option is used to retrieve only the most recent alert for each device.
Content-Type: application/json; charset=utf-8
{
Count: ...
Items: [
{
deviceid, time, description, status, etc.
$metadata
},
{
deviceid, time, description, status, etc.
$metadata
},
...
]
"$metadata": {
$type: AlertsList;1
$uri: ...
}
}
- Scroll through the list of "open" alerts, to identify which devices have a new/open alert.
- Scroll through the list of "acknowledged" alerts, ignore devices which have an open alert, what remains is the list of devices with an acknoledged alert.