找出 Prometheus 中 CPU 使用率高的查询

ken*_*tor 5 prometheus

我负责管理多个团队的普罗米修斯集群。平均 CPU 利用率是 4 个分配的 CPU 核心的 0.6。然而,有时 Prometheus 会在数分钟甚至数小时内将 4 个核心的 CPu 最大化。

我认为 CPU 使用率高是由运行大量(低效)查询的 Grafana 仪表板引起的。由于每次都有多个 grafana 仪表板,我很难弄清楚哪个仪表板甚至查询导致了我的 prometheus 集群上的高 CPU 使用率。更大的问题是,这会导致所有其他仪表板非常慢,因为 prometheus 实例无法及时回答查询。

问题

我如何找出哪些查询消耗大量 CPU 使用率,或者如何限制查询/团队的 CPU 使用率?

小智 0

过时了,但仍然可以用谷歌搜索。现在您可以启用查询日志记录 https://github.com/prometheus/prometheus/pull/6520/files#diff-17f1012e0c2fbd9bcd8dff3c23b1 ​​8ff4b6676eef3beca6f8a3e72e6a36633334L68-R71

global:
...
  # File to which PromQL queries are logged.
  # Reloading the configuration will reopen the file.
  [ query_log_file: <string> ]
Run Code Online (Sandbox Code Playgroud)