我们希望通过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
型
我们不知道上面的计算是否正确。有人能帮我们再检查一遍吗?或者我们遗漏了什么?
1条答案
按热度按时间wkftcu5l1#
如果你不想让它有时间限制,那么你可以这样使用它:
字符串