目标节点重启时未显示普罗米修斯过去的指标
prometheus past metrics not shown on target node restart
我是 Prometheus 的新手,需要帮助来理解为什么在目标节点重新启动时不显示过去的指标数据。
我已经设置了一个 Golang 网络服务器(目标)。此服务器使用 Go Prometheus Docs Golang Prometheus 客户端准备指标并在端口 3000 上公开指标。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 link)。
image 1
但是在网络服务器重新启动时,之前记录的指标不会显示在 Prometheus 上(点击图片 2 link)。
image 2
我不清楚为什么之前从网络服务器(目标)抓取的指标在目标节点重新启动时没有显示在上方。我可以在图形视图中看到以前抓取的指标(参见图 3 link)。但不在 table 视图中。
image 3
您似乎将主机名作为指标名称的一部分。这会为每个容器生成新的指标。 table 视图仅显示每个目标的最新抓取中包含的指标。
要解决此问题,请从指标名称中删除主机名部分,这样名称就不会在两次重启之间发生变化。如果这确实是有用的信息,请将它们添加为标签,尽管 that is almost certainly a bad idea.
我是 Prometheus 的新手,需要帮助来理解为什么在目标节点重新启动时不显示过去的指标数据。
我已经设置了一个 Golang 网络服务器(目标)。此服务器使用 Go Prometheus Docs Golang Prometheus 客户端准备指标并在端口 3000 上公开指标。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 link)。
image 1
但是在网络服务器重新启动时,之前记录的指标不会显示在 Prometheus 上(点击图片 2 link)。
image 2
我不清楚为什么之前从网络服务器(目标)抓取的指标在目标节点重新启动时没有显示在上方。我可以在图形视图中看到以前抓取的指标(参见图 3 link)。但不在 table 视图中。
image 3
您似乎将主机名作为指标名称的一部分。这会为每个容器生成新的指标。 table 视图仅显示每个目标的最新抓取中包含的指标。
要解决此问题,请从指标名称中删除主机名部分,这样名称就不会在两次重启之间发生变化。如果这确实是有用的信息,请将它们添加为标签,尽管 that is almost certainly a bad idea.