如何使用大于和小于运算符过滤grafana仪表板? [英] How to filter grafana dashboard with greater than and less than operators?

查看:98
本文介绍了如何使用大于和小于运算符过滤grafana仪表板?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Grafana和InfluxdB的项目中工作.我能够获得grafana所需的所有值.

I'm working on a project where I'm using Grafana and InfluxdB. I was able to get all the required values to grafana.

在我的回复中,我提交了一个值小于零且大于零的文件.我想添加一个过滤器,用户可以在其中选择操作类型.

In my response I have a filed with value less than and greater than zero. I want to add a filter where user can select the type of operation.

关于如何破解此问题的任何建议.

Any recommendation on how to crack this.

到目前为止,我已经尝试过了.

So far I have tried..

我创建了一个变量(常数值为0,我试图在仪表板查询中使用小于或大于运算符的变量.选择变量后,运算符会立即变为等于"或不等于"来".

I created a Variable (constant value 0, which i tried to use in my dashboard query with less than or greater than operator. As soon as I select my variable, the operator gets changed to 'equal to' or 'not equal to'.

通过直接在查询中提供值可以正常工作.

By providing the value directly in the query works fine.

查询反映了使用我创建为常量的变量

Query reflected Using the variable which i created as constant

SELECT "servicename" AS "Service Name", "topic" AS "Topic", "type" AS "Type", "count" AS "Count" FROM "KafkaLag" WHERE ("servicename" =~ /^$servicename$/ AND "topic" =~ /^$topic$/ AND "type" =~ /^$type$/ AND "count" =~ /^$Greater_than_zero$/) AND $timeFilter ORDER BY time DESC

直接使用值反映查询,而无需任何变量

Query reflected using value directly without any variable

SELECT "servicename" AS "Service Name", "topic" AS "Topic", "type" AS "Type", "count" AS "Count" FROM "KafkaLag" WHERE ("servicename" =~ /^$servicename$/ AND "topic" =~ /^$topic$/ AND "type" =~ /^$type$/ AND "count" > 0) AND $timeFilter ORDER BY time DESC

从下表中,我需要一种在field_2上放置动态过滤器的方法,在需要时我可以得到大于零的值.

From the below table I need a way to put a dynamic filter on field_2 where I can get greater than zero values when required.

time | field_1 | field_2 
  t1 |   v1    |    0 
  t1 |   v2    |    2 
  t2 |   v3    |    0 
  t2 |   v4    |    12

推荐答案

select * from <table/measurement name> where field_2 > 0;

此查询将根据您的需要过滤数据.

This query will filter data as per you need.

这篇关于如何使用大于和小于运算符过滤grafana仪表板?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