From 8b873983339688efa90bdf933f01231bb710b470 Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Sun, 21 Feb 2021 23:21:17 +0200 Subject: [PATCH] lib/promscrape: export vm_promscrape_target_relabel_duration_seconds metric --- docs/CHANGELOG.md | 1 + lib/promscrape/config.go | 3 +++ 2 files changed, 4 insertions(+) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index d19346a897..6ca294ee4b 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -10,6 +10,7 @@ * `process_io_write_syscalls_total` - the number of write syscalls such as write and pwrite * `process_io_storage_read_bytes_total` - the number of bytes read from storage layer * `process_io_storage_written_bytes_total` - the number of bytes written to storage layer +* FEATURE: vmagent: export `vm_promscrape_target_relabel_duration_seconds` metric, which can be used for monitoring the time spend on relabeling for discovered targets. * BUGFIX: vmagent: properly perform graceful shutdown on `SIGINT` and `SIGTERM` signals. The graceful shutdown has been broken in `v1.54.0`. See https://github.com/VictoriaMetrics/VictoriaMetrics/issues/1065 diff --git a/lib/promscrape/config.go b/lib/promscrape/config.go index aade32faac..6c1e2f5026 100644 --- a/lib/promscrape/config.go +++ b/lib/promscrape/config.go @@ -24,6 +24,7 @@ import ( "github.com/VictoriaMetrics/VictoriaMetrics/lib/promscrape/discovery/kubernetes" "github.com/VictoriaMetrics/VictoriaMetrics/lib/promscrape/discovery/openstack" "github.com/VictoriaMetrics/VictoriaMetrics/lib/proxy" + "github.com/VictoriaMetrics/metrics" "gopkg.in/yaml.v2" ) @@ -608,6 +609,7 @@ func appendGCEScrapeWork(dst []*ScrapeWork, sdc *gce.SDConfig, swc *scrapeWorkCo } func appendScrapeWorkForTargetLabels(dst []*ScrapeWork, swc *scrapeWorkConfig, targetLabels []map[string]string, sectionName string) []*ScrapeWork { + startTime := time.Now() for _, metaLabels := range targetLabels { target := metaLabels["__address__"] var err error @@ -617,6 +619,7 @@ func appendScrapeWorkForTargetLabels(dst []*ScrapeWork, swc *scrapeWorkConfig, t continue } } + metrics.GetOrCreateHistogram(fmt.Sprintf("vm_promscrape_target_relabel_duration_seconds{type=%q}", sectionName)).UpdateDuration(startTime) return dst }