简体   繁体   English

在 Grafana 中,查询步骤和间隔有什么区别?

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

In the docs , it says that:docs中,它说:

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. Grafana 会自动计算适当的间隔,并且可以将其用作模板化查询中的变量。 The variable is either in seconds: $__interval or in milliseconds: $__interval_ms .该变量以秒为单位: $__interval或以毫秒为单位: $__interval_ms

The part about deciding the Interval based on how wide the graph is confused me.根据图表的宽度决定Interval的部分让我感到困惑。 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?如果我们根据图形宽度计算Interval ,那么这是否意味着我的图形宽度/ Interval决定了我想在某个绝对范围内每个时间跨度显示多少数据点? 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 屏幕截图(来自他们的演示),用于可视化我的要求:

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?为简化问题:SQL 查询中使用了Intervalquery step这两个因素中的哪一个来获取 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.如果在查询中直接使用 $__interval,它不会覆盖任何查询选项。 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.因此,对于 Influx,您可能希望向查询添加“按时间分组($__interval)”,但查询检查器仍会添加查询选项。

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.使用 Prometheus,查询检查器不会显示在查询中使用“最大数据点”的任何提示,但对于较宽的时间范围,它会添加 step 选项。 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.我没有看到 $__interval 或 step 对视觉的任何其他影响。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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