TS.QUERYLABELS

TS.QUERYLABELS <LABELS | VALUES label> [FILTER filterExpr
  [filterExpr ...]]
Available in:
Redis Open Source / timeseries 8.10.0
Time complexity:
O(n) where n is the number of time-series that match the filters (all indexed series when FILTER is omitted)
ACL categories:
@read, @timeseries,
Compatibility:
Redis Software and Redis Cloud compatibility
Note:
This command's behavior varies in clustered Redis environments. See the multi-key operations page for more information.

Get all label names, or all values of a given label, for the time series matching a filter list (or all series when no filter is given).

Examples

Required arguments

LABELS | VALUES label

selects what the command returns:

  • LABELS - returns the set of distinct label names used by the matching time series.
  • VALUES label - returns the set of distinct values of label used by the matching time series. The result is empty (not an error) when label does not exist or when no matching series carries it.

Each name or value appears at most once, regardless of how many series it belongs to. The order of the results is not defined.

Optional arguments

FILTER filterExpr [filterExpr ...]

restricts the command to the time series whose labels and label values match all of the filter expressions. When FILTER is omitted, the command considers all indexed time series.

Each filter expression has one of the following syntaxes:

  • label!= - the time series has a label named label
  • label=value - the time series has a label named label with a value equal to value
  • label=(value1,value2,...) - the time series has a label named label with a value equal to one of the values in the list
  • label= - the time series does not have a label named label
  • label!=value - the time series does not have a label named label with a value equal to value
  • label!=(value1,value2,...) - the time series does not have a label named label with a value equal to any of the values in the list

Notes:

  • At least one filter expression with a syntax label=value or label=(value1,value2,...) is required.
  • Filter expressions are conjunctive. For example, the filter type=temperature room=study means that type=temperature AND room=study.
  • Whitespace is not allowed in a filter expression except between quotes or double quotes in values - for example, x="y y" or x='(y y,z z)'.

Examples

List labels and label values for a set of sensors

Create a set of sensors to measure temperature and humidity in your study and kitchen.

redis> TS.CREATE telemetry:study:temperature LABELS room study type temperature
OK
redis> TS.CREATE telemetry:study:humidity LABELS room study type humidity
OK
redis> TS.CREATE telemetry:kitchen:temperature LABELS room kitchen type temperature
OK
redis> TS.CREATE telemetry:kitchen:humidity LABELS room kitchen type humidity
OK

Retrieve the label names used by the time series located in the kitchen.

redis> TS.QUERYLABELS LABELS FILTER room=kitchen
1) "room"
2) "type"

Retrieve the distinct values of the type label across all time series.

redis> TS.QUERYLABELS VALUES type
1) "humidity"
2) "temperature"

Details

Access control

Unlike TS.QUERYINDEX, which lists every matching key whether or not the user has read access to it, TS.QUERYLABELS silently omits the time series that the user is not allowed to read. Label names and values that belong only to unreadable series do not appear in the result.

Redis Software and Redis Cloud compatibility

Redis
Software
Redis
Cloud
Notes
❌ Standard
❌ Active-Active
❌ Standard
❌ Active-Active

Return information

One of the following:

  • Array reply where each element is a Bulk string reply: a label name (with LABELS) or a label value (with VALUES). The array is empty if no time series matches the filter.
  • Simple error reply in these cases: invalid subtype, missing label after VALUES, or invalid filter expression.

See also

TS.QUERYINDEX | TS.CREATE | TS.MGET | TS.MRANGE

RedisTimeSeries

RATE THIS PAGE
Back to top ↑