首页 > 解决方案 > 普罗米修斯中的刮擦间隔和评估间隔

问题描述

我的刮擦间隔和评估间隔彼此相差很远,如下所示(15s vs 4m)。当我向端点提供指标时,我发现规则每 4m 进行一次评估,这是预期的。但是,我不明白的是,它不会评估过去 4 分钟提供的所有指标的规则。我很难理解两个时钟(刮擦和评估)的功能。此外,这方面的文档非常稀少。任何指针都会有很大帮助。我毫不犹豫地将刮擦时间和评估时间更改为各 15 秒。但我需要了解将时钟分开的后果。

# my global config
global:
  scrape_interval:     15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
  evaluation_interval: 4m # Evaluate rules every 15 seconds. The default is every 1 minute.
  # scrape_timeout is set to the global default (10s).

# Alertmanager configuration
alerting:
  alertmanagers:
  - static_configs:
    - targets:
       - testmanager:9093

# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
   - "/etc/prometheus/xyz_rule.yml"
   - "/etc/prometheus/pqr_rule.yml"

# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
scrape_configs:
  # The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
  - job_name: 'prometheus'

    # metrics_path defaults to '/metrics'
    metrics_path: /v1/metrics/xyz
    # scheme defaults to 'http'.

    static_configs:
    - targets: ['test:7070']

标签: prometheusprometheus-alertmanager

解决方案


这两个进程是独立的,PromQL 和记录规则都不知道你的抓取间隔是多少。因此,无论评估间隔是多少,在给定时间评估时,您指定的任何规则都将以相同的方式评估并获得相同的结果。

为简单起见,最好让两个间隔相同,所以我建议在这里都设置为 15s。


推荐阅读