VictoriaMetrics(VM 代理)可靠指标模式

问题描述 投票:0回答:1

我的 vmagent 中有此配置:

global:
  scrape_interval: 60s
  scrape_timeout: 60s
  external_labels:
    server_name: vmagent

scrape_configs:
  - job_name: "kafka_exporter"
    file_sd_configs:
    - files:
      - kafka_exporter.yml
    metric_relabel_configs:
      - if: '{__name__="kafka_consumergroup_lag_sum"}'
        target_label: foo
        replacement: 3

我正在尝试仅向一个指标添加标签。就在那里:

kafka_consumergroup_lag_sum{consumergroup="test",topic="elk"} 0

但是,如果我在我的 VictoriaMetrics(远程写入 vmagent)中搜索指标,则它没有带有此标签的指标。他们在这里:

sum by(__name__)({__name__=~".+",foo="3"}):

kafka_consumergroup_lag_sum{}
kafka_consumergroup_members{}
kafka_exporter_build_info{}
kafka_topic_partition_current_offset{}
kafka_topic_partition_in_sync_replica{}
kafka_topic_partition_leader{}
kafka_topic_partition_leader_is_preferred{}
kafka_topic_partition_oldest_offset{}
kafka_topic_partition_replicas{}
kafka_topic_partition_under_replicated_partition{}
kafka_topic_partitions{}
process_cpu_seconds_total{}
process_max_fds{}
process_open_fds{}
process_resident_memory_bytes{}
process_start_time_seconds{}
process_virtual_memory_bytes{}
process_virtual_memory_max_bytes{}
promhttp_metric_handler_requests_in_flight{}
promhttp_metric_handler_requests_total{}

我做错了什么?为什么其他指标具有相同的标签?

如果我尝试对另一个指标(kafka_topic_partitions)执行相同的操作,则不存在此类问题。配置完全一样:

      - if: '{__name__="kafka_topic_partitions"}'
        target_label: foo
        replacement: 3
prometheus monitoring promql victoriametrics metricsql
1个回答
0
投票

您的配置看起来正确并且应该可以工作,除非您的实际配置中有拼写错误。如果你愿意的话,你可能想这样做(这更优雅,但与你所做的相同)

    metric_relabel_configs:
    - if: 'kafka_consumergroup_lag_sum'
      target_label: foo
      replacement: 3
© www.soinside.com 2019 - 2024. All rights reserved.