The*_*ode 17 prometheus prometheus-alertmanager
我的抓取间隔和评估间隔相差很远,如下所示(15 秒与 4 米)。当我向端点提供指标时,我发现规则每 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']
Run Code Online (Sandbox Code Playgroud)
刮削间隔:It defines the interval based on which prometheus scrapes a monitored target. It is defined globally but can also be overridden at job level. Defaults to 1 min.
评估间隔:It defines the interval based on which prometheus evaluates the query for alerting. In each evaluation cycle, prometheus runs the expression defined in each alerting rule and sets the state of alert.
建议:将两个间隔设置为该same值
发出警报所需的时间应在以下范围内变化:
minimum time = [time set in the 'FOR' clause]
maximum time = [scrapeInterval + evaluationInterval + 'FOR' clause time]
Run Code Online (Sandbox Code Playgroud)
假设:evaluationInterval是multiple的scrapeInterval。例如,
scrapeInterval = 30 sec and
evaluation interval = 1 min and
FOR clause set for 2 mins
Minimum time to fire alarm => 2 mins.
Maximum time to fire alarm => 30 sec + 1min + 2min => 3 min 30 sec
Run Code Online (Sandbox Code Playgroud)
注意:如果FOR子句时间为0,警报将立即进入触发状态。
如果您觉得有用,请点赞:)
这两个进程是独立的,PromQL 和记录规则都不知道您的抓取间隔是多少。因此,无论评估间隔是多少,您指定的任何规则在给定时间评估时都会以相同的方式评估并获得相同的结果。
为简单起见,最好使两个间隔相同,因此我建议此处均设为 15 秒。
| 归档时间: |
|
| 查看次数: |
30548 次 |
| 最近记录: |