Grafana difference between two datapoints

13,967

You need to use the derivative function

This is the opposite of the integral function. This is useful for taking a running total metric and calculating the delta between subsequent data points.

This function does not normalize for periods of time, as a true derivative would. Instead see the perSecond() function to calculate a rate of change over time.

Together with the keepLastValue

Takes one metric or a wildcard seriesList, and optionally a limit to the number of ‘None’ values to skip over.

Continues the line with the last received value when gaps (‘None’ values) appear in your data, rather than breaking your line.

Like this

derivative(keepLastValue(your_mteric))

A good example can be found here http://www.perehospital.cat/blog/graphite-getting-derivative-to-work-with-empty-data-points

Share:
13,967

Related videos on Youtube

Lou_Ds
Author by

Lou_Ds

Updated on June 04, 2022

Comments

  • Lou_Ds
    Lou_Ds almost 2 years

    In a Graphana dashboard with several datapoints, how can I get the difference between the last value and the previouse one for the same metric? Perhaps the tricky part is that the tiem between 2 datapoins for the same metric is not know.

    so the desired result is the <metric>.$current_value - <metric>.$previouse_value for each point in the metricstring.

    Edit: The metrics are stored in graphite/Carbon DB.

    thanks

    • AussieDan
      AussieDan over 5 years
      Which data source are you using?
    • Lou_Ds
      Lou_Ds over 5 years
      The metrics are stored in graphite/Carbon DB.