diff --git a/config/query_log.go b/config/query_log.go index 616ecdfd8..bb19a4a5c 100644 --- a/config/query_log.go +++ b/config/query_log.go @@ -1,6 +1,8 @@ package config import ( + "net/url" + "github.com/sirupsen/logrus" ) @@ -32,7 +34,7 @@ func (c *QueryLog) LogConfig(logger *logrus.Entry) { logger.Infof("type: %s", c.Type) if c.Target != "" { - logger.Infof("target: %s", c.Target) + logger.Infof("target: %s", c.censoredTarget()) } logger.Infof("logRetentionDays: %d", c.LogRetentionDays) @@ -41,3 +43,15 @@ func (c *QueryLog) LogConfig(logger *logrus.Entry) { logger.Infof("flushInterval: %s", c.FlushInterval) logger.Infof("fields: %s", c.Fields) } + +func (c *QueryLog) censoredTarget() string { + target, err := url.Parse(c.Target) + if err != nil || target.User == nil { + return c.Target + } + + // Drop the password + target.User = url.User(target.User.Username()) + + return target.String() +}