Events
Reference documentation
What are Sensu events?
Sensu events are created to acknowledge that something potentially noteworthy has occurred, which events may then be processed by one or more event handlers to do things such as send an email, or invoke an automated action. Every Sensu event provides context, called “event data”, which contains information about the originating Sensu client and the corresponding check result.
How are Sensu events created?
A Sensu Event is created every time a check result is processed by the Sensu server, regardless of the status indicated by the check result. An Event is created by collating data from the check result, the client registry and additional context added at the time of processing.
Event actions
Sensu supports the following event actions.
- create. Indicates a check result
status
change from zero to non-zero. - resolve. Indicates a check result
status
change from a non-zero to zero. - flapping. Indicates a rapid change in check result
status
.
action
s, please see the Sensu event data
specification, below.Event data
Example event
The following is an example Sensu event. By default, event data is JSON formatted, making it language-independent and fairly human readable.
[
{
"id": "ef6b87d2-1f89-439f-8bea-33881436ab90",
"action": "create",
"timestamp": 1460172826,
"occurrences": 2,
"check": {
"type": "standard",
"total_state_change": 11,
"history": ["0", "0", "1", "1", "2", "2"],
"status": 2,
"output": "No keepalive sent from client for 230 seconds (>=180)",
"executed": 1460172826,
"issued": 1460172826,
"name": "keepalive",
"thresholds": {
"critical": 180,
"warning": 120
}
},
"client": {
"timestamp": 1460172596,
"version": "1.0.0",
"socket": {
"port": 3030,
"bind": "127.0.0.1"
},
"subscriptions": [
"production"
],
"environment": "development",
"address": "127.0.0.1",
"name": "client-01"
}
}
]
Event data specification
EVENT
attributes
The following attributes are available in the root scope of the event data JSON document:
id | |
---|---|
description | Persistent unique ID for the event. |
type | String |
possible values | Any Ruby SecureRandom.uuid value |
example |
|
timestamp | |
---|---|
description | The time the event occurred in Epoch time (generated via Ruby Time.now.to_i ) |
type | Integer |
example |
|
action | |
---|---|
description | The Sensu event action, providing event handlers with more information about the state change. |
type | String |
possible values | create , resolve , flapping |
default | create |
example |
|
last_ok | |
---|---|
description | The most recent time a check result indicated an ‘OK’ status for this client/check pair (generated via Ruby Time.now.to_i ). |
type | Integer |
example | 1528150592 |
occurrences | |
---|---|
description | The occurrence count for the event; the number of times an event has been created for a client/check pair with the same state (check status). |
type | Integer |
default | 1 |
example |
|
occurrences_watermark | |
---|---|
description | The “high water mark” tracking number of occurrences at the current severity. |
type | Integer |
default | 1 |
example |
|
check | |
---|---|
description | The check result check attributes. |
type | Hash |
example |
|
client | |
---|---|
description | Client attributes from the originating client, or the proxy client attributes, in the case of an event from a proxy client. |
type | Hash |
example |
|
silenced | |
---|---|
description | |
type | |
example |
silenced_by | |
---|---|
description | List of silence entry IDs which match this event |
type | Array |
example |
|
check
attributes
The following attributes are available in the { "check": {} }
scope of the
event data JSON document.
type | |
---|---|
description | The check type. |
default | standard |
allowed values | standard , metric |
type | String |
example |
|
name | |
---|---|
description | The name as defined in the originating check definition. |
type | String |
required | true |
example |
|
command | |
---|---|
description | The command as defined in the originating check definition. |
type | String |
required | true |
example |
|
subscribers | |
---|---|
description | The subscribers as defined in the originating check definition. |
type | Array |
required | true |
example |
|
interval | |
---|---|
description | The interval , in seconds, as defined in the originating check definition. |
type | Integer |
required | true |
example |
|
handler | |
---|---|
description | The handler as defined in the originating check definition. |
type | String |
required | false |
example |
|
handlers | |
---|---|
description | The handlers as defined in the originating check definition. |
type | Array |
required | false |
example |
|
issued | |
---|---|
description | The issued timestamp (in epoch time), when Sensu issued the check request (for a subscription check or standalone check). |
type | Integer |
required | false |
example |
|
output | |
---|---|
description | The output produced by the check, as included in the check result. |
type | String |
required | true |
example |
|
status | |
---|---|
description | The exit status code produced by the check, as included in the check result. |
type | Integer |
required | true |
example |
|
history | |
---|---|
description | The history of the last 21 exit status codes produced by the check, as included in the check result. |
type | Array |
required | true |
example |
|
source | |
---|---|
description | The name of the proxy client to associate the event with, as included in the check result (source attribute).NOTE: the source attribute may be included in check definitions, or provided in check results published to the Sensu client input socket. |
type | String |
required | false |
example |
|
origin | |
---|---|
description | The name of the Sensu client that executed the check.NOTE: this attribute is only provided for proxy client events (i.e. events containing a source attribute. |
type | String |
required | false |
example |
|
client
attributes
The following attributes are available in the { "client": {} }
scope of the
event data JSON document.
name | |
---|---|
description | The name of the Sensu client (or proxy client) the event is associated with, as fetched from the Clients API. |
type | String |
required | true |
example |
|
address | |
---|---|
description | The address of the Sensu client (or proxy client) the event is associated with, as fetched from the Clients API. |
type | String |
required | true |
example |
|
subscriptions | |
---|---|
description | The subscriptions the associated Sensu client (or proxy client) is a member of, as fetched from the Clients API. |
type | Array |
required | true |
example |
|
timestamp | |
---|---|
description | The last keepalive timestamp (in epoch time) produced by the Sensu client (or proxy client), as fetched from the Clients API.NOTE: for proxy clients, this will usually represent the date/time when the proxy client was created, unless some external process is updating proxy client data via the Clients API (POST). |
type | Integer |
required | true |
example |
|