# Python.d/postgres plugin: add pg\_stat\_statements metrics for monitoring database queries

**URL:** <https://community.netdata.cloud/t/python-d-postgres-plugin-add-pg-stat-statements-metrics-for-monitoring-database-queries/1441>\
**Category:** Help\
**Tags:** agent-collector, agent\
**Created:** [June 18, 2021, 1:53pm UTC](https://community.netdata.cloud/t/python-d-postgres-plugin-add-pg-stat-statements-metrics-for-monitoring-database-queries/1441 "2021-06-18T13:53:40Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vitaliy\_Kukharik](https://yyz1.discourse-cdn.com/flex029/user_avatar/community.netdata.cloud/vitaliy_kukharik/32/932_2.png) [@Vitaliy\_Kukharik](https://community.netdata.cloud/u/Vitaliy_Kukharik)\
**Post date:** [June 18, 2021, 1:53pm UTC](https://community.netdata.cloud/t/python-d-postgres-plugin-add-pg-stat-statements-metrics-for-monitoring-database-queries/1441/1 "2021-06-18T13:53:40Z")

</div>

## Problem/Question

I experiment with the addition of pg\_stat\_statements metrics to monitor queries to PostgreSQL in Netdata (python.d/postgres plugin), and I have some difficulties with adding the new charts.

In fact, I can now add Top-1 metrics (e.g., max total time)

 ![изображение](https://canada1.discourse-cdn.com/flex029/uploads/netdata2/original/1X/f6f61f64a2bd5f5e78ad12c45c00cc628b8749fc.png)

But I have a questions:

1. How to add a queryid to a chart?
2. How to add multiple values in chart for each queryid?

 ![изображение](https://canada1.discourse-cdn.com/flex029/uploads/netdata2/original/1X/232aa5e95d3c5d4f86e0d08ddf94b0cb8f9dc762.png)

Here are the changes that I made in postgres.chart.py:  
[https://github.com/vitabaks/netdata/commit/904667937b4ff46f42e6182801802a0fe53cd66b](https://github.com/vitabaks/netdata/commit/904667937b4ff46f42e6182801802a0fe53cd66b)

I am not strong in programming on Python, so I will be glad to any help in this matter.

## What I expected to happen

Add stat\_statements charts with multiple values for each queryid.

Example:

 ![изображение](https://canada1.discourse-cdn.com/flex029/uploads/netdata2/original/1X/427b1cd924a566371b3a3d52edfb29f11ef3d39f.png)

---

<div class="post-metadata">

**Author:** ![myin142](https://yyz1.discourse-cdn.com/flex029/user_avatar/community.netdata.cloud/myin142/32/1533_2.png) [@myin142](https://community.netdata.cloud/u/myin142)\
**Post date:** [February 9, 2022, 8:42am UTC](https://community.netdata.cloud/t/python-d-postgres-plugin-add-pg-stat-statements-metrics-for-monitoring-database-queries/1441/2 "2022-02-09T08:42:39Z")

</div>

How is the progress of this feature? It would be really useful for our project. Even just the Top-1 metrics would be more than enough for us.  
Unfortunately I can’t really help you with the question but couldn’t you take inspiration from existing collectors that does the same thing like the Applications \> CPU chart?

---

<div class="post-metadata">

**Author:** ![ilyam8](https://yyz1.discourse-cdn.com/flex029/user_avatar/community.netdata.cloud/ilyam8/32/134_2.png) [@ilyam8](https://community.netdata.cloud/u/ilyam8)\
**Post date:** [February 9, 2022, 10:36am UTC](https://community.netdata.cloud/t/python-d-postgres-plugin-add-pg-stat-statements-metrics-for-monitoring-database-queries/1441/3 "2022-02-09T10:36:25Z")

</div>

Hello, guys. Somehow I missed this topic 🤷‍♂️ @Vitaliy_Kukharik my suggestion is to create a PR with your changes. I have no real experience with Postgres, but I can tag some people on GitHub who has.

As for a chart with `queryid` dimensions - I understand that we need to add a dimension to the chart is there is a new entry in that table. But do we need to remove them?
