TS.MGET [ WITHLABELS | SELECTED_LABELS label1 [label1 ...]] FILTER l=v | l!=v | l= | l!= | l=(v1,v2,...) | l!=(v1,v2,...) [ l=v | l!=v | l= | l!= | l=(v1,v2,...) | l!=(v1,v2,...) ...]

Available in: Redis Stack

Time complexity: O(n) where n is the number of time-series that match the filters

TS.MGET

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:

    • label=value - label equals value
    • label!=value - label doesn't equal value
    • label= - key does not have the label label
    • label!= - key has label label
    • label=(value1,value2,...) - key with label label that equals one of the values in the list
    • lable!=(value1,value2,...) - key with label label that doesn't equal any of the values in the list

    Note: 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.

Return Value

For each time series matching the specified filters, the following is reported:

  • The key name
  • A list of label-value pairs
    • By default, an empty list is reported
    • If WITHLABELS is specified, all labels associated with this time series are reported
    • If SELECTED_LABELS label... is specified, the selected labels are reported
  • The last sample's timetag-value pair

Complexity

TS.MGET complexity is O(n).

n = Number of time series that match the filters

Examples

MGET Example with default behaviour
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"
MGET Example with WITHLABELS option
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"