简体   繁体   English

时间范围过滤器不适用于 Grafana 中的条形图和条形图

[英]Time range filter is not working for Bar-chart and Bar-gauge in Grafana

*We are trying to utilize the time range selector in grafana which works only for time series representation as of now. Can you please let me know any way to utilize that time range selector for bar-chart and bar-graph in Grafana representation.*

Adding the Schema, query and representation in grafana for reference.在 grafana 中添加 Schema、Query 和 Representation 以供参考。

  1. Schema:[ https://i.stack.imgur.com/n2srW.png]架构:[https://i.stack.imgur.com/n2srW.png]
  2. query: [https://i.stack.imgur.com/HwWRJ.png]查询:[https://i.stack.imgur.com/HwWRJ.png]
  3. Bar-chart rep: [https://i.stack.imgur.com/1MQbA.png]条形图代表:[https://i.stack.imgur.com/1MQbA.png]

Not totally sure what you are asking but hopefully this is right.不完全确定你在问什么,但希望这是正确的。

Your query has no where clause to filter by the selected time in Grafana.您的查询没有在 Grafana 中按选定时间过滤的 where 子句。 You can use a Grafana macro to add a time range filter.您可以使用 Grafana 宏来添加时间范围过滤器。 The MySQL macro documentation is here . MySQL 宏文档在这里 And there are some examples further down on the page.页面下方还有一些示例。

You haven't specified what the table schema looks like or which column you want to use for filtering.您尚未指定表架构的外观或要用于过滤的列。 So I made a guess and just added a where clause with the $__timeFilter macro and filtering on the lastupdated column as it is the only datetime column in your example:所以我做了一个猜测,只是在$__timeFilter宏中添加了一个 where 子句,并在lastupdated列上进行过滤,因为它是您示例中唯一的 datetime 列:

SELECT
  lastupdated as time_sec,
  TIME_FORMAT(sec_to_time(time), "%H:%i") AS total_time,
  mrid as metric
  ,time/3600 as time_in_hours
FROM margetomerge.mergedetails
WHERE $__timeFilter(lastupdated)
order by mrid desc

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

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