0

I'm trying to figure out how the Graphite summarize function works. I've the following data points, where X-axis represents time, and Y-axis duration in ms.

+-------+------+
|   X   |  Y   |
+-------+------+
| 10:20 |    0 |
| 10:30 | 1585 |
| 10:40 |  356 |
| 10:50 |    0 |
+-------+------+

When I pick any time window on Grafana more than or equal to 2 hours (why?), and apply summarize('1h', avg, false), I get a triangle starting at (9:00, 0) and ending at (11:00, 0), with the peak at (10:00, 324).

A formula that a colleague came up with to explain the above observation is as follows.

Let: a = Number of data points for a peak, in this case 4. b = Number of non-zero data points, in this case 2.

Then avg = sum / (a + b). It produces (1585+356) / 6 = 324 but doesn't match with the definition of any mean I know of. What is the math behind this?

Abhijit Sarkar
  • 21,927
  • 20
  • 110
  • 219

1 Answers1

0

Your data is at 10 minute intervals, so there are 6 points in each 1hr period. Graphite will simply take the sum of the non-null values in each period divided by the count (standard average). If you look at the raw series you'll likely find that there are also zero values at 10:00 and 10:10

AussieDan
  • 2,116
  • 15
  • 11
  • Data is sent every 10 sec, so there are 360 data points in an hour, most zero. – Abhijit Sarkar Jul 14 '18 at 16:47
  • There is a difference between a null value and a zero value, in general Graphite aggregation functions (like summarize) discard null values but use zero values. The best way to understand how Graphite functions work is to read the source, in this case https://github.com/graphite-project/graphite-web/blob/master/webapp/graphite/render/functions.py#L4716-L4816 – AussieDan Jul 16 '18 at 00:53
  • I’m using `transformNull(0)`, so there are only zeros, no null. – Abhijit Sarkar Jul 16 '18 at 05:01