When working with Metrics in Sumo you can perform basic math operations (+, -, *, /) on query results. Math expressions support the same set of functions as the eval operator so you can use sin, cos, abs, log, round, ceil, floor, tan, exp, sqrt, min, and max.
For example, if you are ingesting network information, you could use metrics queries and math operations to chart the net difference of incoming and outgoing network traffic.
Open a new Metrics window
In the first row, define the incoming traffic as the result of rate and sum (to simplify the data). This will become our variable #A, please notice you do not need to declare #A as a variable, just Enter the following:
Metric Net_InBytes, Operators: rate, sum
Note to add an operator to a query select the grey plus sign
By virtue of adding this query to the first line, we can refer back to it as #A. Any query on the second line can be referenced as #B and so on.
To create a second row, click on the + icon (Add Query) on the far right of Line #A. A second row will be created. define the outgoing traffic as the result of rate and sum (to simplify the data). This will become our variable #B, please notice you do not need to declare #B as a variable. Enter:
Metric Net_OutBytes, Operators: rate sum
Next we need to subtract row #A from #B. To do so we will create a third row, by clicking on the +icon (Add Query) on the far right of Line #B. This will become our variable #C.
Now we want to utilize Advanced Mode to enter the query that will subtract row #A from row #B. To enable Advanced Mode for Row #C, go to the far right and click on the details icon (3 vertical dots) and select Advanced Mode
Once Advanced Mode is enabled for Row #C, enter:
#B - #A
NOTE: The query is case-sensitive, it should be #B-#A not #b-#a.
Finally hide the A and B rows, so that your visualization only shows the difference. To do, so click on #A and #B
You now have a basic line chart of your rate of traffic over time.