由于 Prometheus 仅支持文本指标和许多工具返回 json 格式的指标(如 Finatra、Spring Boot),因此我创建了一个简单的代理,它将 json 转换为文本。因为我想将它用于多个源,所以要从中检索实际指标的目标是通过查询参数设置的。
指标 URL 如下所示:
/metrics?prefix=finatra&url=http://<ip>:9990/admin/metrics.json
这在浏览器或curl 中工作得很好。
然而,在《普罗米修斯》中,“?”被编码为“%3F”,因此请求失败:
/metrics%3Fprefix=finatra&url=http://<ip>:9990/admin/metrics.json
How can I prevent Prometheus from encoding the ??
Is this a bug in Prometheus?
I already tried escaping with %
or \
, using unicode etc, but still no luck.
此行为是正确的,因为指标路径是一条路径,而不是协议、主机和端口上的任意后缀。
您正在寻找params https://prometheus.io/docs/prometheus/latest/configuration/configuration/#%3Cscrape_config%3E配置选项:
scrape_configs:
- job_name: 'somename'
params:
prefix: ['finatra']
url: ['http://:9090/admin/metrics.json']
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)