【问题标题】:Is there an option in Prometheus to disable scraping a specific endpoint?Prometheus 中是否有禁用抓取特定端点的选项?
【发布时间】:2022-01-15 02:48:15
【问题描述】:

为了最大程度地减少 Prometheus Federation 的负载,我正在尝试禁用对特定指标的抓取。如果我们有这样的选择或任何其他选择,请告诉我。

【问题讨论】:

  • 请编辑问题以将其限制为具有足够详细信息的特定问题,以确定适当的答案。

标签: prometheus screen-scraping disable


【解决方案1】:

这在documentation中有解释:

必须至少指定一个match[] URL 参数才能选择要公开的系列。每个match[] 参数都需要指定一个即时向量选择器,例如up{job="api-server"}。如果提供了多个match[]参数,则选择所有匹配系列的并集。

换句话说,通过使用match[],您可以明确说明您想要联合哪些指标。

scrape_configs:
  - job_name: 'federate'
    scrape_interval: 15s

    honor_labels: true
    metrics_path: '/federate'

    params:
      'match[]':
        # all metrics with label job == "prometheus"
        - '{job="prometheus"}'
        # plus all metrics with label foo == "bar" where instance != "example.com"
        - '{foo="bar", instance!="example.com"}'         
        # and so on

    static_configs:
      - targets:
        - 'source-prometheus-1:9090'
        - 'source-prometheus-2:9090'
        - 'source-prometheus-3:9090'

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-11-12
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多