app/vmagent/remotewrite: do not show -remoteWrite.url in logs if -remoteWrite.showURL isn't set

Updates https://github.com/VictoriaMetrics/VictoriaMetrics/issues/773
This commit is contained in:
Aliaksandr Valialkin 2020-09-29 19:48:53 +03:00
parent f7636b0342
commit 127537d631
3 changed files with 9 additions and 5 deletions

View file

@ -61,6 +61,7 @@ func main() {
flag.CommandLine.SetOutput(os.Stdout)
flag.Usage = usage
envflag.Parse()
remotewrite.InitSecretFlags()
buildinfo.Init()
logger.Init()
cgroup.UpdateGOMAXPROCSToCPUQuota()

View file

@ -45,6 +45,14 @@ var allRelabelConfigs atomic.Value
// since it may lead to high memory usage due to big number of buffers.
var maxQueues = runtime.GOMAXPROCS(-1) * 4
// InitSecretFlags must be called after flag.Parse and before any logging.
func InitSecretFlags() {
if !*showRemoteWriteURL {
// remoteWrite.url can contain authentication codes, so hide it at `/metrics` output.
flagutil.RegisterSecretFlag("remoteWrite.url")
}
}
// Init initializes remotewrite.
//
// It must be called after flag.Parse().
@ -60,10 +68,6 @@ func Init() {
if *queues <= 0 {
*queues = 1
}
if !*showRemoteWriteURL {
// remoteWrite.url can contain authentication codes, so hide it at `/metrics` output.
flagutil.RegisterSecretFlag("remoteWrite.url")
}
initLabelsGlobal()
rcs, err := loadRelabelConfigs()
if err != nil {

View file

@ -15,7 +15,6 @@ func logAllFlags() {
lname := strings.ToLower(f.Name)
value := f.Value.String()
if flagutil.IsSecretFlag(lname) {
// Do not expose passwords and keys to prometheus.
value = "secret"
}
Infof("flag %q = %q", f.Name, value)