# Postgresql Query Drill Down Dashboard metrics - pg\_stat\_statements\_time milliseconds is not from postgres\_exporter

**URL:** <https://forums.percona.com/t/postgresql-query-drill-down-dashboard-metrics-pg-stat-statements-time-milliseconds-is-not-from-postgres-exporter/13911>\
**Category:** PMM 2.x\
**Created:** [January 13, 2022, 9:23pm UTC](https://forums.percona.com/t/postgresql-query-drill-down-dashboard-metrics-pg-stat-statements-time-milliseconds-is-not-from-postgres-exporter/13911 "2022-01-13T21:23:11Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Eleonora\_Grigoryan](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/eleonora_grigoryan/32/5573_2.png) [@Eleonora\_Grigoryan](https://forums.percona.com/u/Eleonora_Grigoryan)\
**Post date:** [January 13, 2022, 9:23pm UTC](https://forums.percona.com/t/postgresql-query-drill-down-dashboard-metrics-pg-stat-statements-time-milliseconds-is-not-from-postgres-exporter/13911/1 "2022-01-13T21:23:11Z")

</div>

In the mentioned dashboard there is prometheus metric called  
pg\_stat\_statements \_time\_milliseconds

I have noticed that this is not collected by postgres\_exporter. I am interested how this metric is being gathered and where? This is under query duration graph. I have tried to set up PMM Server but it also fails to show the mentioned metric and I want to understand how to troubleshoot it.

Thanks

---

<div class="post-metadata">

**Author:** ![Lenz\_Grimmer](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/lenz_grimmer/32/2419_2.png) [@Lenz\_Grimmer](https://forums.percona.com/u/Lenz_Grimmer)\
**Post date:** [January 14, 2022, 10:47am UTC](https://forums.percona.com/t/postgresql-query-drill-down-dashboard-metrics-pg-stat-statements-time-milliseconds-is-not-from-postgres-exporter/13911/2 "2022-01-14T10:47:47Z")

</div>

That metric is likely only populated if you’ve enabled the `pg_stat_statements` PostgreSQL extension. Did you install it? If not, please see the [upstream documentation](https://www.postgresql.org/docs/13/pgstatstatements.html) on how to accomplish this.

By the way, we’re working on a PostgreSQL extension named `pg_stat_monitor`, which provides a lot of additional stats and metrics. It’s included in our [PostgreSQL distribution](https://www.percona.com/doc/postgresql/14/pg-stat-monitor.html).

---

<div class="post-metadata">

**Author:** ![Eleonora\_Grigoryan](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/eleonora_grigoryan/32/5573_2.png) [@Eleonora\_Grigoryan](https://forums.percona.com/u/Eleonora_Grigoryan)\
**Post date:** [January 14, 2022, 12:02pm UTC](https://forums.percona.com/t/postgresql-query-drill-down-dashboard-metrics-pg-stat-statements-time-milliseconds-is-not-from-postgres-exporter/13911/3 "2022-01-14T12:02:15Z")

</div>

Thank you for the answer.

Sure I have enabled pg\_stat\_statements extension for all databases.

I have installed PMM client , postgres\_exporter is registered and works fine but still those pg\_stat\_statement\_\* metrics are not collected in exporter [host]:9187/metrics. I thought I have to install additional components or another exporter is being used, not the default [postgres\_exporter](https://github.com/prometheus-community/postgres_exporter)

For example this statement does not work

sum by (datname) ((rate(pg\_stat\_statements\_calls{datname=~“$datname”,instance=~“$host”}[$interval]) or  
irate(pg\_stat\_statements\_calls{datname=~“$datname”,instance=~“$host”}[5m])))

Dashboards are very helpful but I can’t make them work

PS.I have checked pg\_stat\_monitor, it seems better, but my version is PG10 not supported by it so I use pg\_stat\_statements instead. **strong text**

---

<div class="post-metadata">

**Author:** ![sergey.kuzmichev](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/sergey.kuzmichev/32/1279_2.png) [@sergey.kuzmichev](https://forums.percona.com/u/sergey.kuzmichev)\
**Post date:** [January 20, 2022, 11:19am UTC](https://forums.percona.com/t/postgresql-query-drill-down-dashboard-metrics-pg-stat-statements-time-milliseconds-is-not-from-postgres-exporter/13911/4 "2022-01-20T11:19:16Z")

</div>

Hi @Eleonora_Grigoryan,

The query drill-down dashboard is a custom dashboard implemented for PMM 1.x. It requires the presence of extra metrics that aren’t available by default. Please read this blogpost: [Adding PostgreSQL Queries Overview Dashboards to the PMM Plugin - Percona Database Performance Blog](https://www.percona.com/blog/2019/04/23/adding-postgresql-queries-overview-dashboards-to-the-pmm-plugin/).

In PMM 2.x the same functionality should be superseded by QAN. Technically, it is possible to add the same metrics and create an analogous dashboard, I’ve done that: [scratch/pmm2-pg at master · arronax/scratch · GitHub](https://github.com/arronax/scratch/tree/master/pmm2-pg). There, pg\_query\_drill-down.json and pg\_query\_overview.json are dashboards and pg\_query\_pg13.yaml is a custom query definition. You can find guidance on how to add custom queries in PMM 2 in the following blog post: [PostgreSQL Custom Dashboards Ported to Percona Monitoring and Management 2 - Percona Database Performance Blog](https://www.percona.com/blog/postgresql-custom-dashboards-ported-to-pmm-2/).

_ **However** _, I strongly recommend against using these dashboards in PMM 2. The nature of query-related metrics makes them ill-suited for time series databases like the VictoriaMetrics used in PMM 2. Moreover, the same data is already being gathered by the QAN subsystem of PMM. If you feel that QAN cannot give you something that the “query drill-down” dashboard can, consider creating a feature request in the PMM Jira project: [https://jira.percona.com/projects/PMM/issues](https://jira.percona.com/projects/PMM/issues). If the dashboard is still required in the meantime, the correct way would be to query the ClickHouse database which contains the QAN data. For an example of this, you can check out the following dashboard: [RED Method for MySQL Queries - Designed for PMM2 | Grafana Labs](https://grafana.com/grafana/dashboards/12470).

P.S. My answer here is heavily based on the assumption that you’re using PMM 2. If you’re still using PMM 1, you should update soon, as it’s going EOL in May, 2022.
