Created
August 18, 2014 15:24
-
-
Save ojilles/6611ab81ad6169fb95f5 to your computer and use it in GitHub Desktop.
Adding 'invisible' function to Graphite Web
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Ran on current version of `synthesize`: | |
https://localhost:8443/render/?width=941&height=542&_salt=1408374478.348&from=-1hours&fontSize=16&target=invisible(legendValue(integral(collectd.graphite.apache-graphite-web.apache_requests)%2C%22max%22))&target=legendValue(collectd.graphite.apache-graphite-web.apache_requests%2C%22total%22) | |
And a little more clear: | |
https://localhost:8443/render/?width=941&height=542&_salt=1408374478.348&from=-1hours&fontSize=16& | |
target=invisible(legendValue(integral(collectd.graphite.apache-graphite-web.apache_requests),"max")) | |
&target=legendValue(collectd.graphite.apache-graphite-web.apache_requests,"total") | |
In this case (for testing) the two metrics are the same and result in the same legend values. But with this patch the metrics don't need to be the same at all. One could f.ex. have a graph with latencies, and a legend item stating how many requests were served in that period. | |
This results in the following graph: http://imgur.com/qSGWmys | |
(Mind the Y-axis: it scales down to the one visible metric, not the invisible (much larger, number wise) metric. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
New function: | |
def invisible(requestContext, seriesList): | |
""" | |
Accepts one or more series, and will remove that from the graph, but will leave it in place in the Legend. | |
""" | |
try: | |
seriesList.options['invisible'] = True | |
except AttributeError: | |
for series in seriesList: | |
series.options['invisible'] = True | |
return seriesList | |
+ needs to be added in composer (easy) and at the bottom of functions.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
For illustration purposes only (would need to rewrite to do both drawAsInfinite and invisible, of course. But describes the scale of changes needed. | |
< sumSeries.append( safeSum( [series[i] for series in self.data if not series.options.get('drawAsInfinite')] ) ) | |
> sumSeries.append( safeSum( [series[i] for series in self.data if not series.options.get('invisible')] ) ) | |
And: | |
< yMaxValue = safeMax( [safeMax(series) for series in self.data if not series.options.get('drawAsInfinite')] ) | |
> yMaxValue = safeMax( [safeMax(series) for series in self.data if not series.options.get('invisible')] ) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment