...
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 alarms event subscription.
Alarms can be managed using Websocket API or REST API
Alarm creation
A new alarm can be created with REST API query /api/alarm/create request
API | Request | Response | Response status |
---|
WS API | |
...
|
---|
| SEND
destination:/app/api/alarm/create
content-length:174
{
"requestId":"c71ec29d-b292-46c0-9138-a8ff434f2c3e",
"realm":"/api/alarm/create",
"payload":
{
"type":"0",
"name":"alarm1",
"value":"100000",
"metric":"3",
"node":"3",
"time":"1000"
}
} |
| |
...
...
user/service
content-type:application/json;charset=UTF-8
subscription:sub-1
message-id:3-51
content-length:84
{
"requestId":"c71ec29d-b292-46c0-9138-a8ff434f2c3e",
"status":200,
"reason":"SUCCESS"
} |
| 200 OK 400 Object not found 500 Persist exception |
REST API | Code Block |
---|
| POST: /api/alarm/create "application/json; charset=utf-8"
{
|
|
...
...
...
...
...
...
...
...
...
...
...
| Code Block |
---|
| {
"status":200,
"reason":"SUCCESS"
} |
| 200 OK 400 Object not found 500 Persist exception |
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 100 kbps for more than 5 seconds1 second, was created.
If node Id is not set, the alarm applies to all the nodes on backend server.
...
An alarm parameters can be changed with REST API query /api/alarm/update request
...
...
Response status |
---|
WS API | Code Block |
---|
| SEND
destination:/app/api/alarm/update
content-length:183
{
"requestId":"a60920eb-257a-451f-937f-1226a3856610",
"realm":"/api/alarm/update",
"payload":
{
"id":"6",
"type":"0",
"name":"alarm1",
"value":"100000",
"metric":"3",
"node":"3",
"time":"1000"
}
} |
| |
...
...
user/service
content-type:application/json;charset=UTF-8
subscription:sub-1
message-id:3-56
content-length:84
{
"requestId":"a60920eb-257a-451f-937f-1226a3856610",
"status":200,
"reason":"SUCCESS"
} |
| 200 OK 400 Object not found 500 Persist exception |
REST API | Code Block |
---|
| POST: /api/alarm/update "application/json; charset=utf-8"
{
|
|
...
...
...
...
...
...
...
...
...
...
...
...
...
...
| Code Block |
---|
| {
"status":200,
"reason":"SUCCESS"
} |
| 200 OK 400 Object not found 500 Persist exception |
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 can be deleted with REST API query /api/alarm/delete request
...
API | Request | Response | Response status |
---|
WS API | Code Block |
---|
| SEND
destination:/app/api/alarm/delete
content-length:101
{
"requestId":"c108dbf9-35c0-42e5-814c-0eec57c4de8e",
"realm":"/api/alarm/delete",
"payload":
{
"id":"6"
}
} |
| |
...
MESSAGE
destination:/user/ |
|
...
service
content-type:application/json;charset=UTF-8
subscription:sub-1
message-id:3-57
content-length:84
{
"requestId":"c108dbf9-35c0-42e5-814c-0eec57c4de8e",
"status":200,
"reason":"SUCCESS"
} |
| 200 OK 400 Object not found 500 Persist exception |
REST API | Code Block |
---|
| POST: /api/alarm/delete "application/json; charset=utf-8"
{
|
|
...
| Code Block |
---|
| {
"status":200,
"reason":" |
|
...
| 200 OK 400 Object not found 500 Persist exception |
Where
...
An alarm information can be obtained with REST API query /api/alarm/list request
API | Request | Response | Response status |
---|
WS API | |
...
|
---|
| SEND
destination:/app/api/alarm/list
content-length:98
{
"requestId":"d8e79851-85eb-4df1-bd3a-9f13090e8be5",
"realm":"/api/alarm/list",
"payload":
{
"id":""
}
} |
| |
...
...
user/service
content-type:application/json;charset=UTF-8
subscription:sub-1
message-id:3-60
content-length:177
{
"requestId":"d8e79851-85eb-4df1-bd3a-9f13090e8be5",
"status":200,
"reason":"SUCCESS",
"payload":[
{
"id":8,
"name":"alarm1",
"type":0,
"value":100000,
"time":1000,
"metric":3,
"node":3
}
]
} |
| 200 OK 400 Object not found 500 Persist exception |
REST API | Code Block |
---|
| POST: /api/alarm/list "application/json; charset=utf-8"
{ |
|
...
| Code Block |
---|
| {
"status": 200,
"reason": "SUCCESS",
"payload": [
{
"id": 8,
"name": "alarm1",
"type": 0,
"value": 100000,
"time": 1000,
"metric": 3,
"node": 3
}
]
} |
| 200 OK 400 Object not found 500 Persist exception |
Where
...
For every alarm, the response contains the same fields as /api/alarm/update queryrequest.