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

$__from and $__to changing the rawQuery value in the dashboard and triggering save prompt. #135

Closed
dan-hughes opened this issue Jul 9, 2019 · 3 comments · Fixed by #247, #250 or grafana/grafana-plugin-repository#690
Labels

Comments

@dan-hughes
Copy link

I have the Grafana $__from and $__to built-in variables used in a dashboard panel.
When these change in the dashboard the rawQuery value in the dashboard JSON model changes which is triggering a save changes prompt.

Culprit looks to be here.

Looking at the Grafana datasource plugins these mostly still include any dashboard variables and not the expanded variable values.

I'll look at giving it a go myself but I need to understand how the query or rawQuery is executed.

@hagen1778
Copy link
Collaborator

Hi @dan-hughes !

Thank you for the question!

Query is the query you write in the Grafana query field. RawQuery is a final query which should be executed by ClickHouse after all replacements and modifications. For example, if query contains $timeFilter macros then rawQuery will be populated with current time filters. That means rawQuery is almost always changing with every execution. However, I've never seen issue you mentioned. Are you sure that nothing else were changed?

@dan-hughes
Copy link
Author

dan-hughes commented Jul 19, 2019

Hi @hagen1778,

I do use the $__from and $__to Grafana time variables if this makes any difference but I have tried the clickhouse-grafana $from and $to variables too.

I have opened a dashboard last saved another day and saved the dashboard when prompted and not changed anything else. I have then compared the JSON models for the dashboard from the two saves and the only difference is the variables in the query being updated/expanded. I do use the 'Yesterday/day before yesterday' timeranges, therefore, the time is expected to change each day the dashboard is viewed.

I have looked at another datasource to see what rawQuery is used for. In the InfluxDB datasource for example (which I also use) the rawQuery field is used to determine if the Grafana query editor is in builder mode or raw SQL mode via a bool.

It does not look like they expand any variables out and write them into the dashboard JSON model which then does not trigger a save prompt.

@Slach
Copy link
Collaborator

Slach commented Jul 21, 2020

@dan-hughes
could you share your dashboard JSON or maybe make screencast which captures triggering "save prompt"?

I tried to reproduce use $__from, $__to inside SQL query
"save prompt" doesn't trigger when I change time range in grafana UI

image

Slach added a commit that referenced this issue Jul 24, 2020
# 2.0.3 (2020-07-24)

## Enhancements:
* add setup notes for Grafana 7.x to README
* add SQL preprocessing logic on browser side with <% js code subset %>, #186, thanks @fgbogdan
* improve alerts query processing for use case when `query(query_name, from, to)` time range is less than visible dashboard time range, see #237
* improve alerts json parsing in golang part for case when we have string fields in response which interprets as series name, see #230
* properly parsing POST queries in golang part of plugin, #228, thanks @it1804


## Fixes:
* add Vagrantfile for statefull environment and allow to upgrade scenario like  grafana 7.1.0 + grafana-cli upgrade-all
  * fix #244
  * fix #243
* add multiple dashboard examples for github issues:
  * fix #240 
  * fix #135 
  * fix #245 
  * fix #238   
  * fix #232
  * fix #127
  * fix #141
Slach added a commit to Altinity/grafana-plugin-repository that referenced this issue Jul 24, 2020
## Enhancements:
* add setup notes for Grafana 7.x to README
* add SQL preprocessing logic on browser side with <% js code subset %>, Altinity/clickhouse-grafana#186, thanks @fgbogdan
* improve alerts query processing for use case when `query(query_name, from, to)` time range is less than visible dashboard time range, see Altinity/clickhouse-grafana#237
* improve alerts json parsing in golang part for case when we have string fields in response which interprets as series name, see Altinity/clickhouse-grafana#230
* properly parsing POST queries in golang part of plugin, Altinity/clickhouse-grafana#228, thanks @it1804

## Fixes:
* add Vagrantfile for statefull environment and allow to upgrade scenario like  grafana 7.1.0 + grafana-cli upgrade-all
  * fix Altinity/clickhouse-grafana#244
  * fix Altinity/clickhouse-grafana#243
* add multiple dashboard examples for github issues:
  * fix Altinity/clickhouse-grafana#240
  * fix Altinity/clickhouse-grafana#135
  * fix Altinity/clickhouse-grafana#245
  * fix Altinity/clickhouse-grafana#238
  * fix Altinity/clickhouse-grafana#232
  * fix Altinity/clickhouse-grafana#127
  * fix Altinity/clickhouse-grafana#141

Signed-off-by: Eugene Klimov <eklimov@altinity.com>
Slach added a commit to Altinity/grafana-plugin-repository that referenced this issue Aug 13, 2020
# 2.1.0 (2020-08-13)

## Enhancement:
* add "Skip comments" checkbox to query editor to pass SQL comments to server, fix Altinity/clickhouse-grafana#265
* add setup notes for Grafana 7.x to README
* add SQL preprocessing logic on browser side with <% js code subset %>, Altinity/clickhouse-grafana#186, thanks @fgbogdan
* improve alerts query processing for use case when `query(query_name, from, to)` time range is less than visible dashboard time range, see Altinity/clickhouse-grafana#237
* improve alerts json parsing in golang part for case when we have string fields in response which interprets as series name, see Altinity/clickhouse-grafana#230
* properly parsing POST queries in golang part of plugin, Altinity/clickhouse-grafana#228, thanks @it1804

## Fixes:
* fix corner cases for $macro + subquery, see Altinity/clickhouse-grafana#276 and Altinity/clickhouse-grafana#277
* fix parallel query execution, see Altinity/clickhouse-grafana#273
* fix identifiers quotes, see Altinity/clickhouse-grafana#276, Altinity/clickhouse-grafana#277
* fix plugin.json for pass `grafana-plugin-repository` plugin validator
* fix multi-value variables behavior - Altinity/clickhouse-grafana#252
* add Vagrantfile for statefull environment and allow to upgrade scenario like  grafana 7.1.0 + grafana-cli upgrade-all
  * fix Altinity/clickhouse-grafana#244
  * fix Altinity/clickhouse-grafana#243
* add multiple dashboard examples for github issues:
  * fix Altinity/clickhouse-grafana#240
  * fix Altinity/clickhouse-grafana#135
  * fix Altinity/clickhouse-grafana#245
  * fix Altinity/clickhouse-grafana#238
  * fix Altinity/clickhouse-grafana#232
  * fix Altinity/clickhouse-grafana#127
  * fix Altinity/clickhouse-grafana#141

Signed-off-by: Eugene Klimov <eklimov@altinity.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
3 participants