diff --git a/go.mod b/go.mod index eda6fe9dee..dbf04d6aea 100644 --- a/go.mod +++ b/go.mod @@ -36,7 +36,7 @@ require ( github.com/minio/minio-go/v7 v7.0.27 github.com/percona-platform/dbaas-api v0.0.0-20220110092915-5aacd784d472 github.com/percona-platform/saas v0.0.0-20220427162947-f9d246ad0f16 - github.com/percona/pmm v0.0.0-20220520150831-23069cdf1bb8 + github.com/percona/pmm v0.0.0-20220601235657-42d659733aa3 github.com/percona/promconfig v0.2.4-0.20211110115058-98687f586f54 github.com/pkg/errors v0.9.1 github.com/pmezard/go-difflib v1.0.0 @@ -128,8 +128,8 @@ require ( github.com/shopspring/decimal v1.3.1 // indirect github.com/shurcooL/httpfs v0.0.0-20190707220628-8d4bc4ba7749 // indirect github.com/shurcooL/vfsgen v0.0.0-20200824052919-0d455de96546 // indirect - github.com/stretchr/objx v0.3.0 // indirect - go.mongodb.org/mongo-driver v1.9.0 // indirect + github.com/stretchr/objx v0.4.0 // indirect + go.mongodb.org/mongo-driver v1.9.1 // indirect go.opentelemetry.io/otel v1.7.0 // indirect go.opentelemetry.io/otel/trace v1.7.0 // indirect golang.org/x/mod v0.5.1 // indirect diff --git a/go.sum b/go.sum index 3b9f6e86f1..1d2b65ca0a 100644 --- a/go.sum +++ b/go.sum @@ -468,8 +468,8 @@ github.com/percona-platform/dbaas-api v0.0.0-20220110092915-5aacd784d472 h1:Henk github.com/percona-platform/dbaas-api v0.0.0-20220110092915-5aacd784d472/go.mod h1:WZZ3Hi+lAWCaGWmsrfkkvRQPkIa8n1OZ0s8Su+vbgus= github.com/percona-platform/saas v0.0.0-20220427162947-f9d246ad0f16 h1:0fx16uGtl4MwrBwm9/VSoNEhjL0cXYxS0quEhLthGcc= github.com/percona-platform/saas v0.0.0-20220427162947-f9d246ad0f16/go.mod h1:gFUwaFp6Ugu5qsBwiOVJYbDlzgZ77tmXdXGO7tG5xVI= -github.com/percona/pmm v0.0.0-20220520150831-23069cdf1bb8 h1:P5iuV4GRUIviRg/5/FM6ZOKdiBPdwUPbrHld/epM3hk= -github.com/percona/pmm v0.0.0-20220520150831-23069cdf1bb8/go.mod h1:gr+WLd8clEAe2xMFgsGhpw9ziZc2UCWcfy6d3M6Aq00= +github.com/percona/pmm v0.0.0-20220601235657-42d659733aa3 h1:UYp4XhqiDl89a6qKNBoblzGZy/1MAo7c0rFnxJsQ12w= +github.com/percona/pmm v0.0.0-20220601235657-42d659733aa3/go.mod h1:xgPCsAjF+4K3llSsv5kwqFw3ig/1zPt9kEq9d4WMHMA= github.com/percona/promconfig v0.2.4-0.20211110115058-98687f586f54 h1:aI1emmycDTGWKsBdxFPKZqohfBbK4y2ta9G4+RX7gVg= github.com/percona/promconfig v0.2.4-0.20211110115058-98687f586f54/go.mod h1:Y2uXi5QNk71+ceJHuI9poank+0S1kjxd3K105fXKVkg= github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= @@ -551,8 +551,8 @@ github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3 github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.3.0 h1:NGXK3lHquSN08v5vWalVI/L8XU9hdzE/G6xsrze47As= -github.com/stretchr/objx v0.3.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= +github.com/stretchr/objx v0.4.0 h1:M2gUjqZET1qApGOWNSnZ49BAIMX4F/1plDv3+l31EJ4= +github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= @@ -580,8 +580,8 @@ github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1 go.mongodb.org/mongo-driver v1.7.3/go.mod h1:NqaYOwnXWr5Pm7AOpO5QFxKJ503nbMse/R79oO62zWg= go.mongodb.org/mongo-driver v1.7.5/go.mod h1:VXEWRZ6URJIkUq2SCAyapmhH0ZLRBP+FT4xhp5Zvxng= go.mongodb.org/mongo-driver v1.8.3/go.mod h1:0sQWfOeY63QTntERDJJ/0SuKK0T1uVSgKCuAROlKEPY= -go.mongodb.org/mongo-driver v1.9.0 h1:f3aLGJvQmBl8d9S40IL+jEyBC6hfLPbJjv9t5hEM9ck= -go.mongodb.org/mongo-driver v1.9.0/go.mod h1:0sQWfOeY63QTntERDJJ/0SuKK0T1uVSgKCuAROlKEPY= +go.mongodb.org/mongo-driver v1.9.1 h1:m078y9v7sBItkt1aaoe2YlvWEXcD263e1a4E1fBrJ1c= +go.mongodb.org/mongo-driver v1.9.1/go.mod h1:0sQWfOeY63QTntERDJJ/0SuKK0T1uVSgKCuAROlKEPY= go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= diff --git a/models/agent_helpers.go b/models/agent_helpers.go index cc9a29a497..220ac88f60 100644 --- a/models/agent_helpers.go +++ b/models/agent_helpers.go @@ -545,6 +545,7 @@ func CreateNodeExporter(q *reform.Querier, pushMetrics bool, disableCollectors []string, agentPassword *string, + logLevel string, ) (*Agent, error) { // TODO merge into CreateAgent @@ -569,6 +570,7 @@ func CreateNodeExporter(q *reform.Querier, PushMetrics: pushMetrics, DisabledCollectors: disableCollectors, AgentPassword: agentPassword, + LogLevel: pointer.ToStringOrNil(logLevel), } if err := row.SetCustomLabels(customLabels); err != nil { return nil, err diff --git a/models/database.go b/models/database.go index 2b7aa7efe5..a4de2d8a74 100644 --- a/models/database.go +++ b/models/database.go @@ -903,7 +903,7 @@ func setupFixture1(q *reform.Querier, username, password string) error { if _, err = createPMMAgentWithID(q, PMMServerAgentID, node.NodeID, nil); err != nil { return err } - if _, err = CreateNodeExporter(q, PMMServerAgentID, nil, false, []string{}, nil); err != nil { + if _, err = CreateNodeExporter(q, PMMServerAgentID, nil, false, []string{}, nil, ""); err != nil { return err } diff --git a/services/agents/azure_database.go b/services/agents/azure_database.go index 4395f13dc4..465d019659 100644 --- a/services/agents/azure_database.go +++ b/services/agents/azure_database.go @@ -22,6 +22,7 @@ import ( "github.com/percona/pmm/api/agentpb" "github.com/percona/pmm/api/inventorypb" + "github.com/percona/pmm/version" "github.com/pkg/errors" "github.com/percona/pmm-managed/models" @@ -53,7 +54,9 @@ resource_groups: ` // azureDatabaseExporterConfig returns configuration of azure_database_exporter process. -func azureDatabaseExporterConfig(exporter *models.Agent, service *models.Service, redactMode redactMode) (*agentpb.SetStateRequest_AgentProcess, error) { +func azureDatabaseExporterConfig(exporter *models.Agent, service *models.Service, redactMode redactMode, + pmmAgentVersion *version.Parsed, +) (*agentpb.SetStateRequest_AgentProcess, error) { t, err := template.New("credentials").Parse(azureDatabaseTemplate) if err != nil { return nil, err @@ -95,6 +98,7 @@ func azureDatabaseExporterConfig(exporter *models.Agent, service *models.Service "--config.file=" + tdp.Left + " .TextFiles.config " + tdp.Right, "--web.listen-address=:" + tdp.Left + " .listen_port " + tdp.Right, } + args = withLogLevel(args, exporter.LogLevel, pmmAgentVersion) return &agentpb.SetStateRequest_AgentProcess{ Type: inventorypb.AgentType_AZURE_DATABASE_EXPORTER, diff --git a/services/agents/azure_database_test.go b/services/agents/azure_database_test.go index 2d53a851df..bc00835711 100644 --- a/services/agents/azure_database_test.go +++ b/services/agents/azure_database_test.go @@ -23,12 +23,15 @@ import ( "github.com/AlekSi/pointer" "github.com/percona/pmm/api/agentpb" "github.com/percona/pmm/api/inventorypb" + "github.com/percona/pmm/version" "github.com/stretchr/testify/require" "github.com/percona/pmm-managed/models" ) func TestAzureExporterConfig(t *testing.T) { + pmmAgentVersion := version.MustParse("2.28.0") + node1 := &models.Node{ NodeID: "/node_id/node1", NodeType: models.RemoteAzureDatabaseNodeType, @@ -66,7 +69,7 @@ func TestAzureExporterConfig(t *testing.T) { }, } - actual, err := azureDatabaseExporterConfig(agent, service1, redactSecrets) + actual, err := azureDatabaseExporterConfig(agent, service1, redactSecrets, pmmAgentVersion) require.NoError(t, err) expected := &agentpb.SetStateRequest_AgentProcess{ Type: inventorypb.AgentType_AZURE_DATABASE_EXPORTER, diff --git a/services/agents/node.go b/services/agents/node.go index 6d5a4589e3..c6012662f7 100644 --- a/services/agents/node.go +++ b/services/agents/node.go @@ -130,6 +130,8 @@ func nodeExporterConfig(node *models.Node, exporter *models.Agent, agentVersion args = append(args, "--web.telemetry-path="+*exporter.MetricsPath) } + args = withLogLevel(args, exporter.LogLevel, agentVersion) + sort.Strings(args) params := &agentpb.SetStateRequest_AgentProcess{ diff --git a/services/agents/rds.go b/services/agents/rds.go index ea11c30b0c..adbfc0fa38 100644 --- a/services/agents/rds.go +++ b/services/agents/rds.go @@ -22,6 +22,7 @@ import ( "github.com/AlekSi/pointer" "github.com/percona/pmm/api/agentpb" "github.com/percona/pmm/api/inventorypb" + "github.com/percona/pmm/version" "github.com/pkg/errors" "github.com/prometheus/common/model" "gopkg.in/yaml.v3" @@ -66,7 +67,9 @@ func mergeLabels(node *models.Node, agent *models.Agent) (model.LabelSet, error) } // rdsExporterConfig returns desired configuration of rds_exporter process. -func rdsExporterConfig(pairs map[*models.Node]*models.Agent, redactMode redactMode) (*agentpb.SetStateRequest_AgentProcess, error) { +func rdsExporterConfig(pairs map[*models.Node]*models.Agent, redactMode redactMode, + pmmAgentVersion *version.Parsed, +) (*agentpb.SetStateRequest_AgentProcess, error) { config := rdsExporterConfigFile{ Instances: make([]rdsInstance, 0, len(pairs)), } @@ -114,6 +117,9 @@ func rdsExporterConfig(pairs map[*models.Node]*models.Agent, redactMode redactMo "--web.listen-address=:" + tdp.Left + " .listen_port " + tdp.Right, "--config.file=" + tdp.Left + " .TextFiles.config " + tdp.Right, } + + args = withLogLevel(args, toOneLogLevel(pairs), pmmAgentVersion) + sort.Strings(args) b, err := yaml.Marshal(config) @@ -132,3 +138,27 @@ func rdsExporterConfig(pairs map[*models.Node]*models.Agent, redactMode redactMo RedactWords: words, }, nil } + +// toOneLogLevel returns first if all equals. +func toOneLogLevel(pairs map[*models.Node]*models.Agent) *string { + var ( + logLevel *string + logLevelFirst bool + ) + + for _, exporter := range pairs { + if !logLevelFirst { + logLevel = exporter.LogLevel + + logLevelFirst = true + + continue + } + + if pointer.GetString(logLevel) != pointer.GetString(exporter.LogLevel) { + return nil + } + } + + return logLevel +} diff --git a/services/agents/rds_test.go b/services/agents/rds_test.go index a8c005bfbd..e06df0af39 100644 --- a/services/agents/rds_test.go +++ b/services/agents/rds_test.go @@ -23,12 +23,15 @@ import ( "github.com/AlekSi/pointer" "github.com/percona/pmm/api/agentpb" "github.com/percona/pmm/api/inventorypb" + "github.com/percona/pmm/version" "github.com/stretchr/testify/require" "github.com/percona/pmm-managed/models" ) func TestRDSExporterConfig(t *testing.T) { + pmmAgentVersion := version.MustParse("2.28.0") + node1 := &models.Node{ NodeID: "/node_id/node1", NodeType: models.RemoteRDSNodeType, @@ -76,7 +79,7 @@ func TestRDSExporterConfig(t *testing.T) { node2: agent2, node1: agent1, } - actual, err := rdsExporterConfig(pairs, redactSecrets) + actual, err := rdsExporterConfig(pairs, redactSecrets, pmmAgentVersion) require.NoError(t, err) expected := &agentpb.SetStateRequest_AgentProcess{ Type: inventorypb.AgentType_RDS_EXPORTER, diff --git a/services/agents/state.go b/services/agents/state.go index 0e571894de..a341eadb55 100644 --- a/services/agents/state.go +++ b/services/agents/state.go @@ -210,7 +210,7 @@ func (u *StateUpdater) sendSetStateRequest(ctx context.Context, agent *pmmAgentI if err != nil { return err } - config, err := azureDatabaseExporterConfig(row, service, redactMode) + config, err := azureDatabaseExporterConfig(row, service, redactMode, pmmAgentVersion) if err != nil { return err } @@ -264,7 +264,7 @@ func (u *StateUpdater) sendSetStateRequest(ctx context.Context, agent *pmmAgentI sort.Strings(rdsExporterIDs) groupID := u.r.roster.add(agent.id, rdsGroup, rdsExporterIDs) - c, err := rdsExporterConfig(rdsExporters, redactMode) + c, err := rdsExporterConfig(rdsExporters, redactMode, pmmAgentVersion) if err != nil { return err } diff --git a/services/converters.go b/services/converters.go index 9b870bf5b8..356c333dbe 100644 --- a/services/converters.go +++ b/services/converters.go @@ -237,6 +237,7 @@ func ToAPIAgent(q *reform.Querier, agent *models.Agent) (inventorypb.Agent, erro PushMetricsEnabled: agent.PushMetrics, DisabledCollectors: agent.DisabledCollectors, ProcessExecPath: processExecPath, + LogLevel: inventorypb.LogLevel(inventorypb.LogLevel_value[pointer.GetString(agent.LogLevel)]), }, nil case models.MySQLdExporterType: @@ -314,6 +315,7 @@ func ToAPIAgent(q *reform.Querier, agent *models.Agent) (inventorypb.Agent, erro TlsSkipVerify: agent.TLSSkipVerify, QueryExamplesDisabled: agent.QueryExamplesDisabled, ProcessExecPath: processExecPath, + LogLevel: inventorypb.LogLevel(inventorypb.LogLevel_value[pointer.GetString(agent.LogLevel)]), }, nil case models.QANMySQLSlowlogAgentType: @@ -330,6 +332,7 @@ func ToAPIAgent(q *reform.Querier, agent *models.Agent) (inventorypb.Agent, erro QueryExamplesDisabled: agent.QueryExamplesDisabled, MaxSlowlogFileSize: agent.MaxQueryLogSize, ProcessExecPath: processExecPath, + LogLevel: inventorypb.LogLevel(inventorypb.LogLevel_value[pointer.GetString(agent.LogLevel)]), }, nil case models.QANMongoDBProfilerAgentType: @@ -344,6 +347,7 @@ func ToAPIAgent(q *reform.Querier, agent *models.Agent) (inventorypb.Agent, erro Tls: agent.TLS, TlsSkipVerify: agent.TLSSkipVerify, ProcessExecPath: processExecPath, + LogLevel: inventorypb.LogLevel(inventorypb.LogLevel_value[pointer.GetString(agent.LogLevel)]), // TODO QueryExamplesDisabled https://jira.percona.com/browse/PMM-4650 }, nil @@ -377,6 +381,7 @@ func ToAPIAgent(q *reform.Querier, agent *models.Agent) (inventorypb.Agent, erro Tls: agent.TLS, TlsSkipVerify: agent.TLSSkipVerify, ProcessExecPath: processExecPath, + LogLevel: inventorypb.LogLevel(inventorypb.LogLevel_value[pointer.GetString(agent.LogLevel)]), }, nil case models.QANPostgreSQLPgStatMonitorAgentType: @@ -392,6 +397,7 @@ func ToAPIAgent(q *reform.Querier, agent *models.Agent) (inventorypb.Agent, erro TlsSkipVerify: agent.TLSSkipVerify, QueryExamplesDisabled: agent.QueryExamplesDisabled, ProcessExecPath: processExecPath, + LogLevel: inventorypb.LogLevel(inventorypb.LogLevel_value[pointer.GetString(agent.LogLevel)]), }, nil case models.RDSExporterType: @@ -408,6 +414,7 @@ func ToAPIAgent(q *reform.Querier, agent *models.Agent) (inventorypb.Agent, erro EnhancedMetricsDisabled: agent.RDSEnhancedMetricsDisabled, PushMetricsEnabled: agent.PushMetrics, ProcessExecPath: processExecPath, + LogLevel: inventorypb.LogLevel(inventorypb.LogLevel_value[pointer.GetString(agent.LogLevel)]), }, nil case models.ExternalExporterType: @@ -443,6 +450,7 @@ func ToAPIAgent(q *reform.Querier, agent *models.Agent) (inventorypb.Agent, erro ListenPort: uint32(pointer.GetUint16(agent.ListenPort)), CustomLabels: labels, ProcessExecPath: processExecPath, + LogLevel: inventorypb.LogLevel(inventorypb.LogLevel_value[pointer.GetString(agent.LogLevel)]), }, nil case models.VMAgentType: @@ -457,3 +465,11 @@ func ToAPIAgent(q *reform.Querier, agent *models.Agent) (inventorypb.Agent, erro panic(fmt.Errorf("unhandled Agent type %s", agent.AgentType)) } } + +func SpecifyLogLevel(variant inventorypb.LogLevel) string { + if variant == inventorypb.LogLevel_auto { + return "" + } + + return variant.String() +} diff --git a/services/inventory/agents.go b/services/inventory/agents.go index d608efff49..631d7776dd 100644 --- a/services/inventory/agents.go +++ b/services/inventory/agents.go @@ -183,7 +183,7 @@ func (as *AgentsService) AddPMMAgent(ctx context.Context, req *inventorypb.AddPM func (as *AgentsService) AddNodeExporter(ctx context.Context, req *inventorypb.AddNodeExporterRequest) (*inventorypb.NodeExporter, error) { var res *inventorypb.NodeExporter e := as.db.InTransaction(func(tx *reform.TX) error { - row, err := models.CreateNodeExporter(tx.Querier, req.PmmAgentId, req.CustomLabels, req.PushMetrics, req.DisableCollectors, nil) + row, err := models.CreateNodeExporter(tx.Querier, req.PmmAgentId, req.CustomLabels, req.PushMetrics, req.DisableCollectors, nil, services.SpecifyLogLevel(req.LogLevel)) if err != nil { return err } @@ -233,6 +233,7 @@ func (as *AgentsService) AddMySQLdExporter(ctx context.Context, req *inventorypb TableCountTablestatsGroupLimit: req.TablestatsGroupTableLimit, PushMetrics: req.PushMetrics, DisableCollectors: req.DisableCollectors, + LogLevel: services.SpecifyLogLevel(req.LogLevel), } var err error row, err = models.CreateAgent(tx.Querier, models.MySQLdExporterType, params) @@ -293,6 +294,7 @@ func (as *AgentsService) AddMongoDBExporter(ctx context.Context, req *inventoryp MongoDBOptions: models.MongoDBOptionsFromRequest(req), PushMetrics: req.PushMetrics, DisableCollectors: req.DisableCollectors, + LogLevel: services.SpecifyLogLevel(req.LogLevel), } row, err := models.CreateAgent(tx.Querier, models.MongoDBExporterType, params) if err != nil { @@ -351,6 +353,7 @@ func (as *AgentsService) AddQANMySQLPerfSchemaAgent(ctx context.Context, req *in TLSSkipVerify: req.TlsSkipVerify, MySQLOptions: models.MySQLOptionsFromRequest(req), QueryExamplesDisabled: req.DisableQueryExamples, + LogLevel: services.SpecifyLogLevel(req.LogLevel), } row, err := models.CreateAgent(tx.Querier, models.QANMySQLPerfSchemaAgentType, params) if err != nil { @@ -416,6 +419,7 @@ func (as *AgentsService) AddQANMySQLSlowlogAgent(ctx context.Context, req *inven MySQLOptions: models.MySQLOptionsFromRequest(req), QueryExamplesDisabled: req.DisableQueryExamples, MaxQueryLogSize: maxSlowlogFileSize, + LogLevel: services.SpecifyLogLevel(req.LogLevel), } row, err := models.CreateAgent(tx.Querier, models.QANMySQLSlowlogAgentType, params) if err != nil { @@ -475,6 +479,7 @@ func (as *AgentsService) AddPostgresExporter(ctx context.Context, req *inventory PushMetrics: req.PushMetrics, DisableCollectors: req.DisableCollectors, PostgreSQLOptions: models.PostgreSQLOptionsFromRequest(req), + LogLevel: services.SpecifyLogLevel(req.LogLevel), } row, err := models.CreateAgent(tx.Querier, models.PostgresExporterType, params) if err != nil { @@ -533,6 +538,7 @@ func (as *AgentsService) AddQANMongoDBProfilerAgent(ctx context.Context, req *in TLS: req.Tls, TLSSkipVerify: req.TlsSkipVerify, MongoDBOptions: models.MongoDBOptionsFromRequest(req), + LogLevel: services.SpecifyLogLevel(req.LogLevel), // TODO QueryExamplesDisabled https://jira.percona.com/browse/PMM-4650 } row, err := models.CreateAgent(tx.Querier, models.QANMongoDBProfilerAgentType, params) @@ -593,6 +599,7 @@ func (as *AgentsService) AddProxySQLExporter(ctx context.Context, req *inventory TLSSkipVerify: req.TlsSkipVerify, PushMetrics: req.PushMetrics, DisableCollectors: req.DisableCollectors, + LogLevel: services.SpecifyLogLevel(req.LogLevel), } row, err := models.CreateAgent(tx.Querier, models.ProxySQLExporterType, params) if err != nil { @@ -650,6 +657,7 @@ func (as *AgentsService) AddQANPostgreSQLPgStatementsAgent(ctx context.Context, TLS: req.Tls, TLSSkipVerify: req.TlsSkipVerify, PostgreSQLOptions: models.PostgreSQLOptionsFromRequest(req), + LogLevel: services.SpecifyLogLevel(req.LogLevel), } row, err := models.CreateAgent(tx.Querier, models.QANPostgreSQLPgStatementsAgentType, params) if err != nil { @@ -708,6 +716,7 @@ func (as *AgentsService) AddQANPostgreSQLPgStatMonitorAgent(ctx context.Context, TLS: req.Tls, TLSSkipVerify: req.TlsSkipVerify, PostgreSQLOptions: models.PostgreSQLOptionsFromRequest(req), + LogLevel: services.SpecifyLogLevel(req.LogLevel), } row, err := models.CreateAgent(tx.Querier, models.QANPostgreSQLPgStatMonitorAgentType, params) if err != nil { @@ -764,6 +773,7 @@ func (as *AgentsService) AddRDSExporter(ctx context.Context, req *inventorypb.Ad RDSBasicMetricsDisabled: req.DisableBasicMetrics, RDSEnhancedMetricsDisabled: req.DisableEnhancedMetrics, PushMetrics: req.PushMetrics, + LogLevel: services.SpecifyLogLevel(req.LogLevel), } row, err := models.CreateAgent(tx.Querier, models.RDSExporterType, params) if err != nil { @@ -872,6 +882,7 @@ func (as *AgentsService) AddAzureDatabaseExporter(ctx context.Context, req *inve AzureOptions: models.AzureOptionsFromRequest(req), CustomLabels: req.CustomLabels, PushMetrics: req.PushMetrics, + LogLevel: services.SpecifyLogLevel(req.LogLevel), } row, err := models.CreateAgent(tx.Querier, models.AzureDatabaseExporterType, params) if err != nil { diff --git a/services/management/management.go b/services/management/management.go index 3f56ea89df..32fc3061bb 100644 --- a/services/management/management.go +++ b/services/management/management.go @@ -132,14 +132,6 @@ func isPushMode(variant managementpb.MetricsMode) bool { return variant == managementpb.MetricsMode_PUSH || variant == managementpb.MetricsMode_AUTO } -func specifyLogLevel(variant inventorypb.LogLevel) string { - if variant == inventorypb.LogLevel_auto { - return "" - } - - return variant.String() -} - // Automatically pick metrics mode. func supportedMetricsMode(q *reform.Querier, metricsMode managementpb.MetricsMode, pmmAgentID string) (managementpb.MetricsMode, error) { if pmmAgentID == models.PMMServerAgentID && metricsMode == managementpb.MetricsMode_PUSH { diff --git a/services/management/mongodb.go b/services/management/mongodb.go index 11a70c501a..77e5e5fa17 100644 --- a/services/management/mongodb.go +++ b/services/management/mongodb.go @@ -93,7 +93,7 @@ func (s *MongoDBService) Add(ctx context.Context, req *managementpb.AddMongoDBRe MongoDBOptions: mongoDBOptions, PushMetrics: isPushMode(req.MetricsMode), DisableCollectors: req.DisableCollectors, - LogLevel: specifyLogLevel(req.LogLevel), + LogLevel: services.SpecifyLogLevel(req.LogLevel), }) if err != nil { return err @@ -120,7 +120,7 @@ func (s *MongoDBService) Add(ctx context.Context, req *managementpb.AddMongoDBRe TLS: req.Tls, TLSSkipVerify: req.TlsSkipVerify, MongoDBOptions: mongoDBOptions, - LogLevel: specifyLogLevel(req.LogLevel), + LogLevel: services.SpecifyLogLevel(req.LogLevel), // TODO QueryExamplesDisabled https://jira.percona.com/browse/PMM-4650 }) if err != nil { diff --git a/services/management/mysql.go b/services/management/mysql.go index ddf6723d96..8078befb1b 100644 --- a/services/management/mysql.go +++ b/services/management/mysql.go @@ -116,7 +116,7 @@ func (s *MySQLService) Add(ctx context.Context, req *managementpb.AddMySQLReques TableCountTablestatsGroupLimit: tablestatsGroupTableLimit, PushMetrics: isPushMode(req.MetricsMode), DisableCollectors: req.DisableCollectors, - LogLevel: specifyLogLevel(req.LogLevel), + LogLevel: services.SpecifyLogLevel(req.LogLevel), }) if err != nil { return err @@ -145,7 +145,7 @@ func (s *MySQLService) Add(ctx context.Context, req *managementpb.AddMySQLReques TLSSkipVerify: req.TlsSkipVerify, MySQLOptions: models.MySQLOptionsFromRequest(req), QueryExamplesDisabled: req.DisableQueryExamples, - LogLevel: specifyLogLevel(req.LogLevel), + LogLevel: services.SpecifyLogLevel(req.LogLevel), }) if err != nil { return err @@ -169,7 +169,7 @@ func (s *MySQLService) Add(ctx context.Context, req *managementpb.AddMySQLReques MySQLOptions: models.MySQLOptionsFromRequest(req), QueryExamplesDisabled: req.DisableQueryExamples, MaxQueryLogSize: maxSlowlogFileSize, - LogLevel: specifyLogLevel(req.LogLevel), + LogLevel: services.SpecifyLogLevel(req.LogLevel), }) if err != nil { return err diff --git a/services/management/node.go b/services/management/node.go index fd57c4f125..0f7d93f1e2 100644 --- a/services/management/node.go +++ b/services/management/node.go @@ -120,7 +120,7 @@ func (s *NodeService) Register(ctx context.Context, req *managementpb.RegisterNo res.PmmAgent = a.(*inventorypb.PMMAgent) _, err = models. CreateNodeExporter(tx.Querier, pmmAgent.AgentID, nil, isPushMode(req.MetricsMode), req.DisableCollectors, - pointer.ToStringOrNil(req.AgentPassword)) + pointer.ToStringOrNil(req.AgentPassword), "") return err }); e != nil { return nil, e diff --git a/services/management/postgresql.go b/services/management/postgresql.go index f1f7988481..7f38553f78 100644 --- a/services/management/postgresql.go +++ b/services/management/postgresql.go @@ -92,7 +92,7 @@ func (s *PostgreSQLService) Add(ctx context.Context, req *managementpb.AddPostgr PushMetrics: isPushMode(req.MetricsMode), DisableCollectors: req.DisableCollectors, PostgreSQLOptions: models.PostgreSQLOptionsFromRequest(req), - LogLevel: specifyLogLevel(req.LogLevel), + LogLevel: services.SpecifyLogLevel(req.LogLevel), }) if err != nil { return err @@ -119,7 +119,7 @@ func (s *PostgreSQLService) Add(ctx context.Context, req *managementpb.AddPostgr TLS: req.Tls, TLSSkipVerify: req.TlsSkipVerify, PostgreSQLOptions: models.PostgreSQLOptionsFromRequest(req), - LogLevel: specifyLogLevel(req.LogLevel), + LogLevel: services.SpecifyLogLevel(req.LogLevel), }) if err != nil { return err @@ -142,7 +142,7 @@ func (s *PostgreSQLService) Add(ctx context.Context, req *managementpb.AddPostgr TLS: req.Tls, TLSSkipVerify: req.TlsSkipVerify, PostgreSQLOptions: models.PostgreSQLOptionsFromRequest(req), - LogLevel: specifyLogLevel(req.LogLevel), + LogLevel: services.SpecifyLogLevel(req.LogLevel), }) if err != nil { return err diff --git a/services/management/proxysql.go b/services/management/proxysql.go index 2921740026..1d58750bf4 100644 --- a/services/management/proxysql.go +++ b/services/management/proxysql.go @@ -89,7 +89,7 @@ func (s *ProxySQLService) Add(ctx context.Context, req *managementpb.AddProxySQL TLSSkipVerify: req.TlsSkipVerify, PushMetrics: isPushMode(req.MetricsMode), DisableCollectors: req.DisableCollectors, - LogLevel: specifyLogLevel(req.LogLevel), + LogLevel: services.SpecifyLogLevel(req.LogLevel), }) if err != nil { return err