diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index d19346a89..6ca294ee4 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 aade32faa..6c1e2f502 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 }