Skip to content

Retrieve on-call schedules from Datadog and send notifications to Slack

License

Notifications You must be signed in to change notification settings

rgeraskin/dogoncall

Repository files navigation

DogOnCall

DogOnCall is a Go application that retrieves an on-call schedule from Datadog and sends notification to Slack about the current on-call engineer.

Slack will receive following variables from app:

  • engineer_email: Email of the current on-call engineer.
  • schedule_name: Schedule name.
  • schedule_link: Link to datadog schedule page.

Engineer email in Datadog and Slack should be equal.

Usage

Slack workflow

In Slack app:

  1. More button on the left screen side => Automations => Workflows => New workflow => Build workflow

  2. For Start the workflow… choose event From a webhook

  3. Set up variables:

    1. engineer_email as Slack user email
    2. schedule_name and schedule_link as Text.
  4. Use Web request URL as SLACK_ENDPOINT later.

  5. For Then, do these things choose Send a message to... and compose a message using variables.

    See this if you want to use schedule_name and schedule_link together as link.

  6. Publish the workflow

App configuration

The application requires the following environment variables:

  • DD_API_KEY: Your Datadog API key.
  • DD_APP_KEY: Your Datadog application key.
  • SCHEDULE_NAME: The name of the Datadog on-call schedule.
  • SLACK_ENDPOINT: The Slack workflow webhook endpoint to send notifications.

App running

It's reasonable to run this app by a cron. For k8s I use CronJob in the Helm chart.

Using Helm

# put required values in helm/values-private.yaml
helm upgrade --install dogoncall oci://registry-1.docker.io/rgeraskin/helm-dogoncall -f helm/values-private.yaml

or from the cloned git repo:

# put required values in helm/values-private.yaml
helm upgrade --install dogoncall ./helm -f helm/values-private.yaml

Using Docker

# put required envs in .env
docker run --name dogoncall --env-file .env --rm rgeraskin/dogoncall:latest

or from the cloned git repo:

# put required envs in .env
docker buildx build . -t dogoncall
docker run --name dogoncall --env-file .env --rm dogoncall

From Source

go install github.com/rgeraskin/dogoncall/dogoncall@latest
# export required env vars
dogoncall

or from the cloned repo:

go build -C dogoncall -o ..
# export required env vars
./dogoncall

Local development

Prepare local env

  1. Install mise: brew install mise

  2. Activate mise

    Zsh example:

    echo 'eval "$(~/.local/bin/mise activate zsh)"' >> ~/.zshrc
    # restart shell or `source ~/.zshrc`
  3. mise install in the repo root dir to install all required tools

Development hints

  • Use Tilt for a realtime k8s experience: tilt up
  • Use mise tasks for routines: mise run build, mise run deploy

License

This project is licensed under the MIT License. See the LICENSE file for details.

About

Retrieve on-call schedules from Datadog and send notifications to Slack

Topics

Resources

License

Stars

Watchers

Forks