Skip to content

Update messages when the monitoring user doesn't have a proper setup #699

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions input/postgres/replication.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,12 @@ func GetReplication(ctx context.Context, c *Collection, db *sql.DB) (state.Postg
sourceTable = "pganalyze.get_stat_replication()"
} else {
if c.Config.SystemType != "heroku" && !c.ConnectedAsSuperUser && !c.ConnectedAsMonitoringRole {
c.Logger.PrintInfo("Warning: You are not connecting as superuser. Please setup" +
" the monitoring helper functions (https://pganalyze.com/docs/install/aiven/01_create_monitoring_user)" +
" or connect as superuser, to get replication statistics.")
c.Logger.PrintInfo("Warning: Monitoring user may have insufficient permissions to retrieve replication statistics.\n" +
"You are not connecting as a user with the pg_monitor role or a superuser." +
" Please make sure the monitoring user used by the collector has been granted the pg_monitor role or is a superuser.")
if c.Config.SystemType == "aiven" {
c.Logger.PrintInfo("For Aiven, you can also set up the monitoring helper functions (https://pganalyze.com/docs/install/aiven/01_create_monitoring_user).")
}
}
sourceTable = "pg_stat_replication"
}
Expand Down
15 changes: 9 additions & 6 deletions input/postgres/statements.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,12 +168,15 @@ func GetStatements(ctx context.Context, c *Collection, db *sql.DB, showtext bool
} else {
if c.Config.SystemType != "heroku" && !c.ConnectedAsSuperUser && !c.ConnectedAsMonitoringRole && c.GlobalOpts.TestRun {
c.SelfTest.MarkCollectionAspectWarning(state.CollectionAspectPgStatStatements, "monitoring user may have insufficient permissions to capture all queries")
c.SelfTest.HintCollectionAspect(state.CollectionAspectPgStatStatements, "Please set up"+
" the monitoring helper functions (%s)"+
" or connect as superuser to get query statistics for all roles.", selftest.URLPrinter.Sprint("https://pganalyze.com/docs/install/aiven/03_create_pg_stat_statements_helpers"))
c.Logger.PrintInfo("Warning: You are not connecting as superuser. Please setup" +
" the monitoring helper functions (https://pganalyze.com/docs/install/aiven/03_create_pg_stat_statements_helpers)" +
" or connect as superuser, to get query statistics for all roles.")
c.SelfTest.HintCollectionAspect(state.CollectionAspectPgStatStatements, "Please make sure the monitoring user used by the collector has been granted the pg_monitor role or is a superuser.")
c.Logger.PrintInfo("Warning: Monitoring user may have insufficient permissions to capture all queries.\n" +
"You are not connecting as a superuser." +
" Please make sure the monitoring user used by the collector has been granted the pg_monitor role or is a superuser in order to get query statistics for all roles.")
if c.Config.SystemType == "aiven" {
docsLink := "https://pganalyze.com/docs/install/aiven/03_create_pg_stat_statements_helpers"
c.SelfTest.HintCollectionAspect(state.CollectionAspectPgStatStatements, "For aiven, you can also set up the monitoring helper functions (%s).", selftest.URLPrinter.Sprint(docsLink))
c.Logger.PrintInfo("For Aiven, you can also set up the monitoring helper functions (%s).", docsLink)
}
}
if !showtext {
sourceTable = extSchema + ".pg_stat_statements(false)"
Expand Down
Loading