Skip to content

Commit 126d69d

Browse files
authored
Update messages when the monitoring user doesn't have a proper setup (#699)
Previously, when the monitoring user is neither superuser nor has pg_monitor role, we were showing error messages saying that please use a superuser or create a helper function. While this is true for Aiven, especially for "creating a helper function" guidance, it's not true for other cases and when the user hits this with other providers, the error message is confusing and make it not clear which actions to take. Update the messaging to make it clear the next action for these cases.
1 parent d856f2f commit 126d69d

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

Diff for: input/postgres/replication.go

+6-3
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,12 @@ func GetReplication(ctx context.Context, c *Collection, db *sql.DB) (state.Postg
9292
sourceTable = "pganalyze.get_stat_replication()"
9393
} else {
9494
if c.Config.SystemType != "heroku" && !c.ConnectedAsSuperUser && !c.ConnectedAsMonitoringRole {
95-
c.Logger.PrintInfo("Warning: You are not connecting as superuser. Please setup" +
96-
" the monitoring helper functions (https://pganalyze.com/docs/install/aiven/01_create_monitoring_user)" +
97-
" or connect as superuser, to get replication statistics.")
95+
c.Logger.PrintInfo("Warning: Monitoring user may have insufficient permissions to retrieve replication statistics.\n" +
96+
"You are not connecting as a user with the pg_monitor role or a superuser." +
97+
" Please make sure the monitoring user used by the collector has been granted the pg_monitor role or is a superuser.")
98+
if c.Config.SystemType == "aiven" {
99+
c.Logger.PrintInfo("For Aiven, you can also set up the monitoring helper functions (https://pganalyze.com/docs/install/aiven/01_create_monitoring_user).")
100+
}
98101
}
99102
sourceTable = "pg_stat_replication"
100103
}

Diff for: input/postgres/statements.go

+9-6
Original file line numberDiff line numberDiff line change
@@ -168,12 +168,15 @@ func GetStatements(ctx context.Context, c *Collection, db *sql.DB, showtext bool
168168
} else {
169169
if c.Config.SystemType != "heroku" && !c.ConnectedAsSuperUser && !c.ConnectedAsMonitoringRole && c.GlobalOpts.TestRun {
170170
c.SelfTest.MarkCollectionAspectWarning(state.CollectionAspectPgStatStatements, "monitoring user may have insufficient permissions to capture all queries")
171-
c.SelfTest.HintCollectionAspect(state.CollectionAspectPgStatStatements, "Please set up"+
172-
" the monitoring helper functions (%s)"+
173-
" 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"))
174-
c.Logger.PrintInfo("Warning: You are not connecting as superuser. Please setup" +
175-
" the monitoring helper functions (https://pganalyze.com/docs/install/aiven/03_create_pg_stat_statements_helpers)" +
176-
" or connect as superuser, to get query statistics for all roles.")
171+
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.")
172+
c.Logger.PrintInfo("Warning: Monitoring user may have insufficient permissions to capture all queries.\n" +
173+
"You are not connecting as a superuser." +
174+
" 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.")
175+
if c.Config.SystemType == "aiven" {
176+
docsLink := "https://pganalyze.com/docs/install/aiven/03_create_pg_stat_statements_helpers"
177+
c.SelfTest.HintCollectionAspect(state.CollectionAspectPgStatStatements, "For aiven, you can also set up the monitoring helper functions (%s).", selftest.URLPrinter.Sprint(docsLink))
178+
c.Logger.PrintInfo("For Aiven, you can also set up the monitoring helper functions (%s).", docsLink)
179+
}
177180
}
178181
if !showtext {
179182
sourceTable = extSchema + ".pg_stat_statements(false)"

0 commit comments

Comments
 (0)