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
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).
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 oflabelused by the matching time series. The result is empty (not an error) whenlabeldoes 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 namedlabellabel=value- the time series has a label namedlabelwith a value equal tovaluelabel=(value1,value2,...)- the time series has a label namedlabelwith a value equal to one of the values in the listlabel=- the time series does not have a label namedlabellabel!=value- the time series does not have a label namedlabelwith a value equal tovaluelabel!=(value1,value2,...)- the time series does not have a label namedlabelwith a value equal to any of the values in the list
- At least one filter expression with a syntax
label=valueorlabel=(value1,value2,...)is required. - Filter expressions are conjunctive. For example, the filter
type=temperature room=studymeans thattype=temperatureANDroom=study. - Whitespace is not allowed in a filter expression except between quotes or double quotes in values - for example,
x="y y"orx='(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 |
❌ Standard |
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 (withVALUES). 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