Grafana:全局变量,用于访问时间范围的值 [英] Grafana: global variables to access [from,to] values of the time range
问题描述
我正在使用MySQL数据源进行一些测试,并使用了在SQL查询中="=" nofollow noreferrer> timefilter :
I am doing some tests with a MySQL data-source and make use of the timefilter inside the SQL query:
// my query goes here...
WHERE $__timeFilter(time_start);
生成如下内容:
WHERE time_start >= FROM_UNIXTIME(1505207821) AND time_start <= FROM_UNIXTIME(1505229421);
是否有任何变量可以让我访问定义时间范围的2个时间戳?
Are there any variables that can give me access to the 2 timestamps that define the time range?
例如,在上面的示例中:
For instance, at the example above:
from = 1505207821
to = 1505229421
推荐答案
是的,$__timeFrom()
和$__timeTo()
,如果您使用的是最新的4.5.1版本的Grafana(早期版本的Grafana仅包含Alpha版本的MySQL数据源).查询字段下有一个显示帮助"按钮,其中列出了所有宏.参见下文:
Yes, $__timeFrom()
and $__timeTo()
if you are using the latest 4.5.1 version of Grafana (earlier versions of Grafana only include an alpha version of the MySQL data source). There is a "Show Help" button under the query field where all the macros are listed. See below:
前两个宏以datetime格式从and返回,后两个宏以纪元返回.
The first two macros return from and to in the datetime format, the last two return them as epochs.
这篇关于Grafana:全局变量,用于访问时间范围的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!