Created
November 29, 2019 14:36
-
-
Save noamtamim/e66bd74eedcab550a6f345badbcb61eb to your computer and use it in GitHub Desktop.
Simple Prometheus Docker Compose setup
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '3.7' | |
volumes: | |
prometheus_data: {} | |
# Setup: | |
# The app root directory contains an "etc" subdir with the config files required by all containers. | |
# Docker Compose creates an internal network for all containers so they can call each other by name. | |
services: | |
# Prometheus runs on its default port 9090. It's configured to scrape data from http://exporter:9091 | |
# and send alerts to http://alertmanager:9093. | |
prometheus: | |
image: prom/prometheus:v2.14.0 | |
ports: | |
- "9090:9090" # Expose Prometheus port | |
volumes: | |
- ./etc:/etc/myapp | |
- prometheus_data:/prometheus | |
command: | |
- '--config.file=/etc/myapp/prometheus.yml' | |
- '--storage.tsdb.path=/prometheus' | |
depends_on: | |
# Make sure exporter and alertmanager are up before prometheus. | |
- exporter | |
- alertmanager | |
restart: always | |
# Alertmanager listens for incoming alerts on port 9093 and sends webhooks to http://sender:9094. | |
alertmanager: | |
image: prom/alertmanager:v0.19.0 | |
ports: | |
- "9093:9093" # Expose Alertmanager port | |
volumes: | |
- ./etc:/etc/myapp | |
command: | |
- '--config.file=/etc/myapp/alertmanager.yml' | |
- '--storage.path=/alertmanager' | |
depends_on: | |
- sender # Make sure the sender is up. | |
restart: always | |
# A custom Exporter. It reads data from an external source and makes it available | |
# to Prometheus on port 9091. | |
exporter: | |
# The exporter is in a subdirectory called MyExporter, complete with a Dockerfile. | |
build: MyExporter | |
ports: | |
- "9091" # No need to expose the exporter, only Prometheus needs it. | |
volumes: | |
- ./etc:/etc/myapp # Config is read from /etc/myapp/exporter.yml. | |
restart: always | |
# A custom webhook-based alert sender. Listens on port 9094. | |
sender: | |
# The exporter is in a subdirectory called Sender, complete with a Dockerfile. | |
build: Sender | |
ports: | |
- "9094" # Like exporter, it only needs to be available internally. | |
volumes: | |
- ./etc:/etc/myapp # Config is read from /etc/myapp/sender.yml. | |
restart: always | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment