首页 > 解决方案 > prometheus - 总指标计数和 prometheus_tsdb_head_series 结果不同

问题描述

count({__name__=~".+"})查询仅显示 9 但prometheus_tsdb_head_series显示 837 计数,知道为什么会有这种差异吗?两个查询不相似吗?

这是刮配置:

scrape_configs:
  # The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
  - job_name: 'prometheus-1'

    # metrics_path defaults to '/metrics'
    # scheme defaults to 'http'.

    static_configs:
    - targets: ['localhost:9090']
      labels:
        env: local
    metric_relabel_configs:
    - source_labels: [__name__]
      regex: (prometheus_tsdb_head_series)
      action: keep


  - job_name: 'node_exporter-1'
    static_configs:
    - targets: ['localhost:9100']
      labels:
        env: local
    metric_relabel_configs:
    - source_labels: [__name__]
      regex: (?i)(metric1|metric2|metric3)
      action: keep

标签: prometheus

解决方案


prometheus_tsdb_head_series涵盖过去 1-3 小时内存在的所有系列,count({__name__=~".+"})涵盖过去 5 分钟内未过时的系列。

鉴于该配置,我猜这些其他系列来自您添加metric_relabel_configs.


推荐阅读