【问题标题】:Prometheus scrape from Windows - invalid metric name/"INVALID" is not a valid start tokenPrometheus 从 Windows 抓取 - 无效的指标名称/“INVALID”不是有效的开始令牌
【发布时间】:2021-06-08 17:52:23
【问题描述】:

我已经在我的 linux 节点上安装了 prometheus。我在 Windows 服务器上有一个从应用程序导出指标的 go 应用程序。 Windows 节点的指标路径位于 /app/metrics。注意,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,

【问题讨论】:

    标签: windows go prometheus


    【解决方案1】:

    应用的指标不在 Prometheus 基于 YAML 的 Exposition format

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

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

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

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

    【讨论】:

    • 谢谢,这有助于引导我走向正确的方向。该应用程序是用 Go 编写的。它在 Windows 服务器上,但我们不想启用 WMI 来导出指标。因此,我们依靠应用程序来输出指标。我可能需要创建一个转换导出器或查看是否有配置我的 Go 应用程序的方法。
    • 如果您可以更改应用程序,有一个用于 Prometheus 的 Golang library 可以帮助检测应用程序本身以导出 Prometheus 指标。或者,您可以使用 Golang 库(或任何其他库或根本没有库*)编写一个简单的 HTTP 服务器来抓取应用程序的现有指标。 *- 因为 exposition 格式非常简单,你甚至不需要使用 Prometheus 客户端库,只需要服务 HTTP 并可以输出 content-type: text/plain 的东西。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-08-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-03-19
    • 1970-01-01
    相关资源
    最近更新 更多