Skip to content

Conversation

@cristiangreco
Copy link
Contributor

@cristiangreco cristiangreco commented Dec 3, 2025

PR Description

This PR introduces a change for excluding "own queries" in postgres from pg_stat_activity: we need to drop samples (and wait events) for the currently connected user. This new behaviour is enabled by default through the setting exclude_current_user, as it's deemed safe / recommended.

No changes to be done on pg_stat_statements as that is achieved through user permissions update (docs on the website).

Which issue(s) this PR fixes

Relates to https://github.com/grafana/grafana-dbo11y-app/issues/1307

Notes to the Reviewer

PR Checklist

  • CHANGELOG.md updated
  • Documentation added
  • Tests updated
  • Config converters updated

BEGIN_COMMIT_OVERRIDE
feat: database_observability: stop tracking own instrumentation queries (#4991)

This PR introduces a change for excluding "own queries" in postgres from
pg_stat_activity: we need to drop samples (and wait events) for the
currently connected user. This new behaviour is enabled by default
through the setting exclude_current_user, as it's deemed safe /
recommended.

No changes to be done on pg_stat_statements as that is achieved
through user permissions update (docs on the website).
END_COMMIT_OVERRIDE

@cristiangreco cristiangreco force-pushed the cristian/dbo11y-disable-own-queries-tracking-pg branch 3 times, most recently from d37df3f to d8a065d Compare December 3, 2025 10:34
@cristiangreco cristiangreco marked this pull request as ready for review December 3, 2025 10:36
@cristiangreco cristiangreco requested review from a team and clayton-cornell as code owners December 3, 2025 10:36
@github-actions
Copy link
Contributor

github-actions bot commented Dec 3, 2025

💻 Deploy preview available (dbo11y: stop tracking alloy's own queries in pg_stat_activity):

@clayton-cornell clayton-cornell added the type/docs Docs Squad label across all Grafana Labs repos label Dec 3, 2025
@cristiangreco cristiangreco force-pushed the cristian/dbo11y-disable-own-queries-tracking-pg branch from d8a065d to 39091a0 Compare December 15, 2025 20:16
@cristiangreco cristiangreco changed the title dbo11y: stop tracking alloy's own queries in pg_stat_activity feat: database_observability: stop tracking own instrumentation queries Dec 15, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Dec 16, 2025

💻 Deploy preview available (feat: database_observability: stop tracking own instrumentation queries):

This PR introduces a change for excluding "own queries" in postgres from
`pg_stat_activity`: we need to drop samples (and wait events) for the
currently connected user. This new behaviour is enabled by default
through the setting `exclude_current_user`, as it's deemed safe /
recommended.

No changes to be done on `pg_stat_statements` as that is achieved
through user permissions update (docs on the website).
@cristiangreco cristiangreco force-pushed the cristian/dbo11y-disable-own-queries-tracking-pg branch from 6f3ad1e to 5061da1 Compare December 16, 2025 09:54
Comment on lines +32 to +39
columns := []string{
"now", "datname", "pid", "leader_pid",
"usename", "application_name", "client_addr", "client_port",
"backend_type", "backend_start", "backend_xid", "backend_xmin",
"xact_start", "state", "state_change", "wait_event_type",
"wait_event", "blocked_by_pids", "query_start", "query_id",
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Drive-by change: I've tried to fix flakyness of these tests and make the style more consistent.

Copy link
Contributor

@matthewnolf matthewnolf left a comment

Choose a reason for hiding this comment

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

Looks good!

@cristiangreco cristiangreco force-pushed the cristian/dbo11y-disable-own-queries-tracking-pg branch from b44955e to 4e3c751 Compare December 16, 2025 10:59
@cristiangreco cristiangreco merged commit 0b55557 into main Dec 16, 2025
45 of 46 checks passed
@cristiangreco cristiangreco deleted the cristian/dbo11y-disable-own-queries-tracking-pg branch December 16, 2025 11:18
@github-actions github-actions bot locked and limited conversation to collaborators Dec 16, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

type/docs Docs Squad label across all Grafana Labs repos

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants