Incidents Event
Event that fires when an incident was created, updated or moved to incident history.
Request
-
Subscribe
-
Unsubscribe
cn.emit('add-topics', 'incidents', '{"parentFilter":""}')
cn.emit('remove-topics', 'incidents')
Filter incidents
You can filter incidents on the server side by passing Incident filters when you subscribe to an incidents topic.
Incidents that do not match the filter are still received by the client, but they have a
|
let filter = {
"filter":[
"$and",
[
[
"classId","34"
],
[
"$or",
[
[
"severity",[1]
],
[
"tags","628fd2aa3587da6522d8e963"
]
]
]
]
],
"parentFilter":""
}
cn.emit('add-topics', 'incidents', filter)
You can also filter incidents by the parent object. To do this, specify the ID of the parent object in the parentFilter
field.
filter = {
"parentFilter":"62fc3d840b04be66c9ce4dbd"
}
cn.emit('add-topics', 'incidents', filter)
Response
Response contains the following fields:
Field | Type | Description |
---|---|---|
changeType |
Integer |
Type of change that triggered this event. |
payload |
Incident information. Depends on whether this incident was filtered. If the incident matches the filter, server sends all available fields. If the incident doesn’t match the filter, |
Example
Request
const comet = require('socket.io-client');
// Comet settings
const COMET_CONNECT_TIMEOUT = 5000;
const sessionId = "..."
const conf = {
cometHost: 'https://example.com',
cometPort: '1234',
};
const url = `${conf.cometHost}` + (conf.cometPort ? `:${conf.cometPort}` : '');
const cn = comet.connect(url, {
query: { forceNew: true, sessionId },
timeout: COMET_CONNECT_TIMEOUT,
});
let filter = {
"filter":[
"$and",
[
[
"classId","34"
],
[
"$or",
[
[
"severity",[1]
],
[
"tags","628fd2aa3587da6522d8e963"
]
]
]
]
],
"parentFilter":"62fc3d840b04be66c9ce4dbd"
}
cn.emit('add-topics', 'incidents');
cn.on('incidents', msg => {
console.log(msg);
});
Response
{
"changeType": 2,
"payload": {
"id": "63625653cc277a5f1af2ad5c",
"branchId": "63511e7ef441703c22796920",
"entityId": "634023d414d3e37c5d8c865b",
"entityType": 1,
"type": 2,
"data": "{\"packetsTransmitted\":5,\"packetsReceived\":5,\"packetLossPercentile\":0,\"numberOfErrors\":0,\"numberOfDuplicates\":0,\"roundTripMinimal\":15.397,\"roundTripAverage\":15.511,\"roundTripMaximum\":15.928,\"exitCode\":0}",
"lastState": 1,
"localTimestamp": 1667389011294,
"parentChainId": "634023d414d3e37c5d8c865b",
"state": 1,
"text": "",
"timestamp": 1667389011293,
"clearTimestamp": 1667389071672,
"owner": {
"parent_id": [
"62fc3d840b04be66c9ce4dbd"
],
"client_data": "{\"headlinePropIds\":[],\"custom_style\":{\"zIndex\":25,\"left\":\"155px\",\"top\":\"0px\",\"width\":\"300px\",\"height\":\"200px\"},\"widgets\":[{\"id\":\"4d908135-0bf7-4842-9569-8ac21f3d0f03\",\"type\":\"counter\",\"parameters\":{\"metric\":\"packetsTransmitted\"}}],\"collapseSections\":{\"numberOfErrors\":true,\"roundTripAverage\":true}}",
"object_groups": [],
"name": "Info",
"class_id": 34,
"geoposition": [],
"geopositionRadius": 0,
"tags": [
"628fd2aa3587da6522d8e963"
],
"operations": [
{
"name": "Hello World",
"description": "",
"popupResult": true,
"type": 2,
"parameters": {
"type": "scriptText",
"text": "echo 'Hello World!'"
},
"id": "634ed7b7f441703c2279540a"
}
],
"owner_id": "633c2b259ebf31086056225c",
"updated": 1667388967996,
"properties": [
{
"type_id": 8,
"name": "AgentId",
"value": "625439c60db03e3f4504b548",
"id": "634023db14d3e37c5d8c8664"
},
{
"type_id": 8,
"name": "TaskType",
"value": "ping",
"id": "634023de14d3e37c5d8c8666",
"owner_id": "634023d414d3e37c5d8c865b",
"owner_type": 1
},
{
"type_id": 8,
"name": "PingTimeout",
"value": "30",
"id": "634023de14d3e37c5d8c8668",
"owner_id": "634023d414d3e37c5d8c865b",
"owner_type": 1
},
{
"type_id": 8,
"name": "PingPacketsCount",
"value": "5",
"id": "634023de14d3e37c5d8c866a",
"owner_id": "634023d414d3e37c5d8c865b",
"owner_type": 1
},
{
"type_id": 8,
"name": "PingHost",
"value": "example.com",
"id": "634023e214d3e37c5d8c866c",
"owner_id": "634023d414d3e37c5d8c865b",
"owner_type": 1
},
{
"type_id": 8,
"name": "TaskPeriodValue",
"value": "1",
"id": "634e57d6f441703c227951c8"
},
{
"type_id": 8,
"name": "TaskPeriodUnit",
"value": "seconds",
"id": "634e57d69b9c923a47c52e0c"
},
{
"type_id": 1,
"name": "alarm_group",
"value": "135",
"id": "635696f6028e5c2ba71c6fcc",
"owner_id": "634023d414d3e37c5d8c865b",
"owner_type": 1
},
{
"type_id": 1,
"name": "rca_probability",
"value": "0.99",
"id": "635696f7028e5c2ba71c6fd0",
"owner_id": "634023d414d3e37c5d8c865b",
"owner_type": 1
},
{
"type_id": 1,
"name": "rca_time_calc",
"value": "1667281935.2799296",
"id": "635696f7028e5c2ba71c6fd4",
"owner_id": "634023d414d3e37c5d8c865b",
"owner_type": 1
}
],
"state_id": 4,
"created": 1665147860002,
"last_state_update": 1667388967996,
"weight": 1,
"child_ids": [],
"child_link_ids": [],
"child_ref_ids": [],
"manual_state": {
"stateId": 4,
"reason": "test",
"until": 1667389861870,
"by": "633c2b259ebf31086056225c"
},
"id": "634023d414d3e37c5d8c865b"
}
}
}