Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

$__range uses dashboard range, not overwritten panel range #17102

Closed
patrick246 opened this issue May 15, 2019 · 2 comments · Fixed by #17352
Closed

$__range uses dashboard range, not overwritten panel range #17102

patrick246 opened this issue May 15, 2019 · 2 comments · Fixed by #17352

Comments

@patrick246
Copy link
Contributor

What happened: Dashboard is set to Last 6 hours, panel is set to This month so far (now/M). The $__range variable is used in a Prometheus query. Start and end parameters are correct, however, $__range evaluates to 6h.

What you expected to happen: $__range should evaluate to the overridden range

How to reproduce it (as minimally and precisely as possible): Setup a new dashboard, add a new panel, override relative time and use $__range in the query. Then use the query inspector to view the replacement for $__range

Anything else we need to know?: Grafana is running in Docker

Environment:

  • Grafana version: Grafana v6.1.6 (commit: cf9cb45)
  • Data source type & version: Prometheus, Version 2.9.1
  • OS Grafana is installed on: Linux *** 4.15.0-47-generic constantLine() function doesn't work #50-Ubuntu SMP Wed Mar 13 10:44:52 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux as Docker host, Linux bef47d8138a2 4.15.0-47-generic constantLine() function doesn't work #50-Ubuntu SMP Wed Mar 13 10:44:52 UTC 2019 x86_64 GNU/Linux in Docker container
  • User OS & Browser: OS: Linux *** 4.15.0-48-generic PR for issue 24 #51-Ubuntu SMP Wed Apr 3 08:28:49 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux, Browser:
  • Grafana plugins:
    • Alert List
    • Azure Monitor
    • Carpet plot
    • CloudWatch
    • Dashboard list
    • Discrete
    • Elasticsearch
    • Gauge
    • Getting Started
    • Graph
    • Graphite
    • Heatmap
    • InfluxDB
    • Loki
    • Microsoft SQL Server
    • MySQL
    • OpenTSDB
    • Plugin list
    • PostgreSQL
    • Prometheus
    • Singlestat
    • Stackdriver
    • Sun and Moon
    • Table
    • TestData DB
    • Text
  • Others: Running in Docker (Image f96bf1723e2a)
@torkelo
Copy link
Member

torkelo commented May 28, 2019

So if anyone wants to start on this, setup a prometheus data source and issue a query using $__range in a range vector. Use Query inspector to see what it get's interpolated to.

Below the queries specify a panel relative time override. This changes the panel time range
and it should affect the $__range variable.

The reason it does not is that this code:
https://github.com/grafana/grafana/blob/master/public/app/plugins/datasource/prometheus/datasource.ts#L369

uses timeSrv.timeRange() instead of taking in the time range as function arg (the query method gets a time range), pass the query time range to this function and use that.

@patrick246
Copy link
Contributor Author

What are the next steps on this issue?

Frontend Platform Backlog automation moved this from Bugs & Investigations to Done Jun 6, 2019
torkelo pushed a commit that referenced this issue Jun 6, 2019
…d range (#17352)

The range variables get filled with the range from the query options,
not with the range in the timeSrv object. This means that panels that
use a relative time override get the correct values from the __range
variables.

Fixes #17102
@torkelo torkelo added this to the 6.3 milestone Jun 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants