Open source Enterprise Grafana Cloud

Filter data

The Infinity data source provides multiple ways to filter data depending on which parser you use. You can filter results using expressions, visual filters, or query language syntax.

Note

All filtering happens after retrieving the content from the source. For better performance, use filtering provided by the API when possible (for example, query parameters in the URL).

Filter methods by parser

ParserFilter method
Backend (JSONata)Native JSONata filtering (preferred) / Filter expression field
Backend (JQ)Native JQ filtering (preferred) / Filter expression field
FrontendVisual filter editor
UQLwhere clause in query
GROQNative GROQ filtering

Filter with the Backend parser

When using the Backend parser (JSONata or JQ), use the Filter expression field to filter rows. The expression must evaluate to true or false.

Filter expression syntax

Filter expressions support the following operators:

CategoryOperatorsExample
Comparison==, !=, >, >=, <, <=price > 100
Logical&&, ||, !price > 100 && stock > 0
String==, !=status == 'active'
Null check!= null, == nullname != null
MembershipIN, NOT INregion IN ('US','EU')
Negation!()!(region IN ('US','EU'))

Filter with a single value variable

To filter based on a single-value template variable:

text
region == '${region}'

This filters rows where the region field matches the selected variable value.

Filter with a multi-value variable

To filter based on a multi-value template variable, use the IN operator with the singlequote format:

text
region IN (${region:singlequote})

This filters rows where the region field matches any of the selected values.

Exclude values (NOT IN)

To exclude multiple values, wrap the condition with !():

text
!(region IN (${region:singlequote}))

Combine multiple conditions

You can combine conditions using && (AND) and || (OR):

text
region == 'US' && status == 'active'
price > 100 || featured == true

Filter with the Frontend parser

When using the Frontend parser with defined columns, you can use the visual filter editor. This provides a drop-down interface for selecting fields, operators, and values.

Available filter operators

The visual filter editor supports the following operators:

OperatorDescription
EqualsExact match (case-sensitive)
Not EqualsDoes not match (case-sensitive)
ContainsField contains the value
Not ContainsField does not contain the value
Starts WithField starts with the value
Ends WithField ends with the value
Equals - Ignore CaseExact match (case-insensitive)
Not Equals - Ignore CaseDoes not match (case-insensitive)
Contains - Ignore CaseContains (case-insensitive)
Not Contains - Ignore CaseDoes not contain (case-insensitive)
Starts With - Ignore CaseStarts with (case-insensitive)
Ends With - Ignore CaseEnds with (case-insensitive)
RegexMatches regular expression
Regex not matchDoes not match regular expression
InValue is in a list
Not InValue is not in a list
==Numeric equals
!=Numeric not equals
<Less than
<=Less than or equal to
>Greater than
>=Greater than or equal to

Note

The visual filter editor is only available when using the Frontend parser and when you have defined at least one column.

Filter with UQL

When using UQL (Unified Query Language), use the where clause to filter data.

Basic UQL filter

uql
parse-json
| where "region" == 'US'
| summarize count("name") by "region"

UQL with single-value variable

uql
parse-json
| where "region" == '${region}'
| summarize count("name") by "region"

UQL with multi-value variable

uql
parse-json
| where "region" in (${region:singlequote})
| summarize count("name") by "region"

UQL exclude values (NOT IN)

uql
parse-json
| where "region" !in (${region:singlequote})
| summarize count("name") by "region"

UQL with JSONata expressions

You can also use JSONata syntax within UQL for more complex filtering:

uql
parse-json
| jsonata "$[region='${region}']"
| summarize count("name") by "region"

For multi-value variables with JSONata:

uql
parse-json
| jsonata "$[region in [${region:singlequote}]]"
| summarize count("name") by "region"

To exclude values with JSONata:

uql
parse-json
| jsonata "$[$not(region in [${region:singlequote}])]"
| summarize count("name") by "region"

Use template variables in filters

Template variables make filters dynamic, allowing users to select values from dashboard drop-downs.

Variable formatting options

When using multi-value variables in filters, use the appropriate format option:

FormatSyntaxOutput example
Single quote${var:singlequote}'value1','value2'
Double quote${var:doublequote}"value1","value2"
Raw${var:raw}value1,value2

For more information about variable formatting, refer to Advanced variable format options.