【发布时间】:2021-11-12 08:11:47
【问题描述】:
我是 Prometheus 的新手,需要帮助了解为什么在目标节点重新启动时不显示过去的指标数据。
我已经设置了一个 Golang 网络服务器(目标)。此服务器使用Go Prometheus Docs Golang Prometheus 客户端准备指标并在端口 3000 上公开指标。Prometheus 从该目标中抓取数据。
Prometheus 配置文件:
global: scrape_interval: 10s scrape_timeout: 10s
scrape_configs:
- job_name: 'webServer1'
static_configs:
- targets: ['webServer1:8080']
我还在 docker-compose 中设置了保留标志
prometheus:
image: prom/prometheus
volumes:
- ./prometheus/prometheus.yml:/etc/prometheus/prometheus.yml
ports:
- "127.0.0.1:9090:9090"
command:
- '--config.file=/etc/prometheus/prometheus.yml'
- '--storage.tsdb.path=/prometheus'
- '--web.console.libraries=/etc/prometheus/console_libraries'
- '--web.console.templates=/etc/prometheus/consoles'
- '--storage.tsdb.retention.time=200h'
- '--web.enable-lifecycle'
我已经检测了一个 Web 服务器(目标)来计算向 /bar 端点发出的 HTTP 请求的数量。我可以在 Prometheus 上看到正确的请求计数(点击图片 1 链接)。
但是在网络服务器重启时,之前记录的指标不会显示在 Prometheus 上(点击图片 2 链接)。
我不清楚为什么之前从网络服务器(目标)抓取的指标在目标节点重新启动时没有显示在上面。我可以在图表视图中看到以前抓取的指标(参见图 3 链接)。但不在表格视图中。
【问题讨论】:
标签: go prometheus monitoring