We want to get the CPU usage of Postgres through postgres_exporter in Prometheus.
There are three CPU related metrics per doc
# 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
We think the CPU usage could be calculated by
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
We have no idea whether if the above calculation is correct or not. Could someone help us to double-check it? Or anything are we missing?