How to use the selected period of time in a query?

女生的网名这么多〃 提交于 2019-12-02 19:36:49

There are two ways that I know:

  1. You can use the $__interval variable like this:

    increase(http_requests_total[$__interval])
    

There is a drawback that the $__interval variable's value is adjusted by resolution of the graph, but this may also be helpful in some situations.

  1. This approach should fit your case better:

Go to Dashboard's Templating settings, create new variable with the type of Interval. Enable "Auto Option", adjust "Step count" to be equal 1. Then ensure that the "auto" is selected in corresponding drop-down list at the top of the dashboard.

Let's assume you name it timeRange, then the query will look like this:

increase(http_requests_total[$timeRange])

This variable will not be adjusted by graph resolution and if you select "Last 10 hours" its value will be 10h.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!