Simple math on graphs (aka display transform)¶
The display transform allows you to transform the graph based on a simple formula. For example if you are measuring temperature via a sensor you can use the simple display transform to convert the graph from Fahrenheit to Celsius by entering (x-32)/1.8 into the display transform field. Permitted variables are x (data point) and p (period).
The display transform is set in the metric attributes.
In a chart, click on the menu icon for the metric you want to edit.
When you click on Attributes… it opens up the Metric Attributes pane where there is a field for Transform f. In this example we are transforming the metric to a rate by dividing x by p.
Using the Period (p) in calculations¶
A feature that could prove really useful if you have counters like the ones that collectd reports is the to use p, the period. On display transform functions, in addition to the variable ‘x’ (value to transform) you can also specify ‘p’ to mean the current period, which takes into account the current resolution of the data. Make sure your Period is defined however, as it will default to ‘1’ on the native resolution if unspecified. x/p will give you the rate per second. To get the rate per minute simply use (x/p)*60.
As an example consider the metric ‘collectd.interface.if_octets.eth0.rx’ that counts the number of octets received on the eth0 interface. Specifying a display transform of “(x*8)/1000/1000/p” will now properly graph it as Megabits/second at all resolutions.