Events
or click any element in the pipeline to jump to it.
Events are generic containers that Sensu uses to provide context to status and metrics check results. The context, called observation data, is information about the originating entity and the corresponding status or metric check result.
These generic containers allow Sensu to handle different types of events in the pipeline for comprehensive system and service monitoring and observability. Events can contain CPU, memory, and disk usage data; custom application metrics; log data you can send to an external database; and more.
Events require a timestamp, entity, and check. Each event must contain a check result, whether status or metrics. In certain cases, an event can contain both. Because events are polymorphic in nature, it is important to never assume their content (or lack of content).
Here’s an example event that includes both status and metrics data:
type: Event
api_version: core/v2
metadata:
namespace: default
spec:
check:
check_hooks: null
command: /opt/sensu-plugins-ruby/embedded/bin/metrics-curl.rb -u "http://localhost"
duration: 0.060790838
env_vars: null
executed: 1552506033
handlers: []
high_flap_threshold: 0
history:
- executed: 1552505833
status: 0
- executed: 1552505843
status: 0
interval: 10
is_silenced: false
issued: 1552506033
last_ok: 1552506033
low_flap_threshold: 0
metadata:
name: curl_timings
namespace: default
occurrences: 1
occurrences_watermark: 1
output: |-
sensu-go-sandbox.curl_timings.time_total 0.005 1552506033
sensu-go-sandbox.curl_timings.time_namelookup 0.004
output_metric_format: graphite_plaintext
output_metric_handlers:
- influx-db
proxy_entity_name: ""
publish: true
round_robin: false
runtime_assets: []
state: passing
status: 0
stdin: false
subdue: null
subscriptions:
- entity:sensu-go-sandbox
timeout: 0
total_state_change: 0
ttl: 0
entity:
deregister: false
deregistration: {}
entity_class: agent
last_seen: 1552495139
metadata:
name: sensu-go-sandbox
namespace: default
redact:
- password
- passwd
- pass
- api_key
- api_token
- access_key
- secret_key
- private_key
- secret
subscriptions:
- entity:sensu-go-sandbox
system:
arch: amd64
hostname: sensu-go-sandbox
network:
interfaces:
- addresses:
- 127.0.0.1/8
- ::1/128
name: lo
- addresses:
- 10.0.2.15/24
- fe80::5a94:f67a:1bfc:a579/64
mac: 08:00:27:8b:c9:3f
name: eth0
os: linux
platform: centos
platform_family: rhel
platform_version: 7.5.1804
processes: null
user: agent
metrics:
handlers:
- influx-db
points:
- name: sensu-go-sandbox.curl_timings.time_total
tags: []
timestamp: 1552506033
value: 0.005
- name: sensu-go-sandbox.curl_timings.time_namelookup
tags: []
timestamp: 1552506033
value: 0.004
timestamp: 1552506033
id: 431a0085-96da-4521-863f-c38b480701e9
sequence: 1
{
"type": "Event",
"api_version": "core/v2",
"metadata": {
"namespace": "default"
},
"spec": {
"check": {
"check_hooks": null,
"command": "/opt/sensu-plugins-ruby/embedded/bin/metrics-curl.rb -u \"http://localhost\"",
"duration": 0.060790838,
"env_vars": null,
"executed": 1552506033,
"handlers": [],
"high_flap_threshold": 0,
"history": [
{
"executed": 1552505833,
"status": 0
},
{
"executed": 1552505843,
"status": 0
}
],
"interval": 10,
"is_silenced": false,
"issued": 1552506033,
"last_ok": 1552506033,
"low_flap_threshold": 0,
"metadata": {
"name": "curl_timings",
"namespace": "default"
},
"occurrences": 1,
"occurrences_watermark": 1,
"output": "sensu-go-sandbox.curl_timings.time_total 0.005 1552506033\nsensu-go-sandbox.curl_timings.time_namelookup 0.004",
"output_metric_format": "graphite_plaintext",
"output_metric_handlers": [
"influx-db"
],
"proxy_entity_name": "",
"publish": true,
"round_robin": false,
"runtime_assets": [],
"state": "passing",
"status": 0,
"stdin": false,
"subdue": null,
"subscriptions": [
"entity:sensu-go-sandbox"
],
"timeout": 0,
"total_state_change": 0,
"ttl": 0
},
"entity": {
"deregister": false,
"deregistration": {},
"entity_class": "agent",
"last_seen": 1552495139,
"metadata": {
"name": "sensu-go-sandbox",
"namespace": "default"
},
"redact": [
"password",
"passwd",
"pass",
"api_key",
"api_token",
"access_key",
"secret_key",
"private_key",
"secret"
],
"subscriptions": [
"entity:sensu-go-sandbox"
],
"system": {
"arch": "amd64",
"hostname": "sensu-go-sandbox",
"network": {
"interfaces": [
{
"addresses": [
"127.0.0.1/8",
"::1/128"
],
"name": "lo"
},
{
"addresses": [
"10.0.2.15/24",
"fe80::5a94:f67a:1bfc:a579/64"
],
"mac": "08:00:27:8b:c9:3f",
"name": "eth0"
}
]
},
"os": "linux",
"platform": "centos",
"platform_family": "rhel",
"platform_version": "7.5.1804",
"processes": null
},
"user": "agent"
},
"metrics": {
"handlers": [
"influx-db"
],
"points": [
{
"name": "sensu-go-sandbox.curl_timings.time_total",
"tags": [],
"timestamp": 1552506033,
"value": 0.005
},
{
"name": "sensu-go-sandbox.curl_timings.time_namelookup",
"tags": [],
"timestamp": 1552506033,
"value": 0.004
}
]
},
"timestamp": 1552506033,
"id": "431a0085-96da-4521-863f-c38b480701e9",
"sequence": 1
}
}
Checks
Checks work with the Sensu agent to produce events automatically. You can use checks to monitor server resources, services, and application health as well as collect and analyze metrics. Checks define how Sensu will process events, as well as when and where events are generated via subscriptions and scheduling.
Read Monitor server resources to learn more about using checks to generate events.
Status-only events
A Sensu event is created every time a check result is processed by the Sensu server, regardless of the status the result indicates. The agent creates an event upon receipt of the check execution result and executes any configured hooks the check might have. From there, the status result is forwarded to the Sensu backend, where it is filtered, transformed, and processed. Potentially noteworthy events may be processed by one or more event handlers, for example to send an email or invoke an automated action.
Metrics-only events
Sensu events can be created when the agent receives metrics through the StatsD listener. The agent will translate the StatsD metrics to Sensu metric format and place them inside an event. Because these events do not contain checks, they bypass the store and are sent to the event pipeline and corresponding event handlers.
Status and metrics events
Events that contain both a check and metrics most likely originated from check output metric extraction.
If a check is configured for metric extraction, the agent will parse the check output and transform it to Sensu metric format.
Both the check results and resulting (extracted) metrics are stored inside the event.
Event handlers from event.Check.Handlers
and event.Metrics.Handlers
will be invoked.
Proxy entities and events
You can create events with proxy entities, which are dynamically created entities that Sensu adds to the entity store if an entity does not already exist for a check result. Proxy entities allow Sensu to monitor external resources on systems where you cannot install a Sensu agent, like a network switch or website. See Monitor external resources to learn how to use a proxy entity to monitor a website.
Events API
Sensu’s events API provides HTTP access to create, retrieve, update, and delete events. If you create a new event that references an entity that does not already exist, the Sensu backend will automatically create a proxy entity when the event is published.