首页 > 解决方案 > Prometheus 从 Windows 抓取 - 无效的指标名称/“INVALID”不是有效的开始令牌

问题描述

我已经在我的 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,

标签: windowsgoprometheus

解决方案


该应用程序的指标不是 Prometheus 的基于 YAML 的Exposition 格式

最好的办法是确定应用程序是否可以配置为(也)导出 Prometheus 指标。

如果没有,您将需要位于Prometheus 服务器和应用程序之间的代理,当 Prometheus 抓取该代理时,该代理会调用应用程序的指标端点并将结果转换为 Exposition 格式。

据我所知,没有可以使用的通用转换导出器。但这会很有用。您将使用端点和转换功能对其进行配置,它会为您完成工作。

或者,您需要为应用程序编写自己的导出器。但是,如果当前的指标列表足以满足您的需求,那可能需要付出太多努力。


推荐阅读