promtotwilio

command module
v1.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 5, 2019 License: MIT Imports: 9 Imported by: 0

README

Prometheus alert with text message

This is a simple and stupid program that will receive webhooks from Prometheus to send them as text message (using Twilio) with the summary of the alert.

The Docker image size is less than 9MB.

Docker Pulls

Configuration

It needs 4 environment variables:

  • SID - Twilio Account SID
  • TOKEN - Twilio Auth Token
  • RECEIVER - Phone number of receiver (optional parameter, representing default receiver)
  • SENDER - Phone number managed by Twilio (friendly name)

You can see a basic launch inside the Makefile.

API

/: ping promtotwilio application. Returns 200 OK if application works fine.

/send?receiver=<rcv>: send Prometheus firing alerts from payload to a rcv if specified, or to default receiver, represented by RECEIVER environment variable. If none is specified, status code 400 BadRequest is returned.

Test it

To send test sms to a phone +zxxxyyyyyyy use the following command (please notice %2B symbols, representing a url encoded + sign)

$ curl -H "Content-Type: application/json" -X POST -d \
'{"version":"2","status":"firing","alerts":[{"annotations":{"summary":"Server down"},"startsAt":"2016-03-19T05:54:01Z"}]}' \
http://localhost:9090/send?receiver=%2Bzxxxyyyyyyy

Configuration example

Here's a sample Docker Compose file to use it with cAdvisor, Prometheus, Alertmanager and Grafana.

sms:
  image: swatto/promtotwilio:latest
  environment:
    SID: xxx
    TOKEN: xxx
    RECEIVER: xxx
    SENDER: xxx

alert:
  image: prom/alertmanager:latest
  links:
   - sms
  volumes:
   - ./alertmanager.yml:/etc/alertmanager/config.yml

container:
  image: google/cadvisor:latest
  volumes:
   - /:/rootfs:ro
   - /var/run:/var/run:rw
   - /sys:/sys:ro
   - /var/lib/docker/:/var/lib/docker:ro

prometheus:
  image: prom/prometheus:latest
  links:
   - container
   - alert
  volumes:
   - ./prometheus.yml:/etc/prometheus/prometheus.yml
   - ./alerts.conf:/etc/prometheus/alerts.conf
  entrypoint: /bin/prometheus -config.file=/etc/prometheus/prometheus.yml -alertmanager.url=http://alert:9093

web:
  image: grafana/grafana:latest
  links:
   - prometheus
  ports:
   - "3000:3000"
  environment:
    GF_SERVER_ROOT_URL: http://stats.example.com
    GF_SECURITY_ADMIN_PASSWORD: 123456

Here's the AlertManager config where sms will be provided by Docker Compose

route:
  receiver: 'admin'

receivers:
- name: 'admin'
  webhook_configs:
  - url: 'http://sms:9090/send'

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL