Exclude pg_dump sessions from PostgresqlSlowQueries alert - #139
Merged
Conversation
pg_dump takes a long-lived transaction snapshot for the whole duration of a backup, so pg_stat_activity_max_tx_duration crosses the 60s threshold on every backup and fires PostgresqlSlowQueries. Those are expected long transactions, not slow queries. Filter out backup sessions by application_name (pg_dump, pg_dumpall) so the alert only reflects genuinely slow client workloads. Signed-off-by: souravbiswassanto <saurov@appscode.com>
ArnobKumarSaha
approved these changes
Aug 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
PostgresqlSlowQueriesfires on everypg_dumpbackup:pg_dumpholds a single repeatable-read transaction open for the entire duration of the dump to get a consistent snapshot, sopg_stat_activity_max_tx_durationfor that session grows to however long the backup takes. That is expected behaviour for a backup, not a slow query, so the alert is pure noise on any database large enough for a dump to exceed the threshold.Change
Add
application_name!~"pg_dump.*"to the alert expression incharts/postgres-alerts/templates/alert.yaml, which drops bothpg_dumpandpg_dumpallsessions. Client workloads that are genuinely slow still trigger the alert unchanged.Rendered output:
Verified with
helm template.Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.