Skip to content
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

PMM-12894 Add max conneсtions config support for PG exporter #2837

Merged
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
0d0c219
PMM-12894 Add max conn support for PG services
artemgavrilov Feb 21, 2024
c052138
Merge remote-tracking branch 'origin/main' into PMM-12894-rolling-col…
artemgavrilov Feb 21, 2024
4c92115
PMM-12894 Renaming
artemgavrilov Feb 22, 2024
065fbb6
Merge remote-tracking branch 'origin/main' into PMM-12894-rolling-col…
artemgavrilov Feb 22, 2024
633a9b2
PMM-12894 Add exporter configuration tests
artemgavrilov Feb 22, 2024
6069842
Refactoring
artemgavrilov Feb 22, 2024
140a73d
PMM-12894 Add tests
artemgavrilov Feb 22, 2024
5ac590d
PMM-12894 Fix api tests
artemgavrilov Feb 22, 2024
c2affb0
PMM-12894 Fix
artemgavrilov Feb 22, 2024
b2ee56d
Merge remote-tracking branch 'origin/main' into PMM-12894-rolling-col…
artemgavrilov Feb 26, 2024
198c9ec
Merge branch 'main' into PMM-12894-rolling-collection-strategy-for-PG…
artemgavrilov Feb 26, 2024
188d31c
Update managed/services/agents/postgresql_test.go
artemgavrilov Feb 27, 2024
bff943d
PMM-12894 Remove redundant defaults conf
artemgavrilov Feb 27, 2024
e58b701
Merge branch 'main' into PMM-12894-rolling-collection-strategy-for-PG…
artemgavrilov Feb 27, 2024
713b159
PMM-12894 Improvements and fixes
artemgavrilov Feb 29, 2024
dae2bd0
Merge remote-tracking branch 'origin/main' into PMM-12894-rolling-col…
artemgavrilov Feb 29, 2024
c8f9a7c
PMM-12894 Fix parameter description
artemgavrilov Feb 29, 2024
a690e10
PMM-12894 Add max conn parameter to RDS
artemgavrilov Feb 29, 2024
a350f23
Merge branch 'main' into PMM-12894-rolling-collection-strategy-for-PG…
artemgavrilov Mar 1, 2024
7cb283b
Merge branch 'main' into PMM-12894-rolling-collection-strategy-for-PG…
artemgavrilov Mar 5, 2024
c8ae463
Merge branch 'main' into PMM-12894-rolling-collection-strategy-for-PG…
artemgavrilov Mar 6, 2024
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
50 changes: 26 additions & 24 deletions admin/commands/management/add_postgresql.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,24 +61,25 @@ type AddPostgreSQLCommand struct {
NodeID string `help:"Node ID (default is autodetected)"`
PMMAgentID string `help:"The pmm-agent identifier which runs this instance (default is autodetected)"`
// TODO add "auto"
QuerySource string `default:"pgstatmonitor" help:"Source of SQL queries, one of: pgstatements, pgstatmonitor, none (default: pgstatmonitor)"`
Environment string `help:"Environment name"`
Cluster string `help:"Cluster name"`
ReplicationSet string `help:"Replication set name"`
CustomLabels map[string]string `mapsep:"," help:"Custom user-assigned labels"`
SkipConnectionCheck bool `help:"Skip connection check"`
CommentsParsing string `enum:"on,off" default:"off" help:"Enable/disable parsing comments from queries. One of: [on, off]"`
TLS bool `help:"Use TLS to connect to the database"`
TLSCAFile string `name:"tls-ca-file" help:"TLS CA certificate file"`
TLSCertFile string `help:"TLS certificate file"`
TLSKeyFile string `help:"TLS certificate key file"`
TLSSkipVerify bool `help:"Skip TLS certificates validation"`
MaxQueryLength int32 `placeholder:"NUMBER" help:"Limit query length in QAN (default: server-defined; -1: no limit)"`
DisableQueryExamples bool `name:"disable-queryexamples" help:"Disable collection of query examples"`
MetricsMode string `enum:"${metricsModesEnum}" default:"auto" help:"Metrics flow mode, can be push - agent will push metrics, pull - server scrape metrics from agent or auto - chosen by server"`
DisableCollectors []string `help:"Comma-separated list of collector names to exclude from exporter"`
ExposeExporter bool `name:"expose-exporter" help:"Optionally expose the address of the exporter publicly on 0.0.0.0"`
AutoDiscoveryLimit int32 `default:"0" placeholder:"NUMBER" help:"Auto-discovery will be disabled if there are more than that number of databases (default: server-defined, -1: always disabled)"`
QuerySource string `default:"pgstatmonitor" help:"Source of SQL queries, one of: pgstatements, pgstatmonitor, none (default: pgstatmonitor)"`
Environment string `help:"Environment name"`
Cluster string `help:"Cluster name"`
ReplicationSet string `help:"Replication set name"`
CustomLabels map[string]string `mapsep:"," help:"Custom user-assigned labels"`
SkipConnectionCheck bool `help:"Skip connection check"`
CommentsParsing string `enum:"on,off" default:"off" help:"Enable/disable parsing comments from queries. One of: [on, off]"`
TLS bool `help:"Use TLS to connect to the database"`
TLSCAFile string `name:"tls-ca-file" help:"TLS CA certificate file"`
TLSCertFile string `help:"TLS certificate file"`
TLSKeyFile string `help:"TLS certificate key file"`
TLSSkipVerify bool `help:"Skip TLS certificates validation"`
MaxQueryLength int32 `placeholder:"NUMBER" help:"Limit query length in QAN (default: server-defined; -1: no limit)"`
DisableQueryExamples bool `name:"disable-queryexamples" help:"Disable collection of query examples"`
MetricsMode string `enum:"${metricsModesEnum}" default:"auto" help:"Metrics flow mode, can be push - agent will push metrics, pull - server scrape metrics from agent or auto - chosen by server"`
DisableCollectors []string `help:"Comma-separated list of collector names to exclude from exporter"`
ExposeExporter bool `name:"expose-exporter" help:"Optionally expose the address of the exporter publicly on 0.0.0.0"`
AutoDiscoveryLimit int32 `placeholder:"NUMBER" help:"Auto-discovery will be disabled if there are more than that number of databases (default: server-defined, -1: always disabled)"`
MaxExporterConnections int32 `placeholder:"NUMBER" help:"Maximum number of connections to the exporter (default: server-defined)"`
artemgavrilov marked this conversation as resolved.
Show resolved Hide resolved

AddCommonFlags
AddLogLevelNoFatalFlags
Expand Down Expand Up @@ -211,12 +212,13 @@ func (cmd *AddPostgreSQLCommand) RunCmd() (commands.Result, error) {
TLSKey: tlsKey,
TLSSkipVerify: cmd.TLSSkipVerify,

MaxQueryLength: cmd.MaxQueryLength,
DisableQueryExamples: cmd.DisableQueryExamples,
MetricsMode: pointer.ToString(strings.ToUpper(cmd.MetricsMode)),
DisableCollectors: commands.ParseDisableCollectors(cmd.DisableCollectors),
AutoDiscoveryLimit: cmd.AutoDiscoveryLimit,
LogLevel: &cmd.AddLogLevel,
MaxQueryLength: cmd.MaxQueryLength,
DisableQueryExamples: cmd.DisableQueryExamples,
MetricsMode: pointer.ToString(strings.ToUpper(cmd.MetricsMode)),
DisableCollectors: commands.ParseDisableCollectors(cmd.DisableCollectors),
AutoDiscoveryLimit: cmd.AutoDiscoveryLimit,
MaxExporterConnections: cmd.MaxExporterConnections,
LogLevel: &cmd.AddLogLevel,
},
Context: commands.Ctx,
}
Expand Down
22 changes: 13 additions & 9 deletions api-tests/inventory/agents_postgres_exporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ func TestPostgresExporter(t *testing.T) {
"custom_label_postgres_exporter": "postgres_exporter",
},

