How to trigger an event, if agent does not register in time (no keepalive)?

Description of your problem

I would like to see an event triggered if a agent does not connect to the Sensu Go backend within a certain timeframe.

Description of steps you’ve taken to attempt to solve the issue

I have added a configuration for the agent, that is expected to connect and can see it if I run sensuctl entity list with “Last seen” set to “N/A”. I have tried specifying the keepalive timeout values. However, they only trigger an event if the agent sent an initial keepalive.

Environmental information

Operating system information

  • Debian

Package versions

  • Sensu Go: 6.9.1 CE (built with go1.20.2)
  • Etcd: built-in
  • PostgreSQL: -

Thank you for your help.

Hello Tofi, hope this finds you well.

There is no built in way to alert on failed agent connectivity. My suggestion(s) would be either a scripted check script as simple as the one below or a scripted api call to grab entities with a last keepalive value of null while the entity has existed for more than n minutes. Then handling the event alert with your preferred handler.

Possible drawback of the log check approach would be the absence of the error in logs due to a low log level, Please make sure to set the log level to debug while testing.


if journalctl -u sensu-backend | grep -q “websocket connection error”; then
exit 1
exit 0

Documentation reference links


Hello Yussuf,

thank you for your fast reply and the suggested workarounds.