Reputation: 577
I have a docker-compose file with one django app, Prometheus monitoring container and Alertmanager container.
All builds fine, app is running, Prometheus is monitoring but when it is to fire an alert, the alert does not reach the Alertmanager container with the following error message:
prometheus_1 | level=error ts=2021-08-02T08:58:16.018Z caller=notifier.go:527 component=notifier alertmanager=http://0.0.0.0:9093/api/v2/alerts count=1 msg="Error sending alert" err="Post \"http://0.0.0.0:9093/api/v2/alerts\": dial tc
p 0.0.0.0:9093: connect: connection refused"
Alertmanager also refuses telnet test connection like so
klex@DESKTOP-PVC5EP:~$ telnet 0.0.0.0 9093
Trying 0.0.0.0...
Connected to 0.0.0.0.
Escape character is '^]'.
Connection closed by foreign host.
the docker-compose file is:
version: "3"
services:
web:
container_name: smsgate
build: .
command: sh -c "python manage.py migrate &&
python manage.py collectstatic --no-input &&
python manage.py runserver 0.0.0.0:15001"
volumes:
- .:/smsgate:rw
- static_volume:/home/app/smsgate/static
- /var/run/docker.sock:/var/run/docker.sock
ports:
- "15001:15001"
env_file:
- .env.prod
image: smsgate
restart: "always"
networks:
- promnet
prometheus:
image: prom/prometheus
volumes:
- ./prometheus/:/etc/prometheus/
depends_on:
- alertmanager
ports:
- "9090:9090"
networks:
- promnet
alertmanager:
image: prom/alertmanager
ports:
- "9093:9093"
volumes:
- ./alertmanager/:/etc/alertmanager/
restart: "always"
command:
- '--config.file=/etc/alertmanager/alertmanager.yml'
networks:
- promnet
volumes:
static_volume:
alertmanager_volume:
prometheus_volume:
networks:
promnet:
driver: bridge
And prometheus.yml configuration file is
global:
scrape_interval: 15s
evaluation_interval: 15s
alerting:
alertmanagers:
- static_configs:
- targets:
- "0.0.0.0:9093"
rule_files:
- alert.rules.yml
scrape_configs:
- job_name: monitoring
metrics_path: /metrics
static_configs:
- targets:
- smsgate:15001
There is very likely a network? configuration problem either as the service seems not to accept any connections.
Prometheus and Alertmanager GUI interfaces can be accessed via browser on
http://127.0.0.1:9090/
and
http://127.0.0.1:9093/
respectively
Any help would be much appreciated.
Upvotes: 2
Views: 2073
Reputation: 7705
Try to use the service name instead of the 0.0.0.0
. Change the last line in the configuration of alerting block as:
alerting:
alertmanagers:
- static_configs:
- targets:
- "alertmanager:9093"
given that they are on the same net, it should work just fin
I misunderstood the problem in the first place. Apologies. Please check the updated block above ☝🏽
Upvotes: 2