Available in: Redis Stack
Time complexity: O(n) where n is the number of time-series that match the filters
Get the last samples matching a specific filter.
TS.MGET [WITHLABELS | SELECTED_LABELS label...] FILTER filter...
FILTER filter...
This is the list of possible filters:
=
value - label equals value!=
value - label doesn't equal value=
- key does not have the label label!=
- key has label label=(
value1,
value2,
...)
- key with label label that equals one of the values in the list!=(
value1,
value2,
...)
- key with label label that doesn't equal any of the values in the listNote: Whenever filters need to be provided, a minimum of one label=
value filter must be applied.
Optional args:
WITHLABELS
- Include in the reply all label-value pairs representing metadata labels of the time series.SELECTED_LABELS
label... - Include in the reply a subset of the label-value pairs that represent metadata labels of the time series. This is usefull when there is a large number of labels per series, but only the values of some of the labels are required.If WITHLABELS
or SELECTED_LABELS
are not specified, by default, an empty list is reported as the label-value pairs.
For each time series matching the specified filters, the following is reported:
WITHLABELS
is specified, all labels associated with this time series are reportedSELECTED_LABELS
label... is specified, the selected labels are reportedNote: MGET command can't be part of transaction when running on Redis cluster.
TS.MGET complexity is O(n).
n = Number of time series that match the filters
127.0.0.1:6379> TS.MGET FILTER area_id=32
1) 1) "temperature:2:32"
2) (empty list or set)
3) 1) (integer) 1548149181000
2) "30"
2) 1) "temperature:3:32"
2) (empty list or set)
3) 1) (integer) 1548149181000
2) "29"
127.0.0.1:6379> TS.MGET WITHLABELS FILTER area_id=32
1) 1) "temperature:2:32"
2) 1) 1) "sensor_id"
2) "2"
2) 1) "area_id"
2) "32"
3) 1) (integer) 1548149181000
2) "30"
2) 1) "temperature:3:32"
2) 1) 1) "sensor_id"
2) "2"
2) 1) "area_id"
2) "32"
3) 1) (integer) 1548149181000
2) "29"