Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Adding 'invisible' function to Graphite Web
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.
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
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
You can’t perform that action at this time.