Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GROUPBY and REDUCE support #57

Closed
gkorland opened this issue Jul 25, 2021 · 1 comment · Fixed by #71
Closed

Add GROUPBY and REDUCE support #57

gkorland opened this issue Jul 25, 2021 · 1 comment · Fixed by #71
Assignees

Comments

@gkorland
Copy link
Contributor

gkorland commented Jul 25, 2021

Expected argument extension to TS.MRANGE: GROUPBY <label> REDUCE <reducer>

TS.MRANGE 1451679382646 1451682982646 WITHLABELS 
AGGREGATION MAX 60000 
FILTER measurement=cpu 
      fieldname=usage_user 
      hostname=(host_9,host_3,host_5,host_1,host_7,host_2,host_8,host_4)
GROUPBY hostname REDUCE MAX

Documentation extension:

  • GROUPBY - Aggregate results across different time series, grouped by the provided label name.
    For OSS clustered databases, RedisGears is required to be present.

    When combined with AGGREGATION the groupby/reduce is applied post aggregation stage.

    • label - label name to group series by.

    • reducer - Reducer type used to aggregate series that share the same label value. Available reducers: sum, min, max.

    • Note: The resulting series will contain 3 labels with the following label array structure:

      • <label>=<groupbyvalue> : containing the label name and label value.
      • __reducer__=<reducer> : containing the used reducer.
      • __source__=key1,key2,key3 : containing the source time series used to compute the grouped serie.

Example of the above features:

Query time series with metric=cpu, group them by metric_name reduce max

127.0.0.1:6379> TS.ADD ts1 1 90 labels metric cpu metric_name system
(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
(integer) 2
127.0.0.1:6379> TS.MRANGE - + WITHLABELS FILTER metric=cpu GROUPBY metric_name REDUCE max
1) 1) "metric_name=system"
   2) 1) 1) "metric_name"
         2) "system"
      2) 1) "__reducer__"
         2) "max"
      3) 1) "__source__"
         2) "ts1"
   3) 1) 1) (integer) 1
         2) 90
      2) 1) (integer) 2
         2) 45
2) 1) "metric_name=user"
   2) 1) 1) "metric_name"
         2) "user"
      2) 1) "__reducer__"
         2) "max"
      3) 1) "__source__"
         2) "ts2"
   3) 1) 1) (integer) 2
         2) 99
@gkorland gkorland changed the title Add Multi-Series GROUPBY and REDUCE support Add GROUPBY and REDUCE support Jul 25, 2021
@sazzad16 sazzad16 linked a pull request Aug 2, 2021 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants