Skip to content

Conversation

kmoppel
Copy link
Contributor

@kmoppel kmoppel commented Aug 22, 2025

To reduce the observer effect, filter out pg_stat_activity rows of the postgres_exporter session from all SA queries, based on pid / procpid.

A bit annoying to see idling DBs showing pg_stat_activity_count "active" count of 1. Other Postgres monitoring tools (like pgwatch for example) take it into account

To reduce the observer effect, filter out pg_stat_activity rows of the
postgres_exporter session from all SA queries, based on pid / procpid.

A bit annoying to see idling DBs showing pg_stat_activity_count "active"
count of 1

Signed-off-by: Kaarel Moppel <[email protected]>
@kmoppel kmoppel force-pushed the exclude-collecting-query-from-pg-stat-activity branch from aa2f47b to 3fc80a7 Compare August 25, 2025 08:04
@sysadmind sysadmind merged commit 198454c into prometheus-community:master Aug 26, 2025
11 checks passed
maxenglander added a commit to planetscale/postgres_exporter that referenced this pull request Sep 10, 2025
maxenglander added a commit to planetscale/postgres_exporter that referenced this pull request Sep 10, 2025
…vity (prometheus-community#1185)" (#7)

This reverts commit 198454c.

prometheus-community#1185
appears to have broken some things:

>
{"time":"2025-09-10T03:57:53.677992156Z","level":"ERROR","source":"collector.go:223","msg":"collector
failed","name":"long_running_transactions","duration_seconds":0.010053746,"err":"sql:
Scan error on column index 1, name \"oldest_timestamp_seconds\":
converting NULL to float64 is unsupported"}
>
{"time":"2025-09-10T03:57:53.679318983Z","level":"ERROR","source":"collector.go:223","msg":"collector
failed","name":"process_idle","duration_seconds":0.011370523,"err":"pq:
syntax error at or near \";\""}

Signed-off-by: Max Englander <[email protected]>
@@ -56,6 +56,7 @@ func (PGProcessIdleCollector) Update(ctx context.Context, instance *instance, ch
COUNT(*) AS process_idle_seconds_count
FROM pg_stat_activity
WHERE state ~ '^idle'
AND pid <> pg_backend_pid();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bug here

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants