【问题标题】:Grafana Template Variables Query Giving different results in different version (Grafana 5.0 vs Grafana 7.0)Grafana 模板变量查询在不同版本中给出不同的结果(Grafana 5.0 vs Grafana 7.0)
【发布时间】:2020-07-22 07:35:31
【问题描述】:

我正在使用模板变量查询在 Grafana 中分配一个变量。

SELECT * FROM jmeter WHERE application =~ /$tag_left/ ORDER BY time asc LIMIT 1

此查询的结果 JSON 是

{"results":[{"series":[{"name":"jmeter","columns":["time","application","avg","count ","countError","endT","hit","max","maxAT","meanAT","min","minAT","pct90.0","pct95.0","pct99.0 ","rb","re​​sponseCode","re​​sponseMessage","sb","startedT","statut","transaction"],"values":[[1595241959625,"demo_scenario.jmx @ 1 @ Mon Jul 20 16:15:58 IST 2020",null,null,null,0,null,null,0,0,null,0,null,null,null,null,null,null,null,0 ,null,"内部"]]}]}]}

我需要从此查询中获取 时间。哪个是 grafana 的 5.0 版本,但不是 7.0 版本。

有什么方法可以从查询结果中选择像time 这样的相应列并将其分配给变量?类似于 ${var:index}

为了更清楚地说明这一点,我附上了屏幕截图。

如您所见,一个将 timestamp 显示为变量值(例如 1595228080029),另一个显示 application 值(例如 demo_scenario.jmx @ 1 @ Mon Jul 20 16:15:58 IST 2020 ) 作为查询结果的预览值部分下

下划线的数据源是InfluxDB。在这两种情况下,api 查询都有相同的响应。

【问题讨论】:

    标签: grafana influxdb grafana-templating grafana-variable


    【解决方案1】:

    使用的变量查询返回时间序列和多个“列”(因为SELECT *) - 这是错误的。 Doc https://grafana.com/docs/grafana/latest/datasources/influxdb/#templating 包含正确的模板查询应该是什么样子,例如

    SHOW TAG VALUES WITH KEY = "hostname"
    

    它不返回时间序列,只返回一个“列”(在这种特殊情况下为主机名)。 InfluxQL 不允许您仅选择时间列,因此无法在 Grafana 中随心所欲地实现它。

    【讨论】:

      猜你喜欢
      • 2018-12-05
      • 2018-07-29
      • 2020-08-19
      • 1970-01-01
      • 1970-01-01
      • 2016-12-01
      • 2019-10-26
      • 1970-01-01
      • 2021-12-22
      相关资源
      最近更新 更多