Skip to content

roryl23/butterbot

Repository files navigation

butterbot

Overview

Passes butter by requesting configured HTTP services, keeping track of responses, and notifying of state changes.

Can be configured to watch Kafka topics for new messages, and alert if no new data has come across for a specified interval.

Also can be configured to watch a Kafka topic for "events", where a message on the topic is transformed into an alert.

Usage

Compile for testing:

  • bash build.sh

Build Docker image:

  • docker build -t butterbot:latest .

Running butterbot

Create a config.yaml file that looks like this:

butterbot:
  notifiers:
    - name: some-alerts
      type: discord
      url: https://discord.com/webhook
      content_type: application/json
      status_code: 204
    - name: other-alerts
      type: discord
      url: https://discord.com/otherwebhook
      content_type: application/json
      status_code: 204
  httpchecks:
    - name: Your API
      notify: 
        - some-alerts
      parameters:
        method: http
        verb: get
        url: https://yourapi.com/
        code: 200
        skip_verify: false
        timeout: 5
      status: true
  kafkatopicchecks:
    - name: Some data feed
      notify: 
        - some-alerts
      parameters:
        host: kafka.yourdomain.com
        topic: some-topic
        timeout: 600
      status: true
    - name: Another data feed
      notify: 
        - some-alerts
      parameters:
        host: kafka.yourdomain.com
        topic: other-topic
        timeout: 65
      status: true
  kafkaevents:
    - name: Some event happened
      notify: 
        - other-alerts
      parameters:
        host: kafka.yourdomain.com
        topic: events
        key: somekey
        filter:
          - message_field: filter_value
        extract:
          - myfield

Run it like this: ./butterbot --config-file config.yaml

The configuration above would produce alerts like:

  • Your API is down
  • Some data feed is down
  • Another data feed is up
  • Some event happened, myfield: extractedvalue

Where the sent message is constructed like:

  • HTTP alerts and Kafka topic checks: <name> is up/down
  • Kafka topic events: <name>, <extract_field>: <extracted_value>,...