Prometheus 设置 scrape_interval

eas*_* wu 5 prometheus victoriametrics

我正在尝试使用 Prometheus 和 VictoriaMetrics 来收集数据,在配置我的服务器 prometheus.yml 时有一行:

scrape_interval: 15s  # How frequently to scrape targets by default.
Run Code Online (Sandbox Code Playgroud)

这是否意味着我的搜索结果可能会延迟 15 秒?

Sau*_*rya 4

是的,这意味着在最坏的情况下,您的指标将在 15 秒后到达。您可以将其配置得更快。

<duration>: a duration matching the regular expression [0-9]+(ms|[smhdwy])

以上内容来自 Prometheus 文档:https ://prometheus.io/docs/prometheus/latest/configuration/configuration/#duration

通常,将其视为 Prometheus 拍摄(连续)指标的快照(CPU 使用情况、运行的线程数等),而不是将 Prometheus 视为收集离散事件的地方。

当您考虑触发警报需要多长时间或数据可见时,抓取间隔是需要牢记的一个因素。

在警报方面,这篇文章是一个很好的资源:https://pracucci.com/prometheus-understanding-the-delays-on-alerting.html

它基本上是说,如果您的抓取间隔是x时间单位,并且仅当表达式对于y时间单位为真时才触发警报,那么延迟最多可能是 (x + y) 时间单位。