Capture usename and application_name for pg_stat_activity
Description
How to test
Configure PMM and alerting
Configure local PMM agent
Configure local PostgreSQL instance and add to monitoring
Add alerting rule for pg_stat_activity_max_tx_duration {application_name="put_your_app_name_here"}
Add alerting rule for pg_stat_activity_max_tx_duration {usename="put_your_user_name_here"}
Check that alerts fires or does not fire depending on your alert conditions
How to document
Attachments
Smart Checklist
Activity
Ihor Cherkasov October 17, 2022 at 12:28 PM
Hello! Great news! I'm closing the ticket then. Thank you for the response!
Mateusz Henicz October 17, 2022 at 11:13 AM
Hey,
Works great! Thanks.
I have also tested it and everything worked on my local lab.
Ihor Cherkasov October 10, 2022 at 4:19 PM
Hello! Could you please confirm that implemented functionality covers the needs of this improvement?
Ihor Cherkasov October 10, 2022 at 4:17 PM
Verified on FB – https://github.com/Percona-Lab/pmm-submodules/pull/2815#issuecomment-1271591422
Server Docker – perconalab/pmm-server-fb:PR-2815-facd2a3
Client Tarball – https://s3.us-east-2.amazonaws.com/pmm-build-cache/PR-BUILDS/pmm2-client/pmm2-client-PR-2815-facd2a3.tar.gz
What was tested:
1. Now pg_stat_activity_* metrics have "application_name" and "usename" labels:
2. Alerting was tested for both metric labels "application_name" and "usename":
2.1. "application_name" label:
application_name was set to "manual" for "custom" database:
Alert rule for was created:
Alert firing:
So, now user is able to filter metrics by "application_name" label value when configuring alerting
2.2. "usename" label:
Alert rule was created:
Alert firing:
So, user is able to filter metrics by "usename" label when configuring alerting
Taras Shcherban October 4, 2022 at 7:20 AM
Passing a feature build to our QA to verify that it doesn't break anything.
Impact on the user
Unable to write alert rules that ignore specific users or applications for long-running transactions via
pg_stat_activity_max_tx_duration
, leading to unnecessary alertsSteps to reproduce
Configure PMM and alerting
Configure local PMM agent
Configure local PostgreSQL instance and add to monitoring
Add alerting rule for
where n is set to a value suitable for the data set
Perform backup using pdgump
Actual result
Alert received as unable to exclude the backup from alerting
Details
It is necessary to be able to exclude backups from long-running transaction alerts, as they are to be expected. With the current pg_stat_activity metric there is no ability to filter out specific users or application names.