Prometheus从Windows抓取-无效的指标名称/”INVALID”不是有效的起始标记。

huangapple go评论124阅读模式
英文:

Prometheus scrape from Windows - invalid metric name/"INVALID" is not a valid start token

问题

我已经在我的Linux节点上安装了Prometheus。我有一个在Windows服务器上的Go应用程序,从该应用程序导出指标。Windows节点的指标路径位于/app/metrics。请注意,指标的输出格式为JSON。

这是我的prometheus.yml配置文件:

  1. scrape_configs:
  2. - job_name: 'prometheus_metrics'
  3. static_configs:
  4. - targets: ['localhost:9090']
  5. - job_name: 'node_exporter_metrics'
  6. static_configs:
  7. - targets: ['localhost:9100']
  8. - job_name: 'app-qa-1'
  9. metrics_path: /app/metrics
  10. scheme: http
  11. static_configs:
  12. - targets: ['app-qa-1:1701']

当我查询指标并通过promtool时,我得到以下错误:

  1. error while linting: text format parsing error in line 1: invalid metric name

在我的目标页面上,Windows节点出现以下错误:

  1. "INVALID" is not a valid start token

这是我的Windows节点的指标示例:

  1. "api.engine.gateway.50-percentile": 0,
  2. "api.engine.gateway.75-percentile": 0,
  3. "api.engine.gateway.95-percentile": 0,
  4. "api.engine.gateway.99-percentile": 0,
  5. "api.engine.gateway.999-percentile": 0,
  6. "api.engine.gateway.count": 0,
  7. "api.engine.gateway.fifteen-minute": 0,
  8. "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:

  1. scrape_configs:
  2. - job_name: 'prometheus_metrics'
  3. static_configs:
  4. - targets: ['localhost:9090']
  5. - job_name: 'node_exporter_metrics'
  6. static_configs:
  7. - targets: ['localhost:9100']
  8. - job_name: 'app-qa-1'
  9. metrics_path: /app/metrics
  10. scheme: http
  11. static_configs:
  12. - targets: ['app-qa-1:1701']

When I query the metrics and pass through the promtool I get:

  1. 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:

  1. "INVALID" is not a valid start token

And this is what the metrics from my Windows node look like:

  1. "api.engine.gateway.50-percentile": 0,
  2. "api.engine.gateway.75-percentile": 0,
  3. "api.engine.gateway.95-percentile": 0,
  4. "api.engine.gateway.99-percentile": 0,
  5. "api.engine.gateway.999-percentile": 0,
  6. "api.engine.gateway.count": 0,
  7. "api.engine.gateway.fifteen-minute": 0,
  8. "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.

huangapple
  • 本文由 发表于 2021年6月9日 01:52:23
  • 转载请务必保留本文链接:https://go.coder-hub.com/67892204.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定