metricsql icon indicating copy to clipboard operation
metricsql copied to clipboard

Support seting dynamic time duration

Open ColinChen2 opened this issue 3 years ago • 3 comments

We want set dynamic time duration when generate recoding rules, support using variable during e.g.

  • with (a = 2h) (up{job="samples"}[a])
  • with (a = "2h") (up{job="samples"}[a])
  • with (hours = (day_of_month() - 1) * 24 + hour() + "h") (up{job="samples"}[hours])

related issue: dynamic time duration

ColinChen2 avatar Mar 28 '23 09:03 ColinChen2

FYI, the commit f3dd382e41eb1a07d94a72618d4323cd1fd4d049 adds support for specifying duration values via WITH templates. However, it doesn't support the ability to specify dynamic duration, which depend on the evaluation timestamp. See this comment for details.

valyala avatar Jul 19 '23 22:07 valyala

FYI, the commit f3dd382 adds support for specifying duration values via WITH templates. However, it doesn't support the ability to specify dynamic duration, which depend on the evaluation timestamp. See this comment for details.

Thanks for the reply!

To the clear, our case is to calculate SLO/SLI based on a calendar-window, for example, SLO for July. And due to the complexity of the query expression, we would like to use RecordingRules to pre-calculate the result (by aggregating windows). So the dynamic window is necessary in this case.

But what you proposed in the comment seems to be promising and fit our case well. I would like to try to implement this in MetricsQL.

lujiajing1126 avatar Jul 20 '23 01:07 lujiajing1126

FYI, the functionality described in this comment has been included in VictoriaMetrics v1.92.0.

valyala avatar Jul 28 '23 00:07 valyala