-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
[Visualizations] Pass 'aggs' parameter to custom request handlers #71423
Conversation
Since this is a community submitted pull request, a Jenkins build has not been kicked off automatically. Can an Elastic organization member please verify the contents of this patch and then kick off a build manually? |
Pinging @elastic/kibana-app-arch (Team:AppArch) |
Jenkins, test this |
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.
Thanks for doing this @fbaligand! Looks like this will close #67916
Add a few comments/questions... LMK what you think
@@ -107,6 +116,7 @@ export const visualization = (): ExpressionFunctionVisualization => ({ | |||
inspectorAdapters, | |||
queryFilter: getFilterManager(), | |||
forceFetch: true, | |||
aggConfigs, |
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.
Could we call this aggs
here instead of aggConfigs
, as this is consistent with the request handler inside of esaggs.ts
, and also with our previous implementation?
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.
OK, I'll do that.
@@ -94,6 +100,9 @@ export const visualization = (): ExpressionFunctionVisualization => ({ | |||
const uiStateParams = args.uiState ? JSON.parse(args.uiState) : {}; | |||
const uiState = new PersistedState(uiStateParams); | |||
|
|||
const aggConfigsState = args.aggConfigs ? JSON.parse(args.aggConfigs) : {}; |
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.
I don't think you want {}
as a fallback here... createAggConfigs
expects an array of serialized agg configs as the aggConfigsState
:
createAggConfigs(
indexPattern: IndexPattern,
configStates: AggConfigSerialized[]
) => IAggConfigs;
So you can probably either fall back to []
, or to undefined
(in which case createAggConfigs
will default to []
anyway).
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.
You're right, I'll put []
here.
Unless you prefer undefined
?
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.
Makes no difference IMHO. Inside createAggConfigs
it will be []
either way
@@ -94,6 +100,9 @@ export const visualization = (): ExpressionFunctionVisualization => ({ | |||
const uiStateParams = args.uiState ? JSON.parse(args.uiState) : {}; | |||
const uiState = new PersistedState(uiStateParams); | |||
|
|||
const aggConfigsState = args.aggConfigs ? JSON.parse(args.aggConfigs) : {}; | |||
const aggConfigs = indexPattern ? getSearch().aggs.createAggConfigs(indexPattern, aggConfigsState) : null; |
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.
Rather than setting to null
here, perhaps we should simply exclude the aggs from the requestHandler
if for some reason no index pattern is present? Then they are basically an optional parameter?
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.
So I set undefined
as default, instead of null
?
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.
Yeah, I guess that's what I'm proposing. Basically so that the argument to the request handler is aggs?: IAggConfigs
instead of aggs: IAggConfigs | null
I don't feel strongly about this though. In the end it won't make a huge difference since the request handler will likely check if (aggs) {...}
the same either way.
Hi @lukeelmers, I just fixed the 3 remarks you told me. |
Jenkins, test this |
@lukeelmers My guess is that I précise that I did manual tests on my machine, and it worked fine. Or else, it is What do you think about? |
@fbaligand My gut reaction is that it's likely one of 2 things:
I will try to run the tests locally tomorrow and see if I can pinpoint the issue |
@lukeelmers |
This comment has been minimized.
This comment has been minimized.
@fbaligand I looked at this -- the issue is indeed from I've updated |
@lukeelmers |
Great! |
* master: (214 commits) replacing hard coded links for ela.st (elastic#72240) skip flaky suite (elastic#60865) chore(NA): teardown dynamic dll plugin (elastic#72096) Register navLink actions for declared applications (elastic#72109) Fix value for process.hash.sha256 draggable (elastic#72142) Call setupIngest before fleet_install tests (elastic#72214) [Security Solution][Detections] Better toast errors (elastic#72205) skip flaky suite (elastic#64696) [Security Solution][Detections] Disable exceptions for Threshold and ML rules (elastic#72137) [Security Solution][Detections,Lists] Miscellaneous post-FF fixes (elastic#71990) [baseline/capture] use high-memory nodes with ramDisks (elastic#71894) skip flaky suite (elastic#77207) [Maps] Fix issue preventing TMS from rendering correctly (elastic#71946) using test_user with minimum privs (elastic#71988) Fixed Webhook connector doesn't retain added HTTP header settings (elastic#71924) [Ingest Manager] Do not show enrolling and unenrolling agents as online in agent counters (elastic#71921) [Maps] fix 'New Map' from getting added to recently accessed (elastic#72125) [Visualizations] Pass 'aggs' parameter to custom request handlers (elastic#71423) [Monitoring] Out of the box alert tweaks (elastic#71942) [ML] Fix datafeed start time is incorrect when the job has trailing empty buckets (elastic#71976) ...
* master: (55 commits) updates 'External alerts' tab text (elastic#72237) [Security Solution][Case] Fix connector's dropdown with conflicting requests (elastic#72037) replacing hard coded links for ela.st (elastic#72240) skip flaky suite (elastic#60865) chore(NA): teardown dynamic dll plugin (elastic#72096) Register navLink actions for declared applications (elastic#72109) Fix value for process.hash.sha256 draggable (elastic#72142) Call setupIngest before fleet_install tests (elastic#72214) [Security Solution][Detections] Better toast errors (elastic#72205) skip flaky suite (elastic#64696) [Security Solution][Detections] Disable exceptions for Threshold and ML rules (elastic#72137) [Security Solution][Detections,Lists] Miscellaneous post-FF fixes (elastic#71990) [baseline/capture] use high-memory nodes with ramDisks (elastic#71894) skip flaky suite (elastic#77207) [Maps] Fix issue preventing TMS from rendering correctly (elastic#71946) using test_user with minimum privs (elastic#71988) Fixed Webhook connector doesn't retain added HTTP header settings (elastic#71924) [Ingest Manager] Do not show enrolling and unenrolling agents as online in agent counters (elastic#71921) [Maps] fix 'New Map' from getting added to recently accessed (elastic#72125) [Visualizations] Pass 'aggs' parameter to custom request handlers (elastic#71423) ...
Looks like this PR has backport PRs but they still haven't been merged. Please merge them ASAP to keep the branches relatively in sync. |
@lukeelmers |
Thanks for the reminder @fbaligand This was my bad -- I totally missed the notifications that the build has passed 🙄 I'm merging each of them with upstream as a precautionary measure to run one more build, and this time will keep an eye out & merge them when they come back green |
I can see now that all backport PRs are merged! Just a last thing: if I’m not wrong, the fix will be out on kibana v7.8.1, not v7.8.2? |
@fbaligand Yeah, currently getting this in 7.8.1 seems likely, but I'm still not 100% certain it will make it in. I will have a better idea next week and will make sure the PR labels are adjusted accordingly. |
@lukeelmers |
@fbaligand I looked into it and, barring any unforeseen circumstances, this should still make 7.8.1. I'll let you know if anything changes. |
Great! |
@fbaligand Just wanted to follow up now that 7.8.1 is released and confirm that the fix is in there 🚀 https://github.com/elastic/kibana/blob/v7.8.1/src/plugins/visualizations/public/legacy/build_pipeline.ts |
Yes, I saw that! |
This PR lets to pass 'aggConfigs' from
build_pipeline.ts
tovisualization_function.ts
, so thatvisualization_function.ts
can pass it to visualizationrequestHandler
.It is useful for a custom
requestHandler
to haveaggConfigs
, to do a Elasticsearch query.Especially since
build_pipeline.ts
pass 'aggConfigs' toesaggs.ts
and thatrequestHandler
lets to customize the Elasticsearch query (and/or response transformation) done byesaggs.ts
:https://github.com/elastic/kibana/blob/master/src/plugins/visualizations/public/legacy/build_pipeline.ts#L514
Closes #67916