普罗米修斯刮擦/公制,带自定义标题 [英] Prometheus scrape /metric with custom header

查看:8
本文介绍了普罗米修斯刮擦/公制,带自定义标题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序将由普罗米修斯监控, 但应用程序需要如下所示的自定义标头键:

x-auth-token: <customrandomtoken>

我应该如何处理prometheus.yml?

推荐答案

普罗米修斯本身无法定义自定义标头以到达导出器。this GitHub issue中讨论了添加该功能的想法。Tl;dr:如果您需要自定义标头,请使用转发代理或反向代理将其注入。

prometheus-blackbox-exporter标记表明问题与生成探测的导出器有关,这是另一回事,它确实有一种方法来设置标头。只是,它不是擦除指标,而是使它们

Blackbox Exporter有自己的配置文件,它由模块组成。模块是一组参数,定义如何执行探测以及预期的结果。以下是查找200-299响应代码并使用X-Auth-Token头:

的模块的示例
modules:
  http_2xx_with_header:
    prober: http
    http:
      headers:
        X-Auth-Token: skdjfh98732hjf22exampletoken

更多示例here和配置选项列表-here

当您使黑盒导出器加载新配置时,您还需要调整普罗米修斯配置:

scrape_configs:
  - job_name: 'blackbox'
    metrics_path: /probe
    params:
      module: [http_2xx_with_header]  # <- Here goes the name of the new module
    static_configs:
      - targets:
        - http://prometheus.io
    relabel_configs:
      - source_labels: [__address__]
        target_label: __param_target
      - source_labels: [__param_target]
        target_label: instance
      - target_label: __address__
        replacement: 127.0.0.1:9115

这篇关于普罗米修斯刮擦/公制,带自定义标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