Why is test data not in sorted time order?

  • What Grafana version and what operating system are you using?
    6.7.4

  • What are you trying to achieve?
    Use the diff() function for alerting

  • How are you trying to achieve it?
    Eval montonic increasing counter every 1m for 5m. Evaluate points from (1h, now). Get the diff and check if there has been any change. IE, diff() > 0.

  • What happened?
    diff() gets negative values when I know it’s not appropriate

  • What did you expect to happen?
    ^^

When I test my alert, I see that the points do not come back in sorted time order. This seems like a problem. As I can’t find any docs on diff(), I checked the code (grafana/reducer.go at main · grafana/grafana · GitHub). It does seem to be doing what I expect. IE query(t1) - query(t0), except t1 and t0 here are not as expected. The test data looks like this -

0:Array[15172,1626882120]
1:Array[15192,1626882900]
2:Array[15257,1626884820]
3:Array[15159,1626881460]
4:Array[15170,1626881940]

Clearly Point 3 and 4 occurred before 0 and 1?

What is going on here?

This topic was automatically closed after 365 days. New replies are no longer allowed.