diff --git a/app/vmstorage/transport/server.go b/app/vmstorage/transport/server.go index 458b079aab..71ac623d4d 100644 --- a/app/vmstorage/transport/server.go +++ b/app/vmstorage/transport/server.go @@ -1193,7 +1193,9 @@ func (s *Server) processVMSelectSearch(ctx *vmselectRequestCtx) error { if err := checkTimeRange(s.storage, tr); err != nil { return ctx.writeErrorMessage(err) } + startTime := time.Now() ctx.sr.Init(s.storage, ctx.tfss, tr, *maxMetricsPerSearch, ctx.deadline) + indexSearchDuration.UpdateDuration(startTime) defer ctx.sr.MustClose() if err := ctx.sr.Error(); err != nil { return ctx.writeErrorMessage(err) @@ -1228,6 +1230,8 @@ func (s *Server) processVMSelectSearch(ctx *vmselectRequestCtx) error { return nil } +var indexSearchDuration = metrics.NewHistogram(`vm_index_search_duration_seconds`) + // checkTimeRange returns true if the given tr is denied for querying. func checkTimeRange(s *storage.Storage, tr storage.TimeRange) error { if !*denyQueriesOutsideRetention { diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 937a4fa2db..b2149650d1 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -8,6 +8,7 @@ - `histogram_stddev(buckets)` - returns standard deviation for the given buckets. * FEATURE: reduce median query duration by up to 2x. See https://github.com/VictoriaMetrics/VictoriaMetrics/commit/18fe0ff14bc78860c5569e2b70de1db78fac61be * FEATURE: export `vm_available_memory_bytes` and `vm_available_cpu_cores` metrics, which show the number of available RAM and available CPU cores for VictoriaMetrics apps. +* FEATURE: export `vm_index_search_duration_seconds` histogram, which can be used for troubleshooting time series search performance. * FEATURE: vmagent: add ability to replicate scrape targets among `vmagent` instances in the cluster with `-promscrape.cluster.replicationFactor` command-line flag. See [these docs](https://victoriametrics.github.io/vmagent.html#scraping-big-number-of-targets). * FEATURE: vmagent: accept `scrape_offset` option at `scrape_config`. This option may be useful when scrapes must start at the specified offset of every scrape interval. See [these docs](https://victoriametrics.github.io/vmagent.html#troubleshooting) for details. * FEATURE: vmagent: support `proxy_tls_config`, `proxy_basic_auth`, `proxy_bearer_token` and `proxy_bearer_token_file` options at `scrape_config` section for configuring proxies specified via `proxy_url`. See [these docs](https://victoriametrics.github.io/vmagent.html#scraping-targets-via-a-proxy).