Skip to content

Events & Event handlers

adamkobor edited this page Sep 2, 2020 · 12 revisions

Kuvasz is built around events and their handlers. Every check that Kuvasz makes, emits an event, and the handlers who are subscribed to them handle these events in different ways.

Events

MonitorUpEvent

Has been emitted when a website passes the uptime check, i.e. it's live and "healthy". It also contains the latency of the response.

MonitorDownEvent

Has been emitted when a website is unreachable, an it contains the cause of the error.

RedirectEvent

Kuvasz is following redirects through HTTP calls, so when a call is forwarded to an other address, a RedirectEvent will be emitted. It contains the new location from the Location header of the original response.

Event handlers

You can get information about the configured handlers through the built-in /info endpoint, which can be called without authentication as well. The response will be an object like that:

{
  "handlers": {
    "log-event-handler.enabled": true,
    "smtp-event-handler.enabled": false,
    "slack-event-handler.enabled": true
  }
}

STDOUT (log-event-handler)

Handled events:

  • MonitorUpEvent
  • MonitorDownEvent
  • RedirectEvent

This handler writes a simple log message to STDOUT and can be switched off through the ENABLE_LOG_EVENT_HANDLER environment variable.

Examples:

  • Your monitor "test_up" (https://test.com) is UP (200). Latency was: 1826ms.
  • Your monitor "test_down" (https://test2.com) is DOWN. Reason: Connect Error: Connection refused: test2.com
  • Request to "test_redirected" (https://redirected.com) has been redirected

SMTP (smtp-event-handler)

Handled events:

  • MonitorUpEvent
  • MonitorDownEvent

This handler sends email messages about the state of your monitors, and can be set up through environment variables. Same events would be suppressed, which means that two or more consecutive UP or DOWN events wouldn't result in more than one email notification.

Slack (slack-event-handler)

Handled events:

  • MonitorUpEvent
  • MonitorDownEvent

This handler sends notifications through an incoming webhook to Slack about the state of your monitors, and can be set up through environment variables. Same events would be suppressed, which means that two or more consecutive UP or DOWN events wouldn't result in more than one notification. If you aren't familiar with Slack's webhooks, you can read about the initial setup here.

Telegram (telegram-event-handler)

Handled events:

  • MonitorUpEvent
  • MonitorDownEvent

This handler sends notifications through the Bot API to Telegram about the state of your monitors, and can be set up through environment variables. Same events would be suppressed, which means that two or more consecutive UP or DOWN events wouldn't result in more than one notification. If you aren't familiar with Telegram's bots, you can read about them here.

Clone this wiki locally