43

I have no clue what the option "instant" means in Grafana when creating graph with Prometheus.

Any ideas?

palacsint
  • 28,416
  • 10
  • 82
  • 109
eventhorizon
  • 2,977
  • 8
  • 33
  • 57

2 Answers2

55

It uses the query API endpoint rather than the query_range API endpoint on Prometheus, which is more efficient if you only care about the end of your time range and don't want to pull in data that Grafana is going to throw away again.

brian-brazil
  • 31,678
  • 6
  • 93
  • 86
5

By default Grafana sends PromQL queries to /api/v1/query_range for building graphs. This API returns calculated datapoints on the requested [start ... end] time range with the given step interval between datapoints. The step interval is calculated by Grafana based on the selected step and resolution graph options and horizontal pixel resolution of the graph.

Sometimes it is needed to execute query only against the last datapoint on the selected time range. In this case you can check instant checkbox in Grafana graph settings. Then Grafana will send PromQL queries to /api/v1/query instead of /api/v1/query_range. This API returns only a single datapoint per each matching time series at the specified timestamp time. This API usually works faster than /api/v1/query_range, since it evaluates the provided PromQL query only at a single timestamp instead of multiple timestamps.

valyala
  • 11,669
  • 1
  • 59
  • 62
  • I've been trying to find the 'instant' toggle in Grafana, but can not find where it is... Cant see it anywhere, and the docs are doing me no favours. Any pointers @valyala? – abinitio Aug 15 '23 at 10:48
  • 1
    Fixed the link in the answer to Grafana docs about `instant` toggle. The new link is https://grafana.com/docs/grafana/latest/datasources/prometheus/query-editor/#type – valyala Aug 15 '23 at 22:06