-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[PoC] Dashboard queries API #173416
Draft
drewdaemon
wants to merge
14
commits into
elastic:main
Choose a base branch
from
drewdaemon:query-extraction-API
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
[PoC] Dashboard queries API #173416
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
This was referenced Jan 24, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
This "move fast and break things" PoC adds an HTTP endpoint for reporting queries that will be run when a particular dashboard is loaded.
Example request
Example response
Video
Screen.Recording.2023-12-14.at.11.43.43.AM.mov
Technical analysis
Key files
RequestAdapter
.Getting Lens code to run on the server
The most time-consuming part of this was preparing the Lens code that creates the expressions to run on the server. Currently, Lens liberally mixes browser-dependent code with env-agnostic code. For example, the datasource and visualization classes, as well as all the operation definitions for the form-based datasource contain expression building logic, state manipulation, and UI components as methods.
The most low-impact way I found to make some of this logic available on the server was to define paired-down interfaces in the common context that only include the things that need to be used server-side and client-side. For example,
DatasourceCommon
looks like this:Then, the existing client-side interfaces can inherit from the common versions (on the implementation side, a spread operator does the trick).
This pattern could be repeated for the form-based datasource's operators.
Other panel types
Each panel type has a distinct architecture and will require a distinct amount of effort (e.g. extracting the query from Vega visualizations is trivial since it is stored in the configuration itself).
In the context of integrations, Lens is by-far the most important panel to support. However, it would be nice to expand. By usage, saved searches are the number-2 panel out of those that initiate a request.
Current PoC Limitations
None of these limitations are fundamental. They simply exist because I ran out of time. I expect most of them to be quite simple to resolve.
Hosting the route in the dashboard app creates a circular dependency with Lens (probably other panel types, too). Probably makes sense to host the route it its own plugin.no longer true as of [Lens] Cleanup, removes dashboard plugin dependency #179245