3

我正在尝试在 Spring Boot 应用程序上设置 Prometheus 监控但出现错误:Get https://example.com:8080/actuator/prometheus: EOF

我的设置

application.yml

management:
  endpoints:
    web:
      exposure:
        include: "*"
  endpoint:
    metrics:
      enabled: true
    prometheus:
      enabled: true
  metrics:
    export:
      prometheus:
        enabled: true

Prometheus config

global:
  scrape_interval:     5s # Set the scrape interval to every 5 seconds.
  evaluation_interval: 5s # Evaluate rules every 5 seconds.

scrape_configs:
  - job_name: 'app'
    metrics_path: '/actuator/prometheus'
    scheme: https
    static_configs: 
      - targets: ['example.com:8080']

现在,当浏览到 时actuator/prometheus,我可以看到数据:

# HELP hikaricp_connections_usage_seconds Connection usage time
# TYPE hikaricp_connections_usage_seconds summary ....
....

但是在 Prometheous 目标屏幕上,我可以看到正确的 Url,但有指定的错误。

我正在使用 Docker 运行 Prometheus。

level=info ts=2018-08-14T19:10:59.6844594Z caller=main.go:603 msg="Loading   configuration file" filename=/etc/prometheus/prometheus.yml
level=info ts=2018-08-14T19:10:59.686749Z caller=main.go:629 msg="Completed loading of configuration file" filename=/etc/prometheus/prometheus.yml
level=info ts=2018-08-14T19:10:59.6867898Z caller=main.go:502 msg="Server is ready to receive web requests."
4

2 回答 2

0

Prometheus 目标屏幕显示 EOF 错误表明 prometheus.yml 文件有问题

更改 prometheus 配置文件中的抓取配置

- job_name: 'person-app' metrics_path: '/actuator/prometheus' static_configs: - targets: ['example.com:8080']

目标应包括您的主机名,而不是网址。修改配置文件后重启prometheus

对于更新的 yml 文件

scheme 标签应该在 static_configs 之上。正确的声明应该是

job_name: 'person-app' metrics_path: '/actuator/prometheus' scheme: 'https' static_configs: - targets: ['example.com:8080']

于 2018-08-13T21:35:22.930 回答
0

我创建了一个示例来重现您的问题,但失败了。请注意,示例在 上,而so-51765772不是我更改从您的 Prometheus 配置中轻松重现,如下所示:masterschemetarget

global:
  scrape_interval:     5s # Set the scrape interval to every 5 seconds.
  evaluation_interval: 5s # Evaluate rules every 5 seconds.

scrape_configs:
  - job_name: 'app'
    metrics_path: '/actuator/prometheus'
    scheme: http
    static_configs: 
      - targets: ['localhost:8080']

我想问题可能出在其他地方。因此,如果您可以使此示例以您所看到的方式失败,我可以再看一下。

于 2018-08-24T15:48:40.950 回答