繁体   English   中英

如何获得使用Prometheus搁置服务器的请求数?

[英]How can I get the number of requests to rest server with prometheus?

我有这样的获取请求:

http://localhost:4567/hello

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

我现在想以普罗米修斯收到此信息:

  - job_name: 'prometheus'

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

但是我在prometheus控制台中收到:

级别=警告ts = 2019-08-06T08:25:36.643Z呼叫者= scrape.go:937组件=“抓取管理器” scrape_pool = prometheus目标= http:// localhost:4567 /你好 msg =“追加失败” err = “ \\“ INVALID \\”不是有效的开始令牌”

如果我在普罗米修斯中测试以下图形:

prometheus_http_requests_total

我没有收到任何数据。

有人知道我在想什么吗?

谢谢

我想您是从错误的路径抓取指标。 您说http://localhost:4567/hello上的GET请求返回的是hello而不是指标信息。

预期指标信息格式如下:

$ 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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM