From ca856284e4ab55e163b837fbe9f573ca0cfa226b Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Fri, 11 Sep 2020 15:16:02 +0300 Subject: [PATCH] app/vmagent: allow setting multiple identical `-remoteWrite.url` values This may be useful when each url is authenticated via different `-remoteWrite.basicAuth.username`. Updates https://github.com/VictoriaMetrics/VictoriaMetrics/issues/755 --- app/vmagent/remotewrite/remotewrite.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/vmagent/remotewrite/remotewrite.go b/app/vmagent/remotewrite/remotewrite.go index 2acb2d457..498093d2d 100644 --- a/app/vmagent/remotewrite/remotewrite.go +++ b/app/vmagent/remotewrite/remotewrite.go @@ -85,7 +85,7 @@ func Init() { for i, remoteWriteURL := range *remoteWriteURLs { urlLabelValue := fmt.Sprintf("secret-url-%d", i+1) if *showRemoteWriteURL { - urlLabelValue = remoteWriteURL + urlLabelValue = fmt.Sprintf("%d:%s", i+1, remoteWriteURL) } rwctx := newRemoteWriteCtx(i, remoteWriteURL, maxInmemoryBlocks, urlLabelValue) rwctxs = append(rwctxs, rwctx) @@ -192,7 +192,7 @@ type remoteWriteCtx struct { func newRemoteWriteCtx(argIdx int, remoteWriteURL string, maxInmemoryBlocks int, urlLabelValue string) *remoteWriteCtx { h := xxhash.Sum64([]byte(remoteWriteURL)) - path := fmt.Sprintf("%s/persistent-queue/%016X", *tmpDataPath, h) + path := fmt.Sprintf("%s/persistent-queue/%d_%016X", *tmpDataPath, argIdx+1, h) fq := persistentqueue.MustOpenFastQueue(path, remoteWriteURL, maxInmemoryBlocks, maxPendingBytesPerURL.N) _ = metrics.GetOrCreateGauge(fmt.Sprintf(`vmagent_remotewrite_pending_data_bytes{path=%q, url=%q}`, path, urlLabelValue), func() float64 { return float64(fq.GetPendingBytes())