Based on discussion with Ibrar it looks like we can have multiple queries with the same id, but in different buckets.
So we should handle each bucket separately and don't count them twice
To not count them twice we can align our collects with bucket start times.
And also please address these comments in https://github.com/percona/pmm-agent/pull/183
Please move the second half to a separate case with a different logging line (but the same logic) and test with debug logging
[https://github.com/percona/pmm-agent/pull/183#discussion_r486850349
]
How to test it:
- Enable pg_stat_monitor extension for PostgreSQL server.
- Add PG with pg_stat_monitor to pmm.
- Run some SQL queries.
- Wait for metrics more time than `pg_stat_monitor.pgsm_bucket_time` value.
- Check that query count is not more than you've run.