英文:
Prometheus scrape from Windows - invalid metric name/"INVALID" is not a valid start token
问题
我已经在我的Linux节点上安装了Prometheus。我有一个在Windows服务器上的Go应用程序,从该应用程序导出指标。Windows节点的指标路径位于/app/metrics。请注意,指标的输出格式为JSON。
这是我的prometheus.yml配置文件:
scrape_configs:
- job_name: 'prometheus_metrics'
static_configs:
- targets: ['localhost:9090']
- job_name: 'node_exporter_metrics'
static_configs:
- targets: ['localhost:9100']
- job_name: 'app-qa-1'
metrics_path: /app/metrics
scheme: http
static_configs:
- targets: ['app-qa-1:1701']
当我查询指标并通过promtool时,我得到以下错误:
error while linting: text format parsing error in line 1: invalid metric name
在我的目标页面上,Windows节点出现以下错误:
"INVALID" is not a valid start token
这是我的Windows节点的指标示例:
"api.engine.gateway.50-percentile": 0,
"api.engine.gateway.75-percentile": 0,
"api.engine.gateway.95-percentile": 0,
"api.engine.gateway.99-percentile": 0,
"api.engine.gateway.999-percentile": 0,
"api.engine.gateway.count": 0,
"api.engine.gateway.fifteen-minute": 0,
"api.engine.gateway.five-minute": 0,
英文:
I've installed prometheus on my linux node. I have a go application on a Windows server that exports metrics from the app. The metric path for the Windows node is at /app/metrics. Note, the output of the metrics is in json format.
Here is my prometheus.yml:
scrape_configs:
- job_name: 'prometheus_metrics'
static_configs:
- targets: ['localhost:9090']
- job_name: 'node_exporter_metrics'
static_configs:
- targets: ['localhost:9100']
- job_name: 'app-qa-1'
metrics_path: /app/metrics
scheme: http
static_configs:
- targets: ['app-qa-1:1701']
When I query the metrics and pass through the promtool I get:
error while linting: text format parsing error in line 1: invalid metric name
On my targets page I have this error for the Windows node:
"INVALID" is not a valid start token
And this is what the metrics from my Windows node look like:
"api.engine.gateway.50-percentile": 0,
"api.engine.gateway.75-percentile": 0,
"api.engine.gateway.95-percentile": 0,
"api.engine.gateway.99-percentile": 0,
"api.engine.gateway.999-percentile": 0,
"api.engine.gateway.count": 0,
"api.engine.gateway.fifteen-minute": 0,
"api.engine.gateway.five-minute": 0,
答案1
得分: 1
该应用的指标不符合Prometheus的基于YAML的Exposition格式。
你最好确定该应用是否可以配置为导出Prometheus指标。
如果不能,你需要要么使用一个代理程序,位于Prometheus服务器和应用程序之间,当Prometheus进行抓取时,调用应用程序的指标端点并将结果转换为Exposition格式。
据我所知,目前没有通用的转换导出程序可供使用。但这将非常有用。你可以配置它的端点和转换函数,它会为你完成工作。
或者,你需要为该应用程序编写自己的导出程序。但是,如果当前的指标列表已经满足你的需求,那可能需要付出太多的努力。
英文:
The app's metrics aren't in Prometheus' YAML-based Exposition format.
Your best bet is to determine whether the app can be configured to export Prometheus metrics (too).
If not, you're going to need either a proxy that sits between your Prometheus server and the app that, when scraped by Prometheus, calls the app's metrics' endpoint and transforms the results into Exposition format.
To my knowledge, there isn't a general-purpose transforming exporter that you can use. But this would be useful. You'd configure it with your endpoints and a transform function and it would do the work for you.
Or, you will need to write your own exporter for the app. But, if the current metric list is sufficient for your needs, that may be too much effort.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论