postgresql 如何计算Prometheus Postgres导出器的CPU使用率?

kgqe7b3p  于 2023-11-18  发布在  PostgreSQL
关注(0)|答案(1)|浏览(135)

我们希望通过Prometheus中的postgres_exporter获得PostgreSQL的CPU使用率。
每个doc有三个与CPU相关的指标:

  1. # HELP pg_settings_cpu_index_tuple_cost Sets the planner's estimate of the cost of processing each index entry during an index scan.
  2. # TYPE pg_settings_cpu_index_tuple_cost gauge
  3. pg_settings_cpu_index_tuple_cost{server="localhost:5432"} 0.005
  4. # HELP pg_settings_cpu_operator_cost Sets the planner's estimate of the cost of processing each operator or function call.
  5. # TYPE pg_settings_cpu_operator_cost gauge
  6. pg_settings_cpu_operator_cost{server="localhost:5432"} 0.0025
  7. # HELP pg_settings_cpu_tuple_cost Sets the planner's estimate of the cost of processing each tuple (row).
  8. # TYPE pg_settings_cpu_tuple_cost gauge
  9. pg_settings_cpu_tuple_cost{server="localhost:5432"} 0.01

字符串
我们认为CPU使用率可以通过以下方式计算:

  1. avg by (server) (avg_over_time(pg_settings_cpu_index_tuple_cost[2m]) + avg_over_time(pg_settings_cpu_tuple_cost[2m]) + avg_over_time(pg_settings_cpu_operator_cost[2m]) ) * 100


我们不知道上面的计算是否正确。有人能帮我们再检查一遍吗?或者我们遗漏了什么?

wkftcu5l

wkftcu5l1#

如果你不想让它有时间限制,那么你可以这样使用它:

  1. (pg_settings_cpu_index_tuple_cost + pg_settings_cpu_tuple_cost +
  2. pg_settings_cpu_operator_cost) * 100

字符串

相关问题