From a646131a33770e618823c011c5f2a685b97666d9 Mon Sep 17 00:00:00 2001
From: Aliaksandr Valialkin <valyala@gmail.com>
Date: Sat, 30 May 2020 14:22:38 +0300
Subject: [PATCH] app/vmagent: log fatal errors instead of panics when improper
 command-line flags are passed to vmagent

---
 app/vmagent/remotewrite/client.go | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/app/vmagent/remotewrite/client.go b/app/vmagent/remotewrite/client.go
index 1da86d441c..ed126238c4 100644
--- a/app/vmagent/remotewrite/client.go
+++ b/app/vmagent/remotewrite/client.go
@@ -69,7 +69,7 @@ func newClient(argIdx int, remoteWriteURL, urlLabelValue string, fq *persistentq
 	token := bearerToken.GetOptionalArg(argIdx)
 	if len(token) > 0 {
 		if authHeader != "" {
-			logger.Panicf("FATAL: `-remoteWrite.bearerToken`=%q cannot be set when `-remoteWrite.basicAuth.*` flags are set", token)
+			logger.Fatalf("`-remoteWrite.bearerToken`=%q cannot be set when `-remoteWrite.basicAuth.*` flags are set", token)
 		}
 		authHeader = "Bearer " + token
 	}
@@ -85,11 +85,11 @@ func newClient(argIdx int, remoteWriteURL, urlLabelValue string, fq *persistentq
 	switch scheme {
 	case "http", "https":
 	default:
-		logger.Panicf("FATAL: unsupported scheme in -remoteWrite.url=%q: %q. It must be http or https", remoteWriteURL, scheme)
+		logger.Fatalf("unsupported scheme in -remoteWrite.url=%q: %q. It must be http or https", remoteWriteURL, scheme)
 	}
 	host := string(u.Host())
 	if len(host) == 0 {
-		logger.Panicf("FATAL: invalid -remoteWrite.url=%q: host cannot be empty. Make sure the url looks like `http://host:port/path`", remoteWriteURL)
+		logger.Fatalf("invalid -remoteWrite.url=%q: host cannot be empty. Make sure the url looks like `http://host:port/path`", remoteWriteURL)
 	}
 	requestURI := string(u.RequestURI())
 	isTLS := scheme == "https"