Global variables

    This variable is the name of the current dashboard.

    $__from and $__to

    Grafana has two built in time range variables: and $__to. They are currently always interpolated as epoch milliseconds by default but you can control date formatting.

    The above syntax works with ${__to} as well.

    You can use this variable in URLs as well. For example, send a user to a dashboard that shows a time range from six hours ago until now: https://play.grafana.org/d/000000012/grafana-play-home?viewPanel=2&orgId=1?from=now-6h&to=now

    $__interval

    Grafana automatically calculates an interval that can be used to group by time in queries. When there are more data points than can be shown on a graph then queries can be made more efficient by grouping by a larger interval. It is more efficient to group by 1 day than by 10s when looking at 3 months of data and the graph will look the same and the query will be faster. The $__interval is calculated using the time range and the width of the graph (the number of pixels).

    Approximate Calculation: (to - from) / resolution

    For example, when the time range is 1 hour and the graph is full screen, then the interval might be calculated to - points are grouped in 2 minute intervals. If the time range is 6 months and the graph is full screen, then the interval might be 1d (1 day) - points are grouped by day.

    In the InfluxDB data source, the legacy variable $interval is the same variable. $__interval should be used instead.

    The InfluxDB and Elasticsearch data sources have Group by time interval fields that are used to hard code the interval or to set the minimum limit for the $__interval variable (by using the > syntax -> >10m).

    This variable is the $__interval variable in milliseconds, not a time interval formatted string. For example, if the $__interval is 20m then the $__interval_ms is .

    $__name

    $__org

    This variable is the ID of the current organization. ${__org.name} is the name of the current organization.

    ${__user.id} is the ID of the current user. ${__user.login} is the login handle of the current user. ${__user.email} is the email for the current user.

    $__range

    Currently only supported for Prometheus and Loki data sources. This variable represents the range for the current dashboard. It is calculated by to - from. It has a millisecond and a second representation called $__range_ms and $__range_s.

    $__rate_interval

    Currently only supported for Prometheus data sources. The $__rate_interval variable is meant to be used in the rate function. Refer to Prometheus query variables for details.

    The $timeFilter variable returns the currently selected time range as an expression. For example, the time range interval Last 7 days expression is time > now() - 7d.

    • The WHERE clause for the InfluxDB data source. Grafana adds it automatically to InfluxDB queries when in Query Editor mode. You can add it manually in Text Editor mode: .
    • Log Analytics queries in the Azure Monitor data source.
    • SQL queries in MySQL, Postgres, and MSSQL.
    • The $__timeFilter variable is used in the MySQL data source.