Skip to content

Commit

Permalink
Merge branch 'main' into v3
Browse files Browse the repository at this point in the history
  • Loading branch information
ademidoff committed Mar 7, 2024
2 parents ae1b2f5 + 4879e9c commit 2a46e6a
Show file tree
Hide file tree
Showing 46 changed files with 2,532 additions and 2,128 deletions.
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 PostgreSQL instance that exporter can use (default: server-defined)"`

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
50 changes: 27 additions & 23 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: 0,
MaxExporterConnections: 0,
},
},
}, *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 Expand Up @@ -667,7 +671,7 @@ func TestAddPostgreSQL(t *testing.T) {
Username: "username",
PushMetricsEnabled: true,
Status: &AgentStatusUnknown,
AutoDiscoveryLimit: 10,
AutoDiscoveryLimit: 0,
},
},
}, *listAgents.Payload)
Expand Down Expand Up @@ -742,7 +746,7 @@ func TestAddPostgreSQL(t *testing.T) {
PMMAgentID: pmmAgentID,
Username: "username",
Status: &AgentStatusUnknown,
AutoDiscoveryLimit: 10,
AutoDiscoveryLimit: 0,
},
},
}, *listAgents.Payload)
Expand Down Expand Up @@ -818,7 +822,7 @@ func TestAddPostgreSQL(t *testing.T) {
Username: "username",
PushMetricsEnabled: true,
Status: &AgentStatusUnknown,
AutoDiscoveryLimit: 10,
AutoDiscoveryLimit: 0,
},
},
}, *listAgents.Payload)
Expand Down
Loading

0 comments on commit 2a46e6a

Please sign in to comment.