首页 > 解决方案 > 如何使用普罗米修斯获得休息服务器的请求数?

问题描述

我有这样的获取请求:

http://localhost:4567/hello

哪个邮递员返回:“你好”

我现在想在普罗米修斯收到这个:

  - job_name: 'prometheus'

    scrape_interval: 5s
    metrics_path: /hello
    static_configs:
      - targets: ['localhost:4567']

但我在普罗米修斯控制台收到:

level=warn ts=2019-08-06T08:25:36.643Z caller=scrape.go:937 component="scrape manager" scrape_pool=prometheus target= http://localhost:4567/hello msg="append failed" err= "\"INVALID\" 不是有效的开始令牌"

如果我在普罗米修斯中测试一个图表:

prometheus_http_requests_total

我没有收到任何数据。

有人知道我错过了什么吗?

谢谢

标签: monitoringprometheus

解决方案


我猜你正在从错误的路径中抓取指标。您说的是返回您的GET请求而不是指标信息。http://localhost:4567/hellohello

预期的指标信息格式如下:

$ curl http://localhost:8080/metrics
# HELP http_requests_total Count of all http requests
# TYPE http_requests_total counter
http_requests_total{code="0",method="GET"} 1
http_requests_total{code="0",method="Post"} 1
# HELP version Version information about this binary
# TYPE version gauge
version{version="v0.0.1"} 0

确保哪个端点公开了您的指标信息。然后更新scrape_config.


推荐阅读