这是我的 docker compose 文件的一部分:
prometheus:
image: prom/prometheus:latest
container_name: prometheus
volumes:
- ./data/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml
- ./data/alerting/alertmanager_rules.yml:/etc/prometheus/alertmanager_rules.yml
ports:
- 9090:9090
depends_on:
- alertmanager
networks:
- monitor-net
这是 prometheus.yml
global:
scrape_interval: 1m
evaluation_interval: 1m
alerting:
alertmanagers:
- static_configs:
- targets: ['alertmanager:9093']
# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
- "alertmanager_rules.yml"
scrape_configs:
- job_name: 'dev_server_prometheus'
scrape_interval: 30s
scrape_timeout: 10s
static_configs:
- targets: ['prometheus:9090']
- job_name: 'node_exporter'
scrape_interval: 30s
scrape_timeout: 10s
static_configs:
- targets: ['x.x.x.x:9100']
labels:
instance: "production"
我在远程主机中打开了 9100 端口,但如果我删除了远程主机中的 9100 端口,prometheus 仍然显示主机已启动(我等了几个小时)并且显示错误的指标可能是缓存中的 collectig。 但奇怪的是,如果我重新启动 docker compose prometheus 可以检测到主机已关闭并且 alertmanager 也会发送通知。
有人能告诉我发生了什么事以及这个问题的解决方法吗?
我正在使用 Ubuntu:20.04 & docker 版本:23.0.1 & Docker Compose 版本:v2.16.0
观察:
我在 aws 中运行节点。所以如果我继续 端口打开但停止节点导出器服务,普罗米修斯是 正确响应并提醒工作。
虽然问题暂时解决了,但我仍然很想知道为什么会这样,我对网络不太了解。