You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何通过OpenTelemetry Collector按标签组合过滤指定Prometheus指标

正确的OpenTelemetry Collector排除配置方案

你的问题核心是exclude处理器的配置结构错误,缺少metrics:层级导致逻辑异常,误删了所有同名指标。同时建议完善匹配规则,同时指定group和name标签,确保只删除目标时间序列。

正确的处理器配置

processors:
  exclude:
    metrics:
      match_type: expr
      expressions:
        - metric.name == "node_supervisord_up" && attributes["group"] == "ServiceD" && attributes["name"] == "serviceD"

关键说明

  1. 必须嵌套metrics:节点:针对指标的过滤规则必须放在metrics子节点下,否则配置不生效,会触发意外的全量过滤行为。
  2. 精准匹配标签组合:同时指定group和name标签的条件,避免误删其他同名但标签不同的指标实例。
  3. 适配新版本语法:使用metric.name指代指标名称,attributes["标签名"]获取标签值,这是当前主流OTel Collector版本(v0.70+)的标准语法。

完整服务配置示例(需确保处理器加入数据流水线)

receivers:
  prometheus:
    config:
      scrape_configs:
        - job_name: "otel-collector"
          scrape_interval: 30s
          static_configs:
            - targets: ["localhost:9001"]

processors:
  exclude:
    metrics:
      match_type: expr
      expressions:
        - metric.name == "node_supervisord_up" && attributes["group"] == "ServiceD" && attributes["name"] == "serviceD"

exporters:
  # 替换为你的中央聚合器导出配置
  prometheusremotewrite:
    endpoint: "your-central-aggregator:9090/api/v1/write"

service:
  pipelines:
    metrics:
      receivers: [prometheus]
      processors: [exclude]
      exporters: [prometheusremotewrite]

内容的提问来源于stack exchange,提问作者Ruchir Bharadwaj

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.23 00:15:59