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

kgqe7b3p  于 12个月前  发布在  PostgreSQL
关注(0)|答案(1)|浏览(119)

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

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

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

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#

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

(pg_settings_cpu_index_tuple_cost + pg_settings_cpu_tuple_cost + 
pg_settings_cpu_operator_cost) * 100

字符串

相关问题