Prometheus Alertmanager receiver that sends messages via Firebase Cloud Messaging
Configure the /alert/<topic>
API endpoint in alertmanager.yml
.
You may configure this webhook in multiple receivers push messages to different Firebase Cloud Messaging topics:
receivers:
- name: 'webhook.all'
webhook_configs:
- url: 'http://alertmanager-webhook-fcm:9716/alert/all'
- name: 'webhook.important'
webhook_configs:
- url: 'http://alertmanager-webhook-fcm:9716/alert/important'
There is a generic API endpoint that can be used to send simple notifications. It accepts a less comlex JSON format then alertmanager uses:
curl --header "Content-Type: application/json" \
--request POST \
--data '{"title":"The message title", "body":"The message body"}' \
http://localhost:9716/generic/your-topic
This webhook needs cloudmessaging.messages.create
permission for your Firebase project.
You may want to create a custom IAM role with only this permission and assign a new service account to it. Download the service account JSON file and set the environment variable GOOGLE_APPLICATION_CREDENTIALS
to its absolute path.
The container will need access to some root CA to verify Google's SSL certificates. You may want to mount your host certificates, llike:
version: "2"
services:
alertmanager-webhook-fcm:
container_name: alertmanager-webhook-fcm
image: jaymedh/alertmanager-webhook-fcm:v0.2
ports:
- 9716:9716
environment:
- GOOGLE_APPLICATION_CREDENTIALS=/etc/serviceAccountKey.json
volumes:
- /etc/ssl/certs:/etc/ssl/certs:ro
- /serviceAccountKey.json:/etc/serviceAccountKey.json:ro
restart: unless-stopped