登录
首页 >  Golang >  Go问答

Prometheus 从 Windows 中抓取 - 无效的指标名称/“INVALID”不是有效的启动令牌

来源:stackoverflow

时间:2024-04-06 23:27:34 172浏览 收藏

亲爱的编程学习爱好者,如果你点开了这篇文章,说明你对《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,

正确答案


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

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

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

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

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

理论要掌握,实操不能落!以上关于《Prometheus 从 Windows 中抓取 - 无效的指标名称/“INVALID”不是有效的启动令牌》的详细介绍,大家都掌握了吧!如果想要继续提升自己的能力,那么就来关注golang学习网公众号吧!

声明:本文转载于:stackoverflow 如有侵犯,请联系study_golang@163.com删除
相关阅读
更多>
最新阅读
更多>
课程推荐
更多>