Support seting dynamic time duration
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
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.
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.
FYI, the functionality described in this comment has been included in VictoriaMetrics v1.92.0.