Hey!
First off Sensu Go handlers retrieve events in json format. But thereās no event.output. What you probably want is event.check.output
When developing a handler I usually is take a look at the event json representation I want to process so I can understand its structure. Hereās how you can do that with sensuctl
sensuctl event info <entityname> <checkname> --format json
Hereās a truncated example from my systemā¦ I like using jq to pretty print the json into something more human readable.
sensuctl event info carbon-f31 keepalive --format json |jq
{
"check": {
"handlers": [
"keepalive"
],
"high_flap_threshold": 0,
"interval": 20,
"low_flap_threshold": 0,
"publish": false,
"runtime_assets": null,
"subscriptions": [],
"proxy_entity_name": "",
"check_hooks": null,
"stdin": false,
"subdue": null,
"ttl": 0,
"timeout": 120,
"round_robin": false,
"executed": 1589398958,
"history": [
...
The āoutputā is actually from the check object inside the event structure.
sensuctl event info carbon-f31 keepalive --format json |jq .check.output
"No keepalive sent from carbon-f31 for 669495 seconds (>= 120)"
When developing or testing handlers, prior to putting them in production, what I like doing is saving a specific event json into a text file on disk and running the handler manually piping in the json event.
sensuctl event info carbon-f31 keepalive --format json > failing_keepalive_event.json
cat failing_keepalive_event.json | my_custom_handler
Once you have the event captured in a json file like that, you can even make that part of your CI/CD tests if your developing a plugin.
Hope this helps.