Integrate Spike with Sensu Go
Send Sensu Go check events to Spike through a pipe handler and pipeline, so a failing check pages your on-call and a passing check resolves the incident.
Sensu Go runs checks on your agents and proxy entities and hands the resulting events to handlers. A handler in a pipeline can post each event to Spike: a failing check opens an incident and pages your escalation policy, repeats of the same check join that incident, and the check returning to status 0 resolves it.
Prerequisites
A Sensu Go backend, and a user that can create handlers and pipelines in the namespace of your checks
A Sensu Go integration in Spike and its webhook URL
curlon the host or container that runssensu-backend, with outbound HTTPS tohooks.spike.sh
Step 1 — Create the integration in Spike
Make a Sensu Go integration, attach it to a service and an escalation policy, and copy the webhook URL. It looks like https://hooks.spike.sh/<your-token>/push-events.
Step 2 — Create a pipe handler in Sensu Go
A pipe handler runs a command and writes the event to its standard input. Spike receives that event JSON, unchanged, as the request body. Run this on a machine with sensuctl configured, in the namespace of your checks. Replace <your-spike-webhook-url> with the URL you copied.
sensuctl handler create spike --type pipe \
--command "curl -sS --fail -X POST -H 'Content-Type: application/json' --data-binary @- <your-spike-webhook-url>" \
--timeout 10--data-binary @- makes curl post the event read from standard input as the body, byte for byte. --fail makes curl exit non-zero when Spike answers with an error, so a failed post shows up in the sensu-backend log.
Step 3 — Create a pipeline that uses the handler
Save this resource as spike-pipeline.yml and run sensuctl create --file spike-pipeline.yml:
The built-in is_incident filter passes failing events and the event that resolves them, so Spike gets both the alert and its recovery. Keep it: without is_incident the pipeline posts every passing check result to Spike, not only the one that resolves an incident.
Step 4 — Add the pipeline to your checks
Run sensuctl edit check check-disk-usage (with your check's name) and add a pipelines entry to the check's spec:
Or put the same pipelines list in the check's YAML and apply it with sensuctl create. sensuctl has no set-pipelines subcommand, so the pipeline has to be listed in the check definition.
Step 5 — Confirm it with a failing check
Make a check fail (lower its warning threshold, for example). An incident opens in Spike on the service you attached. When the check returns to status 0 the incident resolves itself.
How Spike reads an event
Spike reads these fields from the event Sensu sends. You do not build the body yourself: the handler passes Sensu's event through.
entity.metadata.name
Yes
The entity (agent host or proxy entity) the check ran for. Half of the incident identity, and the "where" of the title.
check.metadata.name
Yes
The check name. The other half of the identity.
entity.metadata.namespace
Recommended
The Sensu namespace. Keeps the same entity and check names in two namespaces as two separate alerts.
check.status
Yes
0 is OK and resolves. 1 is a warning and 2 is critical. Any other integer is unknown or custom. All of those open or join an incident.
check.output
Recommended
The plugin's output. Its first line becomes the incident title.
check.state (passing, failing, flapping) is not read: check.status decides. The event's top-level id is a new UUID for every check execution, so it is never used to match anything.
What opens, joins and resolves an incident
Opens or joins: any event whose
check.statusis not0. A status that is missing or unreadable also opens or joins, and never resolves.Resolves: an event whose
check.statusis the number0or the string"0", for the same entity, check and namespace as the open incident. Both events must name the entity and the check. This includes a flapping check that reports status 0.Identity:
entity.metadata.namepluscheck.metadata.name, scoped byentity.metadata.namespacewhen present. A name counts only when it is a non-empty string or a number. Everything else in the event can change between deliveries (timestamps,sequence,check.output,check.history, counters,check.status) and a repeat still joins the open incident.No identity: if either
entity.metadata.nameorcheck.metadata.nameis missing, Spike falls back to matching by title, so it uses the plain title below without the plugin output. Such an event never resolves an incident: its recovery joins the open incident, which you resolve in Spike.
Incident title
The title is the plugin's output followed by the entity:
The output line is the first non-empty line of
check.output, with everything from the first|(Nagios performance data, with or without a space before it) dropped and whitespace collapsed.on {entity.metadata.name}is added only when the line does not already name the entity as a whole word.The title is at most 200 characters. A longer line is cut at a word boundary and ends in
..., and theon {entity}part is kept whole.If
check.outputis empty:{check.metadata.name} on {entity.metadata.name}.A recovery (status 0):
{check.metadata.name} recovered on {entity.metadata.name}.Without identity, the output is never used:
{check.metadata.name} on {entity.metadata.name}, or whichever of the two exists.Nothing usable:
Sensu Go alert with no details.
For the firing event below the title is:
and for the recovery event:
The title is for display. The entity and check names decide which incident an event belongs to, so a reading that changes in the output does not open a new incident. Use a Title Remapper if you prefer another title.
Example payloads
A firing event, which opens the incident:
The recovery event has the same shape. check.status is 0, check.state is "passing", and the output is an OK message:
Things worth knowing
Several Spike integrations are fine. Create one handler and pipeline per Spike integration if different teams own different checks.
Resolving in Spike does not touch Sensu. The check keeps failing in Sensu until it passes.
Keep the check name stable. Renaming a check in Sensu makes its recovery a different alert from the incident opened under the old name.
Disclaimer: These integration instructions are offered independently by Spike.sh, and Spike.sh is not affiliated with nor a partner of Sensu Inc.
Last updated

