• Stars
    star
    153
  • Rank 243,368 (Top 5 %)
  • Language
    Go
  • License
    MIT License
  • Created almost 6 years ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

🔔 Send alert notifications to Google Chat via Prometheus Alertmanager

calert

Send Alertmanager notifications to Google Chat (and more!)

calert uses Alertmanager webhook receiver to receive alerts payload, and pushes this data to Google Chat webhook endpoint.

Quickstart

Binary

Grab the latest release from Releases.

To run:

./calert.bin --config config.toml

Docker

You can find the list of docker images here

docker pull ghcr.io/mr-karan/calert:latest

Here's an example docker-compose config with a custom message.tmpl mounted inside the container:

  calert:
    image: ghcr.io/mr-karan/calert:latest
    ports:
      - "6000:6000"
    volumes:
      - ./message.tmpl:/etc/calert/message.tmpl

Configuration

Refer to config.sample.toml for instructions on how to configure calert.

All the config variables can also be supplied as Environment Variables by prefixing CALERT_ and replacing . (period) with __ (double underscores).

Example:

  • app.address would become CALERT_APP__ADDRESS

App

Key Explanation Default
app.address Address of the HTTP Server. 0.0.0.0:6000
app.server_timeout Server timeout for HTTP requests. 5s
app.enable_request_logs Enable HTTP request logging. true
app.log Use debug to enable verbose logging. Can be set to info otherwise. info

Providers

