monitoring - 如何使用普罗米修斯获得休息服务器的请求数?
问题描述
我有这样的获取请求:
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
我没有收到任何数据。
有人知道我错过了什么吗?
谢谢
解决方案
我猜你正在从错误的路径中抓取指标。您说的是返回您的GET
请求而不是指标信息。http://localhost:4567/hello
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
.
推荐阅读
- javascript - 为什么输出结果不一样?
- typescript - 如何使 TypeScript 缩小父对象的类型?
- c - 使用和不使用条件变量的两个线程有什么区别?
- python - 向 displot 中的所有子图添加行(Seaborn)
- sql - 如何在oracle中查找json数组中存在的行数?
- reactjs - 在 React-Flow 库中,我们可以只获取叶节点吗?
- awk - 如何使用`md5sum`处理`awk`的`$1`?
- python - Kafka 消息密钥为无
- arrays - 对线性回归建模,输入向量
- django - 我的 django 表单没有在管理面板中保存输入