Introduce $__range variable to monitoring dashboard
Problem to solve
In Grafana there's a $__range
variable that can be used instead of specifying a time range in a query. This variable to the date/time range picker in the upper right corner of the screen. An example of a query that uses this would be
avg_over_time(sla:gitlab:ratio{environment="gprd", stage="main"}[$__range])
Intended users
Further details
We need to consider introducing this kind of variable, because even when you have a 7d
(7 days) query range, if the date time range picker in our monitoring solution doesn't match those 7 days the results of the query will still be filtered out by the range selected in the date time range picker.
Proposal
By introducing a $__range
variable equivalent we need to make sure the date time picker reflects the option accordingly. A plus and a possible follow up issue would be to add the possibility to define a default range in the custom dashboard yaml file definitions.
Links / references
https://prometheus.io/docs/prometheus/latest/querying/basics/#range-vector-selectors
https://grafana.com/docs/grafana/latest/reference/templating/#the-range-variable
Testing
Please trigger the job package-and-qa
on the MR of this issue