go-graphite / carbonapi

Implementation of graphite API (graphite-web) in golang
Other
308 stars 140 forks source link

Add support for Graphite web sumSeriesLists function #701

Closed carrieedwards closed 1 year ago

carrieedwards commented 2 years ago

This PR adds support for the Graphite web sumSeriesLists function, defined as:

sumSeriesLists(seriesListFirstPos, seriesListSecondPos)
Iterates over a two lists and subtracts series lists 2 through n from series 1 list1[0] to list2[0], list1[1] to list2[1] and so on. The lists will need to be the same length

Example:

&target=sumSeriesLists(mining.{carbon,graphite,diamond}.extracted,mining.{carbon,graphite,diamond}.shipped)
An example above would be the same as running [sumSeries](https://graphite.readthedocs.io/en/latest/functions.html#graphite.render.functions.sumSeries) for each member of the list:

?target=sumSeries(mining.carbon.extracted,mining.carbon.shipped)
&target=sumSeries(mining.graphite.extracted,mining.graphite.shipped)

This un
&target=sumSeries(mining.diamond.extracted,mining.diamond.shipped)
This is an alias for [aggregateSeriesLists](https://graphite.readthedocs.io/en/latest/functions.html#graphite.render.functions.aggregateSeriesLists) with aggregation sum.

The function definition can also be found here.

Tests were added to verify the functionality according to the Graphite web implementation and the function definition.

Civil commented 1 year ago

Maybe for future changes, it would be worth to split functions and COMPATIBILITY.md change into separate PRs to avoid such blocker?

carrieedwards commented 1 year ago

Yes, we can do that