Skip to content

request: Add moving average calculation type to downsampling plugin #41

@peterbarnett03

Description

@peterbarnett03

Add moving average calculation type to downsampling plugin

Description:

Add support for a moving average calculation type in the downsampling plugin. This would allow users to compute rolling/sliding window averages over a configurable number of preceding rows.

Example use case:

SELECT                                                                                                                                                                                                             
      time,                                                                                                                                                                                                          
      site_id,                                                                                                                                                                                                       
      AVG(metric_value) OVER (                                                                                                                                                                                       
          PARTITION BY metric_name, site, region, zone, site_id, group_id                                                                                                                                            
          ORDER BY time                                                                                                                                                                                              
          ROWS BETWEEN 4 PRECEDING AND CURRENT ROW                                                                                                                                                                   
      ) AS 5_sec_moving_avg                                                  
  FROM measurements                                                                                                                                                                                                  
  WHERE                                                                                                                                                                                                              
      $__timeFilter(time)                                                                                                                                                                                            
      AND group_id IN (${group_id:singlequote})                                                                                                                                                                      
      AND asset_id LIKE (${asset_id:singlequote})                                                                                                                                                                    
  ORDER BY time ASC                                                                                                                                                                                                  
                               

Requirements:

  • New moving_avg calculation type alongside existing types (e.g. mean, sum, min, max)
  • Configurable window size (number of preceding rows)
  • Support for partition-by grouping on tag columns
  • Results ordered by time

Configuration example:

[[calculations]]
type = "moving_avg"
window_size = 5
field = "metric_value"
partition_by = ["metric_name", "site", "region", "zone"]

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions