Skip to content

feat: Database_observability: add health check collector for postgres component#5222

Merged
matthewnolf merged 2 commits intomainfrom
mn/pg-telemetry-health-check
Jan 12, 2026
Merged

feat: Database_observability: add health check collector for postgres component#5222
matthewnolf merged 2 commits intomainfrom
mn/pg-telemetry-health-check

Conversation

@matthewnolf
Copy link
Contributor

Brief description of Pull Request

This change adds a new health_check collector to the database_observability.postgres component, responsible for exposing diagnostic status information. This information can be used to diagnose misconfiguration issues.

This is a followup to this PR, which first introduced this for MySQL

Pull Request Details

Issue(s) fixed by this Pull Request

Notes to the Reviewer

PR Checklist

  • Documentation added
  • Tests updated
  • Config converters updated

@matthewnolf matthewnolf requested review from a team and clayton-cornell as code owners January 9, 2026 17:01
@matthewnolf matthewnolf changed the title feat: database_observability: add health check collector for db-o11y postgres component feat: database_observability: add health check collector for postgres component Jan 9, 2026
@matthewnolf matthewnolf changed the title feat: database_observability: add health check collector for postgres component feat: Database_observability: add health check collector for postgres component Jan 9, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Jan 9, 2026

💻 Deploy preview available (feat: database_observability: add health check collector for db-o11y postgres component):

r.err = fmt.Errorf("iterate pg_stat_statements: %w", err)
}

r.result = true
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the meaning of result here, given it's always set to true (while above we check for rows.Next())?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right - we don't need this line

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 2bfaeb0

@clayton-cornell clayton-cornell added the type/docs Docs Squad label across all Grafana Labs repos label Jan 12, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Jan 12, 2026

💻 Deploy preview deleted (feat: Database_observability: add health check collector for postgres component).

// checkPgStatStatementsEnabled verifies that the pg_stat_statements extension is enabled.
func checkPgStatStatementsEnabled(ctx context.Context, db *sql.DB) healthCheckResult {
r := healthCheckResult{name: "PgStatStatementsEnabled"}
const q = `SELECT * FROM pg_extension WHERE extname = 'pg_stat_statements'`
Copy link
Contributor

Choose a reason for hiding this comment

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

Just to note that our docs says to enable the extension on every database, but I appreciate it might worth starting simple and just running the check on the initial connection database.

@matthewnolf matthewnolf merged commit 80917b1 into main Jan 12, 2026
48 checks passed
@matthewnolf matthewnolf deleted the mn/pg-telemetry-health-check branch January 12, 2026 11:15
@grafana-alloybot grafana-alloybot bot mentioned this pull request Jan 12, 2026
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 27, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

frozen-due-to-age 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