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.CommandLine.SetOutput(os.Stdout)
flag.Usage = usage flag.Usage = usage
envflag.Parse() envflag.Parse()
remotewrite.InitSecretFlags()
buildinfo.Init() buildinfo.Init()
logger.Init() logger.Init()
cgroup.UpdateGOMAXPROCSToCPUQuota() 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. // since it may lead to high memory usage due to big number of buffers.
var maxQueues = runtime.GOMAXPROCS(-1) * 4 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. // Init initializes remotewrite.
// //
// It must be called after flag.Parse(). // It must be called after flag.Parse().
@ -60,10 +68,6 @@ func Init() {
if *queues <= 0 { if *queues <= 0 {
*queues = 1 *queues = 1
} }
if !*showRemoteWriteURL {
// remoteWrite.url can contain authentication codes, so hide it at `/metrics` output.
flagutil.RegisterSecretFlag("remoteWrite.url")
}
initLabelsGlobal() initLabelsGlobal()
rcs, err := loadRelabelConfigs() rcs, err := loadRelabelConfigs()
if err != nil { if err != nil {

View file

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