I found several examples of prometheus and grafana within docker containers. However, I could not find one example where Prometheus Service Discovery via Consul worked completely within Docker containers including Alert Manager. Had to put this together to ensure it helped someone who needed it.
A simple docker-compose configuration that allows the following services to run as docker containers
- prometheus
- grafana
- cadvisor
- consul
- node-exporter
- alert-manager sending alerts to slack
All the configuration items are there. Alert Manager rules can be extended and when new serivces are registered with Consul, Prometheus auto discovers the services.
- Edit the file data/alertmanager.yml
- Replace the placeholder <<API_URL>> with your Slack webhook URL
api_url: <<API_URL>> ##webhook url
- Replace the placeholder <> with your Slack channel. Leave the # Symbol in
channel: "#<<CHANNEL>>"
- Run the following from the root folder
docker-compose up -d
- Run the following from the root folder
docker-compose down --remove-orphans
- Prometheus available at http://localhost:9090
- Consul available at http://localhost:8500
- Alert Manager available at http://localhost:9093
- Node Exporter available at http://localhost:9100
- cadvisor available at http://localhost:8080
- Grafana available at http://localhost:3000
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.