Transform->Difference shows always 0

  • What Grafana version and what operating system are you using?
    v11.2

  • What are you trying to achieve?
    I’m trying to get a rate for a Totals metric

  • How are you trying to achieve it?
    Using “Transform data”, “Reduce row” mode, Calculation to “Difference”

  • What happened?
    The Difference is always 0.

  • What did you expect to happen?
    The Difference should NOT be 0

The difference will be 0 because it is comparing the Difference between dropsTotal to itself on same row. What do you expect to be per row?

Oh, it seems that I misunderstood what the Difference should do.

You see, I have this metric that gives me the “total dropped packages” of a given interface. And I need to calculate the RATE of drops. So the math is very simple:

(actualValue-previousValue)/timeDifference

So, it’s a simple rate calculation, and I thought from calculation → “Difference” definition (Difference between first and last value of a field) that it should work).

Is there a way to accomplish that?

what is your data source? influx? mysql?

please share sample data and expected result for this formula

(actualValue-previousValue)/timeDifference

My actual source is a JSON file that is generated every 5 seconds. I use Logstash to feed Elasticsearch. And that is Grafana’s datasource.

Sample data is what you can see in the screenshot in the first post:

  • a timestamp in epoch format
  • a number (the total number of missing packets)

(I’m using other fields for other purposes as well, but they work fine).

So taking for example the last two values of the screenshot (chronologically) and using a DeltaT of 5 seconds:

(699792700 packets-699597596 packets)/5 seconds=39020.8 packets/s

I would go the infinity plugin route and hit ip.address.elastic:9200

using UQL

https://grafana.github.io/grafana-infinity-datasource/docs/uql
to get

1 Like

or use 3 transformations on existing plugin

flip rows to fields

then subtract

Then divide by 5

pretty ugly to me :imp:

both produce

1 Like

Thanks a million times!

The less, the better, so I prefer the second “hack” because I need less software to watch :wink:

1 Like