Capture usename and application_name for pg_stat_activity

Description

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 alerts

Steps 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.

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

None

Attachments

9

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

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.

Done

Details

Assignee

Reporter

Priority

Needs QA

Yes

Needs Doc

No

Planned Version/s

Fix versions

Story Points

Affects versions

Smart Checklist

Created August 12, 2022 at 3:10 PM
Updated March 6, 2024 at 12:50 AM
Resolved November 9, 2022 at 8:11 AM