graphite-dev team mailing list archive
-
graphite-dev team
-
Mailing list archive
-
Message #02086
[Merge] lp:~saysjonathan/graphite/rangeseries into lp:graphite
saysjonathan has proposed merging lp:~saysjonathan/graphite/rangeseries into lp:graphite.
Requested reviews:
graphite-dev (graphite-dev)
For more details, see:
https://code.launchpad.net/~saysjonathan/graphite/rangeseries/+merge/92167
[FEATURE] Adds a new Graph Data Function: rangeOfSeries. Distills down a set of inputs into the range of the series, e.g., [0, 1, 2, 3] = 3, and [4, 5, 6] = 2
--
https://code.launchpad.net/~saysjonathan/graphite/rangeseries/+merge/92167
Your team graphite-dev is requested to review the proposed merge of lp:~saysjonathan/graphite/rangeseries into lp:graphite.
=== modified file 'webapp/content/js/composer_widgets.js'
--- webapp/content/js/composer_widgets.js 2011-12-05 08:30:48 +0000
+++ webapp/content/js/composer_widgets.js 2012-02-09 00:23:46 +0000
@@ -884,7 +884,8 @@
{text: 'Average', handler: applyFuncToAll('averageSeries')},
{text: 'Min Values', handler: applyFuncToAll('minSeries')},
{text: 'Max Values', handler: applyFuncToAll('maxSeries')},
- {text: 'Group', handler: applyFuncToAll('group')}
+ {text: 'Group', handler: applyFuncToAll('group')},
+ {text: 'Range', handler: this.applyFuncToAll('rangeOfSeries')}
]
}, {
text: 'Transform',
=== modified file 'webapp/graphite/render/functions.py'
--- webapp/graphite/render/functions.py 2012-02-08 05:40:42 +0000
+++ webapp/graphite/render/functions.py 2012-02-09 00:23:46 +0000
@@ -55,6 +55,10 @@
if a is None or b is None: return None
return float(a) * float(b)
+def safeSubtract(a,b):
+ if a is None or b is None: return None
+ return float(a) - float(b)
+
def safeLast(values):
for v in reversed(values):
if v is not None: return v
@@ -269,6 +273,25 @@
series.pathExpression = name
return [series]
+def rangeOfSeries(requestContext, *seriesLists):
+ """
+ Takes a wildcard seriesList.
+ Distills down a set of inputs into the range of the series
+
+ Example:
+
+ .. code-block:: none
+
+ &target=rangeOfSeries(Server*.connections.total)
+
+ """
+ (seriesList,start,end,step) = normalize(seriesLists)
+ name = "rangeOfSeries(%s)" % ','.join(set([s.pathExpression for s in seriesList]))
+ values = ( safeSubtract(max(row), min(row)) for row in izip(*seriesList) )
+ series = TimeSeries(name,start,end,step,values)
+ series.pathExpression = name
+ return [series]
+
def keepLastValue(requestContext, seriesList):
"""
Takes one metric or a wildcard seriesList.
@@ -2060,6 +2083,7 @@
'averageSeriesWithWildcards': averageSeriesWithWildcards,
'minSeries' : minSeries,
'maxSeries' : maxSeries,
+ 'rangeOfSeries': rangeOfSeries,
# Transform functions
'scale' : scale,