Postgis pg_stat_statements 错误

Postgis pg_stat_statements errors

我在 Kubernetes 集群上部署了一个 Postgis 数据库,使用 this 图片:docker pull postgis/postgis:13-3.1.

我正在尝试解决这个错误:

2021-06-29 03:20:50.958 UTC [2852] ERROR:  relation "pg_stat_statements" does not exist at character 536
2021-06-29 03:20:50.958 UTC [2852] STATEMENT:  SELECT t2.rolname, t3.datname, queryid, calls, total_time / 1000 as total_time_seconds, min_time / 1000 as min_time_seconds, max_time / 1000 as max_time_seconds, mean_time / 1000 as mean_time_seconds, stddev_time / 1000 as stddev_time_seconds, rows, shared_blks_hit, shared_blks_read, shared_blks_dirtied, shared_blks_written, local_blks_hit, local_blks_read, local_blks_dirtied, local_blks_written, temp_blks_read, temp_blks_written, blk_read_time / 1000 as blk_read_time_seconds, blk_write_time / 1000 as blk_write_time_seconds FROM pg_stat_statements t1 JOIN pg_roles t2 ON (t1.userid=t2.oid) JOIN pg_database t3 ON (t1.dbid=t3.oid) WHERE t2.rolname != 'rdsadmin'

所以我在我的所有数据库中安装了缺少的扩展,如下所示:

psql -U $PG_USER \
  -d $DATABSE \
  -c "CREATE EXTENSION pg_stat_statements SCHEMA public"

psql -U $PG_USER \
  -d $DATABSE \
  -c "CREATE EXTENSION pg_stat_statements SCHEMA pg_catalog"

我现在收到这个错误:

2021-06-29 20:04:46.870 UTC [331] ERROR:  column "total_time" does not exist at character 48
2021-06-29 20:04:46.870 UTC [331] STATEMENT:  SELECT t2.rolname, t3.datname, queryid, calls, total_time / 1000 as total_time_seconds, min_time / 1000 as min_time_seconds, max_time / 1000 as max_time_seconds, mean_time / 1000 as mean_time_seconds, stddev_time / 1000 as stddev_time_seconds, rows, shared_blks_hit, shared_blks_read, shared_blks_dirtied, shared_blks_written, local_blks_hit, local_blks_read, local_blks_dirtied, local_blks_written, temp_blks_read, temp_blks_written, blk_read_time / 1000 as blk_read_time_seconds, blk_write_time / 1000 as blk_write_time_seconds FROM pg_stat_statements t1 JOIN pg_roles t2 ON (t1.userid=t2.oid) JOIN pg_database t3 ON (t1.dbid=t3.oid) WHERE t2.rolname != 'rdsadmin'

我试图找到原因,但没有找到任何有用的信息。关于如何解决这个问题有什么想法吗?

Postgres 版本:psql (PostgreSQL) 13.2 (Debian 13.2-1.pgdg100+1)

配置文件:

# ...
shared_preload_libraries = 'pg_stat_statements'
pg_stat_statements.max = 1000
pg_stat_statements.track = all
# ...

该查询来自某些监控工具;据我所知,这与 postgis 无关。监视工具已过时,因为现在该列称为“total_exec_time”。 (在为计划时间和执行时间添加列时重命名。)

根据 jjanes 的评论,我发现 Prometheus 节点导出器进行了错误的查询 (here),因为该列确实拼写错误。

更改列名解决了这个问题。