From f35aafb6a5550454759d6d5b804d3534343b2b29 Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Wed, 4 Nov 2020 11:45:38 +0200 Subject: [PATCH] Revert "lib/promscrape: add `-promscrape.dropOriginalLabels` command-line flag for reducing memory usage when discovering big number of scrape targets" This reverts commit b08c6f5144bf654cd46c39776edbd02122d9c8cc. --- lib/promscrape/config.go | 9 ++------- lib/promscrape/scraper.go | 2 +- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/lib/promscrape/config.go b/lib/promscrape/config.go index dc7128608..d8ca91469 100644 --- a/lib/promscrape/config.go +++ b/lib/promscrape/config.go @@ -32,8 +32,6 @@ var ( dryRun = flag.Bool("promscrape.config.dryRun", false, "Checks -promscrape.config file for errors and unsupported fields and then exits. "+ "Returns non-zero exit code on parsing errors and emits these errors to stderr. "+ "Pass -loggerLevel=ERROR if you don't need to see info messages in the output") - dropOriginalLabels = flag.Bool("promscrape.dropOriginalLabels", false, "Whether to drop original labels for scrape targets at /targets and /api/v1/targets pages. "+ - "This may be needed for reducing memory usage if original labels occupy big amounts of memory") ) // Config represents essential parts from Prometheus config defined at https://prometheus.io/docs/prometheus/latest/configuration/configuration/ @@ -641,11 +639,8 @@ func (stc *StaticConfig) appendScrapeWork(dst []ScrapeWork, swc *scrapeWorkConfi func appendScrapeWork(dst []ScrapeWork, swc *scrapeWorkConfig, target string, extraLabels, metaLabels map[string]string) ([]ScrapeWork, error) { labels := mergeLabels(swc.jobName, swc.scheme, target, swc.metricsPath, extraLabels, swc.externalLabels, metaLabels, swc.params) - var originalLabels []prompbmarshal.Label - if !*dropOriginalLabels { - originalLabels = append([]prompbmarshal.Label{}, labels...) - promrelabel.SortLabels(originalLabels) - } + originalLabels := append([]prompbmarshal.Label{}, labels...) + promrelabel.SortLabels(originalLabels) labels = promrelabel.ApplyRelabelConfigs(labels, 0, swc.relabelConfigs, false) labels = promrelabel.RemoveMetaLabels(labels[:0], labels) if len(labels) == 0 { diff --git a/lib/promscrape/scraper.go b/lib/promscrape/scraper.go index a6683b5fe..341e66462 100644 --- a/lib/promscrape/scraper.go +++ b/lib/promscrape/scraper.go @@ -308,7 +308,7 @@ func (sg *scraperGroup) update(sws []ScrapeWork) { // Stop deleted scrapers, which are missing in sws. for key, sc := range sg.m { - if _, ok := swsMap[key]; !ok { + if swsMap[key] == nil { close(sc.stopCh) delete(sg.m, key) deletionsCount++