It is possible to obtain metric value changes in realtime, when metric value has exceeded or dropped below specified threshold. That can be done using alarms, which can be obtained via STOMP over Websocket by /alarm event subscription.
Alarm creation
A new alarm can be created with REST API query /api/alarm/create
https://hostname:8090/api/alarm/create { "type":"0", "name":"testalarm", "value":"500000", "metric":"4", "node":"15", "time":"5000" }
Where
- type – alarm type:
- 0 – value has dropped below the threshold
- 1 – value has exceeded the threshold
- name – alarm name
- value – threshold value
- metric – metric identifier (for example, video bitrate)
- node – node identifier
- time – time in milliseconds during which the metric value must be above or below the threshold.
In the example above, an alarm, which is triggered if the video bitrate of the stream drops below 500 kbps for more than 5 seconds, was created.
If node Id is not set, the alarm applies to all the nodes on backend server.
Alarm changing
An alarm parameters can be changed with REST API query /api/alarm/update
https://hostname:8090/api/alarm/update { "id": "17", "type":"0", "name":"testalarm", "value":"500000", "metric":"4", "node":"15", "time":"5000" }
Where
- id – alarm identifier
- type – alarm type:
- 0 – value has dropped below the threshold
- 1 – value has exceeded the threshold
- name – alarm name
- value – threshold value
- metric – metric identifier (for example, video bitrate)
- node – node identifier
- time – time in milliseconds during which the metric value must be above or below the threshold.
Alarm deletion
Alarm can be deleted with REST API query /api/alarm/delete
https://hostname:8090/api/alarm/delete { "id": "17" }
Where
- id – alarm identifier
STOMP messages about the alarm triggering stop when it is deleted.
Obtaining alarm information
An alarm information can be obtained with REST API query /api/alarm/list
https://hostname:8090/api/alarm/list { "id": "17" }
Where
- id – alarm identifier
If alarm Id is set, the response will contain only that alarm information. If alarm Id is not set, the response will contain list with all the alarms on backend server.
For every alarm, the response contains the same fields as /api/alarm/update query.