How does Prometheus define sample duration?

I have an SNMP exporter job that scrapes every 10 minutes. I noticed that Grafana shows each sample as 5 dots, one per minute. Prometheus web graph looks similar, with each sample shown as a horizontal line 5 minutes long. Why is this happening? I expected each sample to be just a single data point at one moment in time.


did you set the Min interval to 10m?

Thank you! I wasn’t aware of that setting, it was on the default 60s. If I set it to 10m then I get No Data in the time series. If I set it to 9m then it looks how I expect. Weird!

Set it to 10m and add [$__interval] to the metric name like this:


If it still shows “No Data”, then set it back to 9m and wait for some expert to explain whats happening xD

That works with instant query, but with time series it shows this error:
bad_data: invalid parameter “query”: 1:1: parse error: binary expression must contain only scalar and instant vector types

I found something similar to this

range-vectors can’t be graphed because they have multiple values for each timestamp. If you select the Graph tab in the Prometheus web UI on a range-vector, you’ll see this message:

Error executing query: invalid expression type "range vector" for range query, must be Scalar or instant Vector

A range-vector is typically generated in order to then apply a function to it to get an instant-vector, which can be graphed (only instant vectors can be graphed). Prometheus has many functions for both instant and range vectors.



*If setting the interval 9m works perfectly for you, then fine, just use it without this overhead.