SkipConnectionCheck: true,
SkipConnectionCheck: true,
MaxExporterConnections: 10,
})
agentID := PostgresExporter.PostgresExporter.AgentID
defer pmmapitests.RemoveAgents(t, agentID)
Expand All @@ -83,7 +84,8 @@ func TestPostgresExporter(t *testing.T) {
CustomLabels: map[string]string{
"custom_label_postgres_exporter": "postgres_exporter",
},
Status: &AgentStatusUnknown,
Status: &AgentStatusUnknown,
MaxExporterConnections: 10,
},
},
}, getAgentRes)
Expand All @@ -103,12 +105,13 @@ func TestPostgresExporter(t *testing.T) {
assert.Equal(t, &agents.ChangePostgresExporterOK{
Payload: &agents.ChangePostgresExporterOKBody{
PostgresExporter: &agents.ChangePostgresExporterOKBodyPostgresExporter{
AgentID: agentID,
ServiceID: serviceID,
Username: "username",
PMMAgentID: pmmAgentID,
Disabled: true,
Status: &AgentStatusUnknown,
AgentID: agentID,
ServiceID: serviceID,
Username: "username",
PMMAgentID: pmmAgentID,
Disabled: true,
Status: &AgentStatusUnknown,
MaxExporterConnections: 10,
},
},
}, changePostgresExporterOK)
Expand Down Expand Up @@ -137,7 +140,8 @@ func TestPostgresExporter(t *testing.T) {
CustomLabels: map[string]string{
"new_label": "postgres_exporter",
},
Status: &AgentStatusUnknown,
Status: &AgentStatusUnknown,
MaxExporterConnections: 10,
},
},
}, changePostgresExporterOK)
Expand Down
44 changes: 24 additions & 20 deletions api-tests/management/postgresql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,10 @@ func TestAddPostgreSQL(t *testing.T) {
Port: 5432,
Username: "username",

SkipConnectionCheck: true,
DisableCollectors: []string{"custom_query.ml", "custom_query.mr.directory"},
AutoDiscoveryLimit: 0,
SkipConnectionCheck: true,
DisableCollectors: []string{"custom_query.ml", "custom_query.mr.directory"},
AutoDiscoveryLimit: 0,
MaxExporterConnections: 0,
},
}
addPostgreSQLOK, err := client.Default.PostgreSQL.AddPostgreSQL(params)
Expand Down Expand Up @@ -100,14 +101,15 @@ func TestAddPostgreSQL(t *testing.T) {
assert.Equal(t, agents.ListAgentsOKBody{
PostgresExporter: []*agents.ListAgentsOKBodyPostgresExporterItems0{
{
AgentID: listAgents.Payload.PostgresExporter[0].AgentID,
ServiceID: serviceID,
PMMAgentID: pmmAgentID,
Username: "username",
DisabledCollectors: []string{"custom_query.ml", "custom_query.mr.directory"},
PushMetricsEnabled: true,
Status: &AgentStatusUnknown,
AutoDiscoveryLimit: 10,
AgentID: listAgents.Payload.PostgresExporter[0].AgentID,
ServiceID: serviceID,
PMMAgentID: pmmAgentID,
Username: "username",
DisabledCollectors: []string{"custom_query.ml", "custom_query.mr.directory"},
PushMetricsEnabled: true,
Status: &AgentStatusUnknown,
AutoDiscoveryLimit: 10,
MaxExporterConnections: 0,
artemgavrilov marked this conversation as resolved.
Show resolved Hide resolved
},
},
}, *listAgents.Payload)
Expand Down Expand Up @@ -139,8 +141,9 @@ func TestAddPostgreSQL(t *testing.T) {
QANPostgresqlPgstatmonitorAgent: true,
DisableQueryExamples: true,

SkipConnectionCheck: true,
AutoDiscoveryLimit: 15,
SkipConnectionCheck: true,
AutoDiscoveryLimit: 15,
MaxExporterConnections: 10,
},
}
addPostgreSQLOK, err := client.Default.PostgreSQL.AddPostgreSQL(params)
Expand Down Expand Up @@ -186,13 +189,14 @@ func TestAddPostgreSQL(t *testing.T) {
assert.Equal(t, agents.ListAgentsOKBody{
PostgresExporter: []*agents.ListAgentsOKBodyPostgresExporterItems0{
{
AgentID: listAgents.Payload.PostgresExporter[0].AgentID,
ServiceID: serviceID,
PMMAgentID: pmmAgentID,
Username: "username",
PushMetricsEnabled: true,
Status: &AgentStatusUnknown,
AutoDiscoveryLimit: 15,
AgentID: listAgents.Payload.PostgresExporter[0].AgentID,
ServiceID: serviceID,
PMMAgentID: pmmAgentID,
Username: "username",
PushMetricsEnabled: true,
Status: &AgentStatusUnknown,
AutoDiscoveryLimit: 15,
MaxExporterConnections: 10,
},
},
QANPostgresqlPgstatementsAgent: []*agents.ListAgentsOKBodyQANPostgresqlPgstatementsAgentItems0{
Expand Down
Loading
Loading