calert can load a map of different providers. The unique identifier for the provider is the room name. Each provider has it's own configuration, based on it's provider_type. Currently calert` supports Google Chat but can support arbitary providers as well.

Key Explanation Default
providers.<room_name>.type Provider type. Currently only google_chat is supported. google_chat
providers.<room_name>.endpoint Webhook URL to send alerts to. -
providers.<room_name>.max_idle_conns Maximum Keep Alive connections to keep in the pool. 50
providers.<room_name>.timeout Timeout for making HTTP requests to the webhook URL. 7s
providers.<room_name>.template Template for rendering a formatted Alert notification. static/message.tmpl
providers.<room_name>.thread_ttl Timeout to keep active alerts in memory. Once this TTL expires, a new thread will be created. 12h

Alertmanager Integration

  • Alertmanager has the ability of group similar alerts together and fire only one event, clubbing all the alerts data into one event. calert leverages this and sends all alerts in one message by looping over the alerts and passing data in the template. You can configure the rules for grouping the alerts in alertmanager.yml config. You can read more about it here.

  • Configure Alertmanager config file (alertmanager.yml) and give the address of calert web-server. You can refer to the official documentation for more details.

You can refer to the following config block to route webhook alerts to calert:

route:
    receiver: 'calert'
    group_wait: 30s
    group_interval: 60s
    repeat_interval: 15m
    group_by: ['room', 'alertName']

receivers:
    - name: 'calert'
      webhook_configs:
      - url: 'http://calert:6000/dispatch'

Threading Support in Google Chat

calert ships with a basic support for sending multiple related alerts under a same thread, working around the limitations by Alertmanager.

Alertmanager currently doesn't send any Unique Identifier for each Alert. The use-case of sending related alerts under the same thread is helpful to triage similar alerts and see all their different states (Firing, Resolved) for people consuming these alerts. calert tries to solve this by:

  • Use the fingerprint field present in the Alert. This field is computed by hashing the labels for an alert.
  • Create a map of active_alerts in memory. Add an alert by it's fingerprint and generate a random UUID.v4 and store that in the map (along with some more meta-data like startAt field).
  • Use ?threadKey=uuid query param while making a request to Google Chat. This ensures that all alerts with same fingerprint (=same labels) go under the same thread.
  • A background worker runs every hour which scans the map of active_alerts. It checks whether the alert's startAt field has crossed the TTL (as specified by thread_ttl). If the TTL is expired then the alert is removed from the map. This ensures that the map of active_alerts doesn't grow unbounded and after a certain TTL all alerts are sent to a new thread.

Prometheus Metrics

calert exposes various metrics in the Prometheus exposition format.

Here's a list of internal app metrics available at /metrics:

Name Description Data type
calert_uptime_seconds Uptime of app (in seconds). counter
calert_start_timestamp UNIX timestamp since the app was booted. gauge
calert_http_requests_total Number of HTTP requests, grouped with labels like handler. counter
calert_http_request_duration_seconds_{sum,count,bucket} Duration of HTTP request (in seconds). histogram
calert_alerts_dispatched_total Number of alerts dispatched to upstream providers, grouped with labels like provider and room. counter
calert_alerts_dispatched_duration_seconds_{sum,count,bucket} Duration to send an alert to upstream provider. histogram

It also exposes Go process metrics in addition to app metrics, which you can use to monitor the performance of calert.

Migrating from v1 to v2

A few notes on v2 migration:

Config schema changes

v2 is a complete rewrite from scratch and is a breaking release. The configuration has changed extensively. Please refer to latest config.sample.toml for a complete working example of the config.

Dry Run Mode

In case you're simply experimenting with calert config changes and you don't wish to send actual notifications, you can set dry_run=true in each provider.

Room Name for Google Chat

Apart from the config, calert now determines the room based on the receiver specified in Alertmanager config. Previously, the room was identified with ?room query parameter in each HTTP request. However, since the Alert payload contains the receiver name, it's better to extract this information from the labels instead.

Here's an example of how Alertmanager config looks like. Notice the value of receiver (prod_alerts) should match one of provider.<room_name> (eg provider.prod_alerts) in your config.toml):

receivers:
    - name: 'prod_alerts'
      webhook_configs:
      - url: 'http://calert:6000/dispatch'

Contribution

PRs on Feature Requests, Bug fixes are welcome. Feel free to open an issue and have a discussion first.

For deployment manifests like Helm, Kustomize, Nomad etc - they're placed under contrib folder and generally manintained by the community.

License

LICENSE

More Repositories

1

doggo

🐶 Command-line DNS Client for Humans. Written in Golang
Go
3,034
star
2

awesome-investing

💸💸 Curated list of investment & finance related resources
1,902
star
3

swiggy-analytics

Analyse your swiggy orders 🍔
Python
271
star
4

homelab

Infra-as-code for my personal home server setup
HTML
254
star
5

barreldb

A disk based KV store (based on Bitcask implementation)
Go
166
star
6

kubekutr

Cookie cutter templating tool for scaffolding K8s manifests
Go
159
star
7

gullak

A no-frills expense tracker app enabling quick logging of expenses in natural language, using LLMs for parsing and categorization.
Vue
75
star
8

monkeybeat

Generate a random stock portfolio and find out if it beats the markets!
Go
64
star
9

nomad-monitoring

Collection of jobspecs and Grafana dashboards for end to end monitoring of Nomad clusters
HCL
53
star
10

nomad-vector-logger

A daemon which continuously watches jobs running in a Nomad cluster and templates out a Vector configuration file which can be used to collect application logs enriched with Nomad metadata.
Go
53
star
11

webkin

💻 CLI tool to send webpages to kindle. 📔
Python
50
star
12

nomad-events-sink

An events collection agent which processes Nomad Events and dumps to external sink providers like HTTP
Go
49
star
13

nomctx

Faster way to switch between clusters and namespaces in nomad
Go
47
star
14

flexit

Responsive grid based on CSS Flexbox
HTML
45
star
15

notes

Collection of my byte sized notes on programming and other random topics.
Makefile
37
star
16

nomad-external-dns

Set external DNS records for Nomad services
Go
36
star
17

cloak

Securely share sensitive text with others
Go
33
star
18

store-exporter

Utility to extract metrics from arbitary data stores in Prometheus format
Go
32
star
19

clickhouse-keeper-example

Setup ClickHouse cluster with replication using `clickhouse-keeper`
Makefile
30
star
20

website

Personal site, made using Zola
HTML
30
star
21

fate

Browse FontAawesome icons from your shell
Python
29
star
22

coredns-nomad

Go
29
star
23

terraform-provider-kite

Terraform provider for managing long term portfolio with Zerodha Kite
Go
24
star
24

Insta-notFollow

A Flask web app to find out people whom you follow on Instagram but they don't follow you back 😈
HTML
22
star
25

toru

Toru is a Go module proxy with caching and rewrite capabilities
Go
22
star
26

balance

Minimal Golang library for implemeting weighted round robin load balancing.
Go
21
star
27

1brc-go

1️⃣🐝🏎️ The One Billion Row Challenge -- A fun exploration of how quickly 1B rows from a text file can be aggregated with Golang
Go
16
star
28

clx

Generate CLI commands using AI for common ops
Go
16
star
29

haraka-plugin-outbound-logger

Haraka SMTP plugin for logging outbound traffic. Useful for storing audit information of delivered/bounced emails.
JavaScript
15
star
30

nomcfg

HTML
15
star
31

kiteHistory

🤑 Kite History API wrapper
Python
14
star
32

vscode-kite

Visual Studio Code extension for KiteConnect API
JavaScript
13
star
33

kite-yoda

Ignorance is bliss.
JavaScript
12
star
34

k8s-deployment-book

⭐ Kubernetes - Production Deployments for Developers (Book) ⭐
HTML
12
star
35

nomadev

Docker based development workflow with Nomad and Consul
Dockerfile
12
star
36

simplehealth

Tiny lib for exposing health-check endpoints as Prometheus/JSON format
Go
11
star
37

localhashi

Vagrant based setup for local Nomad/Consul clusters. Helpful for experimenting with Nomad job specs in an environment similar to production.
Jinja
10
star
38

junbi

Shell
9
star
39

ebs-snapshot-exporter

Export AWS EBS Snapshots data as Prometheus metrics
Go
8
star
40

kong-service-exporter

Utility to create a export a service registry Markdown file from Kong's config
Python
8
star
41

alertmatter

Alertmanager - Mattermost Webhook Receiver
Go
7
star
42

calwarrior

Calendar web view for Takwarrior
Vue
7
star
43

NoiseInspector

📢 Arduino + Python + ESP8266 Wifi = Noise Level Monitor
Arduino
7
star
44

ansible-server-logs-monitoring

Ansible playbook to install ELK stack for log analysis and Prometheus/AlertManager/Node Exporter/Grafana for Server monitoring. Or as they say, One 💍 to rule them all!
7
star
45

eks-gitops

Set of utilities to do deployments in an EKS cluster
Dockerfile
6
star
46

caddy-plugins-docker

Docker image for Caddy with custom plugins baked into the image.
Dockerfile
5
star
47

haraka-docker

Docker image for Haraka SMTP server
Dockerfile
5
star
48

listmonk-infra

Source code for deploying listmonk on Kubernetes
Makefile
4
star
49

mfp-calorie-extract

Copy macronutrients information from MFP and paste them in Google Sheets for calorie tracking
JavaScript
4
star
50

cgroup-stats

Tiny Go library designed for retrieving CPU and Memory quota information from Linux control groups (cgroups).
Go
4
star
51

pinkFloyd-Lyrics

Analyzing Pink Floyd lyrics
HTML
4
star
52

SNUMessApp

Android App for SNU Weekly Mess Menu
Jupyter Notebook
3
star
53

notion-weightbot

A Telegram bot which tracks bodyweight and stores the records in a Notion Database and CSV
Go
3
star
54

fritter

Know if it's a good time to call your posh NRI fraands
Go
2
star
55

k8s-pruner

Cleanup unused configmaps in a Kubernetes namespace
Shell
2
star
56

talks

HTML
2
star
57

NetNeutralityBadge

Add SaveTheInternet Badge to your Facebook DP to show support for Net Neutrality
HTML
2
star
58

vscode-nomfmt

Visual Studio Code extension for on-the-fly formatting of Nomad job specs in HCL using `nomad fmt`.
TypeScript
1
star
59

Algorithm-Implementations--Python

Some Implementations of Algorithms in Python
Python
1
star
60

aws-dc-exporter

Prometheus metrics exporter for AWS Direct Connect
Go
1
star
61

kong-ansible

Ansible Playbook for setting up Kong node and using Cassandra as datastore
1
star
62

koanf-test

Go
1
star
63

rubberduck

Toolbox of useful utilities for debugging inside Containers
Go
1
star
64

Python-Scripts

Writing Python Scripts to do boring monotonous work the fun way :D
Python
1
star
65

telegramBot-YtDownload

Telegram Bot which downloads Youtube videos
Python
1
star
66

newsletter

HTML
1
star
67

weather-Twitter-Bot

Made a Weather Twitter Bot using Python
Python
1
star
68

HackerRank-Problems

My codes for some problems on HackerRank : https://www.hackerrank.com/domains/miscellaneous/python-tutorials
Python
1
star
69

khoj

CSE SNU Project Final Year
Python
1
star