Open gabor opened 2 years ago
i found some additional info that i added to the issue (the fact that this happens only when min-interval is involved)
This issue has been automatically marked as stale because it has not had activity in the last year. It will be closed in 30 days if no further activity occurs. Please feel free to leave a comment if you believe the issue is still relevant. Thank you for your contributions!
(seems this never got assigned to a squad, i assigned it to plugins-platform, as they own rangeUtil.ts
, feel free to assign it to a better owner, thanks!)
in a dashboard, let's say you set the
min-interval
to70s
, and choose a time-range of 30 minutes:$__interval
will be1m
$__interval_ms
will be70000
in other words,
$__interval
is rounded to a "nice" number, but$__interval_ms
is kept at the "exact" value.the problem is in this code: https://github.com/grafana/grafana/blob/main/packages/grafana-data/src/datetime/rangeutil.ts#L288-L291 , as you see
intervalMs
is taken as-is, but theinterval
value goes through some "rounding".please note, this problem only happens when min-interval is involved, because if there is no min-interval, the
intervalMs
calculated at https://github.com/grafana/grafana/blob/main/packages/grafana-data/src/datetime/rangeutil.ts#L284 is also rounded, so in a way, when there is no min-interval:intervalMs
is rounded onceinterval
is rounded two times with slightly different rules, which will usually keep it the same as the single-roundedintervalMs
(still, this is quite fragile, i'd recommend not relying on this fact)the documentation for
$__interval_ms
says: "This variable is the $interval variable in milliseconds" ( https://grafana.com/docs/grafana/latest/variables/variable-types/global-variables/#interval_ms ). that is not correct currently.NOTE: there is also the additional problem, that, we specified a min-interval of
70s
, and theinterval
becomes1m
, which is lower than the requested min-interval.