diff --git a/go.mod b/go.mod index 5717f730bf..904c0d2d52 100644 --- a/go.mod +++ b/go.mod @@ -38,7 +38,7 @@ require ( github.com/minio/minio-go/v7 v7.0.24 github.com/percona-platform/dbaas-api v0.0.0-20220110092915-5aacd784d472 github.com/percona-platform/saas v0.0.0-20220326163809-90f261fe195c - github.com/percona/pmm v0.0.0-20220425093801-6ff2b4fb108f + github.com/percona/pmm v0.0.0-20220427122756-c52cc545e1f3 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 diff --git a/go.sum b/go.sum index b8a8e15795..f7cc828382 100644 --- a/go.sum +++ b/go.sum @@ -465,6 +465,12 @@ 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-20220326163809-90f261fe195c h1:laB9JpVYIRclGKk596X/qJaHbchx6O/em0MugBkqPVU= github.com/percona-platform/saas v0.0.0-20220326163809-90f261fe195c/go.mod h1:gFUwaFp6Ugu5qsBwiOVJYbDlzgZ77tmXdXGO7tG5xVI= +github.com/percona/pmm v0.0.0-20220425093801-6ff2b4fb108f h1:HV3NCszjpxkVXWUJSfmT86YFWl1TFHKuAf7mM9t5szQ= +github.com/percona/pmm v0.0.0-20220425093801-6ff2b4fb108f/go.mod h1:FFbpyZXm+Ilg8M/GewuhdjJhPaW1/v1zjRRerYhCfEA= +github.com/percona/pmm v0.0.0-20220426095359-6ec19a46c5a2 h1:82QYprx2f64L08A7g0ZzkzkRlVN2NElGJh/mGsciGGQ= +github.com/percona/pmm v0.0.0-20220426095359-6ec19a46c5a2/go.mod h1:FFbpyZXm+Ilg8M/GewuhdjJhPaW1/v1zjRRerYhCfEA= +github.com/percona/pmm v0.0.0-20220427122756-c52cc545e1f3 h1:6IKHKNDNJADEN/YsvXcUiJ8M75/PW+bJZ3kMb+CL7kM= +github.com/percona/pmm v0.0.0-20220427122756-c52cc545e1f3/go.mod h1:FFbpyZXm+Ilg8M/GewuhdjJhPaW1/v1zjRRerYhCfEA= 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= diff --git a/main.go b/main.go index 4954107a6e..3b8fdd5723 100644 --- a/main.go +++ b/main.go @@ -593,20 +593,23 @@ func main() { supervisordConfigDirF := kingpin.Flag("supervisord-config-dir", "Supervisord configuration directory").Required().String() + logLevelF := kingpin.Flag("log-level", "Set logging level").Envar("PMM_LOG_LEVEL").Default("info").Enum("trace", "debug", "info", "warn", "error", "fatal") debugF := kingpin.Flag("debug", "Enable debug logging").Envar("PMM_DEBUG").Bool() - traceF := kingpin.Flag("trace", "Enable trace logging (implies debug)").Envar("PMM_TRACE").Bool() + traceF := kingpin.Flag("trace", "[DEPRECATED] Enable trace logging (implies debug)").Envar("PMM_TRACE").Bool() kingpin.Parse() logger.SetupGlobalLogger() - if *debugF { - logrus.SetLevel(logrus.DebugLevel) - } - if *traceF { - logrus.SetLevel(logrus.TraceLevel) + + level := parseLoggerConfig(*logLevelF, *debugF, *traceF) + + logrus.SetLevel(level) + + if level == logrus.TraceLevel { grpclog.SetLoggerV2(&logger.GRPC{Entry: logrus.WithField("component", "grpclog")}) logrus.SetReportCaller(true) } + logrus.Infof("Log level: %s.", logrus.GetLevel()) l := logrus.WithField("component", "main") @@ -955,3 +958,25 @@ func main() { wg.Wait() } + +func parseLoggerConfig(level string, debug, trace bool) logrus.Level { + if trace { + return logrus.TraceLevel + } + + if debug { + return logrus.DebugLevel + } + + if level != "" { + parsedLevel, err := logrus.ParseLevel(level) + + if err != nil { + logrus.Warnf("Cannot parse logging level: %s, error: %v", level, err) + } else { + return parsedLevel + } + } + + return logrus.InfoLevel +} diff --git a/services/platform/platform.go b/services/platform/platform.go index 9ee316b7db..0435e0b854 100644 --- a/services/platform/platform.go +++ b/services/platform/platform.go @@ -564,6 +564,7 @@ func (s *Service) ServerInfo(ctx context.Context, req *platformpb.ServerInfoRequ } serverName := "" + connectedToPortal := false ssoDetails, err := models.GetPerconaSSODetails(ctx, s.db.Querier) if err != nil { s.l.Errorf("failed to get SSO details: %s", err) @@ -571,11 +572,14 @@ func (s *Service) ServerInfo(ctx context.Context, req *platformpb.ServerInfoRequ if ssoDetails != nil { serverName = ssoDetails.PMMServerName + connectedToPortal = true } return &platformpb.ServerInfoResponse{ - PmmServerName: serverName, - PmmServerId: settings.PMMServerID, + PmmServerName: serverName, + PmmServerId: settings.PMMServerID, + PmmServerTelemetryId: settings.Telemetry.UUID, + ConnectedToPortal: connectedToPortal, }, nil }