[ML] Adding index pattern runtime fields to anomaly detection wizards#91168
Conversation
|
@elasticmachine merge upstream |
|
merge conflict between base and head |
…y-detection-wizards
|
@elasticmachine merge upstream |
|
@elasticmachine merge upstream |
…y-detection-wizards
…izards' of github.com:jgowdyelastic/kibana into runtime-fields-from-indexpattern-in-anomaly-detection-wizards
|
Pinging @elastic/ml-ui (:ml) |
x-pack/plugins/ml/public/application/jobs/new_job/common/chart_loader/chart_loader.ts
Outdated
Show resolved
Hide resolved
x-pack/plugins/ml/public/application/jobs/new_job/common/job_creator/job_creator.ts
Outdated
Show resolved
Hide resolved
x-pack/plugins/ml/public/application/jobs/new_job/common/job_creator/job_creator.ts
Outdated
Show resolved
Hide resolved
.../new_job/pages/components/pick_fields_step/components/multi_metric_view/metric_selection.tsx
Outdated
Show resolved
Hide resolved
walterra
left a comment
There was a problem hiding this comment.
Just noticed one of my comments related to code that has just been moved, so changing anything totally optional :)
| const isRollup = Object.keys(rollupFields).length > 0; | ||
| const mix = mixFactory(isRollup, rollupFields); | ||
|
|
||
| aggs.forEach((a) => { |
There was a problem hiding this comment.
All other code in this file is creating new instances of arrays so I wonder if the code here would be more clear if it was using .map() and reassigned to a new aggs instances, what do you think? For me it was a bit hard to follow the code because it's mutating the aggregations. As an alternative maybe add a comment here that this is mutating aggs with the inner forEachs?
There was a problem hiding this comment.
i'm hesitant to change this code at all in this PR as it is not new, I have just moved it from the server side into common so it can be used on the client side.
I should have made this clear in the PR description.
| const jobCreator = jc as MultiMetricJobCreator; | ||
|
|
||
| const { fields } = newJobCapsService; | ||
| const [fields] = useState(sortFields([...newJobCapsService.fields, ...jobCreator.runtimeFields])); |
There was a problem hiding this comment.
Does this need useState if a setFields is never needed? Maybe it doesn't need to be wrapped in useState at all or can make use of useMemo?
| const jobCreator = jc as PopulationJobCreator; | ||
|
|
||
| const { fields } = newJobCapsService; | ||
| const [fields] = useState(sortFields([...newJobCapsService.fields, ...jobCreator.runtimeFields])); |
There was a problem hiding this comment.
Does this need useState if a setFields is never needed? Maybe it doesn't need to be wrapped in useState at all or can make use of useMemo?
| const jobCreator = jc as SingleMetricJobCreator; | ||
|
|
||
| const { fields } = newJobCapsService; | ||
| const [fields] = useState(sortFields([...newJobCapsService.fields, ...jobCreator.runtimeFields])); |
There was a problem hiding this comment.
Does this need useState if a setFields is never needed? Maybe it doesn't need to be wrapped in useState at all or can make use of useMemo?
| const [runtimeCategoryFields] = useState(filterCategoryFields(jobCreator.runtimeFields)); | ||
| const [allCategoryFields] = useState([ | ||
| ...newJobCapsService.categoryFields, | ||
| ...runtimeCategoryFields, | ||
| ]); |
There was a problem hiding this comment.
Does this need useState if a setFields is never needed? Maybe it doesn't need to be wrapped in useState at all or can make use of useMemo?
| const [runtimeCategoryFields] = useState(filterCategoryFields(jobCreator.runtimeFields)); | ||
| const [categoryFields] = useState([ | ||
| ...newJobCapsService.categoryFields, | ||
| ...runtimeCategoryFields, | ||
| ]); |
There was a problem hiding this comment.
Does this need useState if a setFields is never needed? Maybe it doesn't need to be wrapped in useState at all or can make use of useMemo?
💚 Build SucceededMetrics [docs]Module Count
Async chunks
History
To update your PR or re-run it, just comment with: |
|
Backport result |
…elastic#91168) * [ML] Adding index pattern runtime fields to anomaly detection wizards * hook refactor * small refactor of search json * fixing mml estimation error * changes based on review * sorting fields in metric selection * using useMemo rather than useState Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
…#91168) (#91480) * [ML] Adding index pattern runtime fields to anomaly detection wizards * hook refactor * small refactor of search json * fixing mml estimation error * changes based on review * sorting fields in metric selection * using useMemo rather than useState Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: James Gowdy <jgowdy@elastic.co>
Runtime fields which are stored in the index pattern are now automatically added to the datafeed when creating a new anomaly detection job in the wizards.
Currently all of the automatically added fields are left in the datafeed, a follow up PR will add the ability to remove all unused fields from the
runtime_mappingsChecklist
Delete any items that are not applicable to this PR.