RedisTimeSeries / NRedisTimeSeries

.Net Client for RedisTimeSeries
https://redistimeseries.io
BSD 3-Clause "New" or "Revised" License
29 stars 12 forks source link

SELECTED_LABELS label1 ... support for TS.MRANGE and TS.MREVRANGE #70

Closed filipecosta90 closed 3 years ago

filipecosta90 commented 3 years ago

Changes to TS.MRANGE / MREVRANGE

SELECTED_LABELS allows to request only a subset of the key-value pair labels of a serie. An important note is that SELECTED_LABELS and WITHLABELS are mutualy exclusive.

TS.MRANGE fromTimestamp toTimestamp
          [FILTER_BY_TS TS1 TS2 ..]
          [FILTER_BY_VALUE min max]
          [COUNT count]
          [WITHLABELS | SELECTED_LABELS label1 ..]
          [AGGREGATION aggregationType timeBucket]
          FILTER filter..
          [GROUPBY <label> REDUCE <reducer>]

TS.MREVRANGE fromTimestamp toTimestamp
          [FILTER_BY_TS TS1 TS2 ..]
          [FILTER_BY_VALUE min max]
          [COUNT count]
          [WITHLABELS | SELECTED_LABELS label1 ..]
          [AGGREGATION aggregationType timeBucket]
          FILTER filter..
          [GROUPBY <label> REDUCE <reducer>]

More detailed args specs:

* WITHLABELS - Include in the reply the label-value pairs that represent metadata labels of the time series. If `WITHLABELS` or `SELECTED_LABELS` are not set, by default, an empty Array will be replied on the labels array position.
* SELECTED_LABELS - Include in the reply a subset of the label-value pairs that represent metadata labels of the time series. This is usefull when you have a large number of labels per serie but are only interested in the value of some of the labels. If `WITHLABELS` or `SELECTED_LABELS` are not set, by default, an empty Array will be replied on the labels array position.

Example:

Query time series with metric=cpu, but only reply the team label

127.0.0.1:6379> TS.ADD ts1 1 90 labels metric cpu metric_name system team NY
(integer) 1
127.0.0.1:6379> TS.ADD ts1 2 45
(integer) 2
127.0.0.1:6379> TS.ADD ts2 2 99 labels metric cpu metric_name user team SF
(integer) 2
127.0.0.1:6379> TS.MRANGE - + SELECTED_LABELS team FILTER metric=cpu
1) 1) "ts1"
   2) 1) 1) "team"
         2) "NY"
   3) 1) 1) (integer) 1
         2) 90
      2) 1) (integer) 2
         2) 45
2) 1) "ts2"
   2) 1) 1) "team"
         2) "SF"
   3) 1) 1) (integer) 2
         2) 99