了解 Prometheus 指标拉取
Understand Prometheus Metrics Pulling
Prometheus Metrics Pulling 阅读和尝试后,我仍然不是很理解。
假设我有一个 telegraf 代理,每 5 秒向 Prometheus 发送一次指标。
- Prometheus 应该配置为每 5 秒拉一次,对吗?但是,如果推和拉之间有几秒的间隔怎么办(好吧,推和拉不会同时发生)?如果 Prometheus 配置为每 7 秒拉一次会怎样?
- 如果 Prometheus 配置为每 15 秒拉一次会怎样? 3 推中只有一个被拉下? telegraf agent 会挑剔吗?
- 如果 Prometheus 配置为每 30 秒甚至 60 秒拉取一次会怎样?是那个时间点的拉取值,还是平均超过 30 / 60 秒?
最后,运行时间Prometheus pulling interval可以改吗?我想在晚上将拉动间隔减少到每 30 秒甚至 60 秒。
我不知道您使用的是哪种导出器,一般来说,Prometheus 指标导出器是 HTTP server
在特定端点服务(大多数情况下 /metrics
)。
因此,当您在配置 Prometheus 时设置 scrape_interval=x
时,它将每隔 x 秒在目标端点发出一个 GET
请求并存储这些时间序列指标。
如果你想监控一些持续时间少于scrape_interval
的事件,你可能会错过这些事件。有一个叫prometheus pushgateway
的东西可以解决这个问题。
一般情况下,metrics exporters不会对时间序列数据进行任何操作,你会收到那一刻的数据。
Prometheus can reload its configuration at runtime. If the new configuration is not well-formed, the changes will not be applied. A configuration reload is triggered by sending a SIGHUP to the Prometheus process or sending a HTTP POST request to the /-/reload endpoint (when the --web.enable-lifecycle flag is enabled). This will also reload any configured rule files.
Say I have a telegraf agent that sends metrics over to Prometheus every 5 seconds.
Telegraf 的 Prometheus output plugin 与 InfluxDB 输出插件不同,它不会将指标推送到目标,而是创建一个服务于 /metrics(默认)端点的网络服务器。
如果您想使用推而不是拉,您可以使用 Pushgateway。推送到 Pushgateway 的数据(通过 HTTP POST 或 PUT)将在 Pushgateway 的端点可用,可以被 Prometheus 抓取。
但请注意,Pushgateway 只能用于某些情况,请参阅 here.
Telegraf 提供了一些 HTTP 输出插件,因此您可以(理论上)使用 Telegraf 将指标推送到 Pushgateway。但在这种情况下,您不应该额外使用 Telegraf 的 Prometheus 输出插件。
Prometheus 根据提供的 scrape configs. Unlike InfluxDB, Prometheus doesn't accept metrics pushed to it from other services. See this article 定期(又名 scrape_interval
)从配置的目标中拉取指标,这解释了为什么 Prometheus 支持拉模型而不是推模型来收集数据。
如果您仍然需要将指标推送到 Prometheus-like 系统,请查看 VictoriaMetrics. It supports both pull and push protocols for data ingestion, including InfluxDB line protocol, so Telegraf can be configured to push metrics directly to VictoriaMetrics. See these docs。
Prometheus Metrics Pulling 阅读和尝试后,我仍然不是很理解。
假设我有一个 telegraf 代理,每 5 秒向 Prometheus 发送一次指标。
- Prometheus 应该配置为每 5 秒拉一次,对吗?但是,如果推和拉之间有几秒的间隔怎么办(好吧,推和拉不会同时发生)?如果 Prometheus 配置为每 7 秒拉一次会怎样?
- 如果 Prometheus 配置为每 15 秒拉一次会怎样? 3 推中只有一个被拉下? telegraf agent 会挑剔吗?
- 如果 Prometheus 配置为每 30 秒甚至 60 秒拉取一次会怎样?是那个时间点的拉取值,还是平均超过 30 / 60 秒?
最后,运行时间Prometheus pulling interval可以改吗?我想在晚上将拉动间隔减少到每 30 秒甚至 60 秒。
我不知道您使用的是哪种导出器,一般来说,Prometheus 指标导出器是 HTTP server
在特定端点服务(大多数情况下 /metrics
)。
因此,当您在配置 Prometheus 时设置
scrape_interval=x
时,它将每隔 x 秒在目标端点发出一个GET
请求并存储这些时间序列指标。如果你想监控一些持续时间少于
scrape_interval
的事件,你可能会错过这些事件。有一个叫prometheus pushgateway
的东西可以解决这个问题。一般情况下,metrics exporters不会对时间序列数据进行任何操作,你会收到那一刻的数据。
Prometheus can reload its configuration at runtime. If the new configuration is not well-formed, the changes will not be applied. A configuration reload is triggered by sending a SIGHUP to the Prometheus process or sending a HTTP POST request to the /-/reload endpoint (when the --web.enable-lifecycle flag is enabled). This will also reload any configured rule files.
Say I have a telegraf agent that sends metrics over to Prometheus every 5 seconds.
Telegraf 的 Prometheus output plugin 与 InfluxDB 输出插件不同,它不会将指标推送到目标,而是创建一个服务于 /metrics(默认)端点的网络服务器。
如果您想使用推而不是拉,您可以使用 Pushgateway。推送到 Pushgateway 的数据(通过 HTTP POST 或 PUT)将在 Pushgateway 的端点可用,可以被 Prometheus 抓取。 但请注意,Pushgateway 只能用于某些情况,请参阅 here.
Telegraf 提供了一些 HTTP 输出插件,因此您可以(理论上)使用 Telegraf 将指标推送到 Pushgateway。但在这种情况下,您不应该额外使用 Telegraf 的 Prometheus 输出插件。
Prometheus 根据提供的 scrape configs. Unlike InfluxDB, Prometheus doesn't accept metrics pushed to it from other services. See this article 定期(又名 scrape_interval
)从配置的目标中拉取指标,这解释了为什么 Prometheus 支持拉模型而不是推模型来收集数据。
如果您仍然需要将指标推送到 Prometheus-like 系统,请查看 VictoriaMetrics. It supports both pull and push protocols for data ingestion, including InfluxDB line protocol, so Telegraf can be configured to push metrics directly to VictoriaMetrics. See these docs。