简体   繁体   中英

In Grafana what is the difference between query step and Interval?

In the docs , it says that:

Interval - The interval is a time span that you can use when aggregating or grouping data points by time.

This automatic interval is calculated based on the width of the graph . If the user zooms out a lot then the interval becomes greater, resulting in a more coarse grained aggregation whereas if the user zooms in then the interval decreases resulting in a more fine grained aggregation. Grafana automatically calculates an appropriate interval and it can be used as a variable in templated queries. The variable is either in seconds: $__interval or in milliseconds: $__interval_ms .

The part about deciding the Interval based on how wide the graph is confused me. If we are calculating the Interval based on graph width, then does that mean my graph width/ Interval dictates how many data points I want to show per time spans in some absolute range? Does it override query step ? I thought that the amount of times my query is repeated through my selected time range, aka, my query step, would decide how many data points I want to show. But that doesn't seem to be the case. What is the relationship between them?

Here is a Grafana screenshot (from their demo ) for visualizing what I'm asking:

Grafana 中简单时间序列图的屏幕截图

Please correct me if I have any misunderstandings.

EDIT :

You can check the comments for a clarification on the question's aim. To simplify the question: Which of the two factors Interval and query step is used in the SQL query for fetching interval data in Grafana? What's their relationship on the visualization side?

I think it all depends on the data source and the query.

If you have a look at the query option "Max data points" the info says: "The maximum data points per series. Used directly by some data sources and used in calculation of auto interval. With streaming data this value is used for the rolling buffer." So some data sources will receive this option, others will not. I guess it is the same with query step.

As I understand it, you have the query itself and the query options. If you directly use $__interval in the query, it does not overwrite any query option. So with Influx you might want to add a "group by time($__interval)" to the query and the query inspector will nevertheless add query options.

With Prometheus, the query inspector does not show any hint that "Max data points" is used in the query but for wide time ranges it adds the step option. The query type used here is range query and step is a request parameter in addition to the query itself.

The number of data points returned by the query effect the visualization side. I don't see any other impact of $__interval or step on the visual.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM