Reference to the globalFilter() function

Summary

globalFilter(<tsExpression | hsExpression>, <filter1> [and|or [not] <filter2>] ... )

where <filterN> is:
    <metricName> | source=<sourceName> | tag=<sourceTagName> | <pointTagKey>=<pointTagValue>

Filters the expression to display only the time series that match the specified filters. This function works for ts() and hs() expressions.

Parameters

ParameterDescription
tsExpression | hsExpression Expression that describes the time series or histogram series that you want to filter.
<metricName>|source=|tag=|<pointTagKey>= A metric, source, source tag, or point tag to filter by. You must specify at least one filter, which can be of any type. Use Boolean operators to combine multiple filters. For example,
(source=app-1 or source=app-2) and env=dev.

Description

The globalFilter() function filters a time series or histogram expression. You can filter by metric, source, source tag, or point tag. To filter by a source, source tag, or point tag, specify source=, tag=, or tagk=. Set pointTagKey to the unique point tag key to filter by.

The globalFilter() function is similar to retainSeries(), but filters are pushed all the way into the inner ts()/hs() expressions. That means you can use globalFilter() to filter data pre-aggregation.

Examples

No Data With retainSeries()

In the following example, we’re using the retainSeries filtering function together with sum(). Because information about the environment is no longer available after the sum() has been applied, the query returns NO DATA.

filter with retainSeries

Data With globalFilter()

In contrast, if we use globalFilter for the same scenario, we can filter by environment and apply the sum() function.

filter with globalFilter

See Also