-
Notifications
You must be signed in to change notification settings - Fork 11.8k
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
Datasource: Change query filtering #84656
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
grafana-dataChangesDataSourceApi.importQueries/home/runner/work/grafana/grafana/pr/grafana-data/dist/index.d.ts Parameter type changed:
* public/app/features/datasources/state/actions.ts
*/
abstract testDatasource(): Promise;
/**
- * This function is not called automatically unless running within the DataSourceWithBackend
- *
- * @deprecated
+ * Optionally, you can implement this method to prevent certain queries from being executed.
+ * Return false to prevent the query from being executed.
*/
filterQuery?(query: TQuery): boolean;
/**
* Get hints for query improvements grafana-runtimeRemovalsDataSourceWithBackend.filterQuery/home/runner/work/grafana/grafana/base/grafana-runtime/dist/index.d.ts filterQuery?(query: TQuery): boolean; |
11faa90
to
02448f4
Compare
mckn
approved these changes
Mar 20, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
ifrost
approved these changes
Mar 21, 2024
3 tasks
This was referenced Mar 22, 2024
3 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
add to changelog
area/backend
area/explore
area/frontend
breaking change
Relevant for changelog generation
datasource/Azure
Azure Monitor Datasource
datasource/CloudWatch
datasource/Elasticsearch
datasource/GoogleCloudMonitoring
datasource/grafana-pyroscope
Grafana pyroscope datasource (previously Phlare)
datasource/Loki
datasource/MySQL
datasource/Postgres
datasource/Tempo
levitate breaking change
A label indicating a breaking change and assigned by Levitate.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What is this feature?
This PR changes query filtering in data source plugins. There are two noticeable changes:
Responses associated with hidden queries will be removed automatically by Grafana
Starting from Grafana 11, responses that are associated with queries where
hide: true
will be removed by Grafana. Queries wherehide: true
will still be executed (unless they're prevented from it in the data sourcefilterQuery
method), but the associated responses will no longer be passed to the panel. To align the UI with this behaviour (and with the DataQuery model), the tooltip in the query editor row is changed fromDisable query
toHide/Show response
.The
datasource.filterQuery
method will be called from the query runnerData source plugins that extended
DataSourceWithBackend
could optionally implementfilterQuery
to prevent certain queries from being executed. The filterQuery method was called fromwithin thequery
method in theDataSourceWithBackend
class. Not all data source plugins extendsDataSourceWithBackend
, and this led to inconsistencies in how filtering worked between different types of data source plugins.From Grafana 11, the
filterQuery
method is called from the query runner before the data source query method is called. This means query filtering now works in a consistent way for all types of data source plugins.For data source plugins that extend
DataSourceWithBackend
, it means they can no longer test query filtering by calling thequery
method, as filtering occurs at an earlier stage in the query execution flow.Why do we need this feature?
To harmonize query execution flow in backend- and non backend data source plugins and clarify the purpose of the
Hide/Show response
button for plugin authors and end-users.Who is this feature for?
Plugin authors and end-users
Which issue(s) does this PR fix?:
Fixes #80531
Release notice breaking change
For data sources that extend
DataSourceWithBackend
, thefilterQuery
method is now called before the data sourcequery
method. If thefilterQuery
method assumes that some kind of query migration happens before this method is called, you now need to do the migration inside this method.Users of data source plugins that did not previously remove hidden queries will see a change of behaviour: Before this change, clicking the
Disable query
button had no impact on the query result, but starting from Grafana 11 responses associated with hidden queries will no longer be returned to the panel.