VictoriaMetrics/lib/promscrape
Aliaksandr Valialkin bb00bae353
Revert "Exemplar support (#5982)"
This reverts commit 5a3abfa041.

Reason for revert: exemplars aren't in wide use because they have numerous issues which prevent their adoption (see below).
Adding support for examplars into VictoriaMetrics introduces non-trivial code changes. These code changes need to be supported forever
once the release of VictoriaMetrics with exemplar support is published. That's why I don't think this is a good feature despite
that the source code of the reverted commit has an excellent quality. See https://docs.victoriametrics.com/goals/ .

Issues with Prometheus exemplars:

- Prometheus still has only experimental support for exemplars after more than three years since they were introduced.
  It stores exemplars in memory, so they are lost after Prometheus restart. This doesn't look like production-ready feature.
  See 0a2f3b3794/content/docs/instrumenting/exposition_formats.md (L153-L159)
  and https://prometheus.io/docs/prometheus/latest/feature_flags/#exemplars-storage

- It is very non-trivial to expose exemplars alongside metrics in your application, since the official Prometheus SDKs
  for metrics' exposition ( https://prometheus.io/docs/instrumenting/clientlibs/ ) either have very hard-to-use API
  for exposing histograms or do not have this API at all. For example, try figuring out how to expose exemplars
  via https://pkg.go.dev/github.com/prometheus/client_golang@v1.19.1/prometheus .

- It looks like exemplars are supported for Histogram metric types only -
  see https://pkg.go.dev/github.com/prometheus/client_golang@v1.19.1/prometheus#Timer.ObserveDurationWithExemplar .
  Exemplars aren't supported for Counter, Gauge and Summary metric types.

- Grafana has very poor support for Prometheus exemplars. It looks like it supports exemplars only when the query
  contains histogram_quantile() function. It queries exemplars via special Prometheus API -
  https://prometheus.io/docs/prometheus/latest/querying/api/#querying-exemplars - (which is still marked as experimental, btw.)
  and then displays all the returned exemplars on the graph as special dots. The issue is that this doesn't work
  in production in most cases when the histogram_quantile() is calculated over thousands of histogram buckets
  exposed by big number of application instances. Every histogram bucket may expose an exemplar on every timestamp shown on the graph.
  This makes the graph unusable, since it is litterally filled with thousands of exemplar dots.
  Neither Prometheus API nor Grafana doesn't provide the ability to filter out unneeded exemplars.

- Exemplars are usually connected to traces. While traces are good for some

I doubt exemplars will become production-ready in the near future because of the issues outlined above.

Alternative to exemplars:

Exemplars are marketed as a silver bullet for the correlation between metrics, traces and logs -
just click the exemplar dot on some graph in Grafana and instantly see the corresponding trace or log entry!
This doesn't work as expected in production as shown above. Are there better solutions, which work in production?
Yes - just use time-based and label-based correlation between metrics, traces and logs. Assign the same `job`
and `instance` labels to metrics, logs and traces, so you can quickly find the needed trace or log entry
by these labes on the time range with the anomaly on metrics' graph.
2024-07-03 15:30:21 +02:00
..
discovery added IMDSv2 for YC SD (#6524) 2024-06-26 18:03:21 +02:00
discoveryutils app/vmagent: support for DNS SRV urls at -remoteWrite.url, scrape target urls and service discovery urls 2024-04-17 20:54:39 +02:00
testdata lib/promscrape: disable support for service discovery and metrics scrape via http2 2023-07-06 16:03:37 -07:00
client.go Revert "Exemplar support (#5982)" 2024-07-03 15:30:21 +02:00
config.go app/vmagent: add max_scrape_size to scrape config (#6434) 2024-06-20 13:58:42 +02:00
config_test.go app/vmagent: add max_scrape_size to scrape config (#6434) 2024-06-20 13:58:42 +02:00
config_timing_test.go lib/promscrape: optimize service discovery speed 2022-11-29 21:26:00 -08:00
relabel_debug.go app/vmselect: small cleanup after 4f3f9950d0 2023-05-08 14:57:11 -07:00
scraper.go feature: [vmagent] Add service discovery support for Vultr (#6068) 2024-05-08 10:01:48 +02:00
scrapework.go Revert "Exemplar support (#5982)" 2024-07-03 15:30:21 +02:00
scrapework_test.go Revert "Exemplar support (#5982)" 2024-07-03 15:30:21 +02:00
scrapework_timing_test.go all: fix golangci-lint(revive) warnings after 0c0ed61ce7 2024-04-02 23:16:29 +03:00
targetstatus.go app/vmagent: add max_scrape_size to scrape config (#6434) 2024-06-20 13:58:42 +02:00
targetstatus.qtpl app/vmagent: add max_scrape_size to scrape config (#6434) 2024-06-20 13:58:42 +02:00
targetstatus.qtpl.go app/vmagent: add max_scrape_size to scrape config (#6434) 2024-06-20 13:58:42 +02:00