2

Image that we have a time series with timestamps t_1, t_2 ... t_n. And a metric m with values m_1, m_2 ... m_n for the respective timestamps. Metric m is a counter so it will only increase. Then there is a second metric k that is calculated from two nearby measures of m:

k(n) = m(n) - m(n - 1)

Basically k indicates the difference between two m measurements. For example: n | 1 | 2 | 3 | 4 | m | 10 | 10 | 15 | 16 | k | 0 | 0 | 5 | 1 |

What would be the query to OpenTSDB or Bosun that will return k based on m.

So far, I've only found rate feature but it is limited in showing rate per minute and it doesn't show the actual difference.

m3nthal
  • 413
  • 5
  • 14
  • The rate function in OpenTSDB returns a per second rate. It does this by taking the difference in value, and dividing it by the difference in time (derivative). There isn't a function like this because it isn't assume time is consistent, and without that showing the difference doesn't seem to have much use? What is your use case? – Kyle Brandt Nov 29 '17 at 03:09
  • @KyleBrandt The use case is to see the difference between two data points no matter how far apart where the points. The rate function will do the following: `(v2 - v1) / (t2 - t1)`. I would like to see just `(v2-v1)`. – m3nthal Nov 29 '17 at 13:11
  • I understand the functional difference, I'm asking for a user story as to why you would want to do that? – Kyle Brandt Nov 29 '17 at 13:13
  • @KyleBrandt I have a metric that has millions in numbers but it not constantly growing, but when it grows I would like to see how much it grew. On a graph that is between 0 and 3 million the difference of 3 is not visible and rate 3/30=0.1 doesn't tell me the information I want to know: the metric has grown by 3 in 30 seconds or whatever time frame I would set. If I set the interval to days, it will show the difference per day in the metric. – m3nthal Nov 29 '17 at 13:30
  • @m3nthal I have the same use case. I have a graph of a metric displayed in grafana. No matter what the first value (v1) is in the time series, I'd like the value to be plotted at 0, 0. I'd like the last value, v(n) to be plotted at n, v(n) - v(1). In the case, the value is the number of errors that occurred and I'm basically seeing how many occurred since time specified for V1. – DaEagle Jun 20 '18 at 19:31
  • @DaEagle so far, I am using rate/counter functionality in Grafana, and if you have fixed interval you can multiply rate by the interval to get the difference – m3nthal Jun 21 '18 at 10:32

1 Answers1

0

You can try Axibase Time Series Database which is compatible with tcollector and scollector protocols and provides a rate transformation to calculate the deltas. The rate transformation returns the difference between consecutive values if the interval is set to 0. There is a boolean flag that controls how counter resets (negative deltas) are handled.

Here's a live example.

More details are available in this tutorial.

enter image description here

Sergei Rodionov
  • 4,079
  • 6
  • 27
  • 44