-
Notifications
You must be signed in to change notification settings - Fork 8.5k
[ML] Improve support for script and aggregation fields in anomaly detection jobs #81923
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
[ML] Improve support for script and aggregation fields in anomaly detection jobs #81923
Conversation
…ggregation-fields
|
Pinging @elastic/ml-ui (:ml) |
jgowdyelastic
left a comment
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.
Added a few minor comments, but generally LGTM
I'll approve once i've tested it.
| } from '../../datavisualizer/index_based/common'; | ||
| import { DataRecognizerConfigResponse, Module } from '../../../../common/types/modules'; | ||
| import { | ||
| DatafeedOverride, |
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.
DatafeedOverride is for overriding the datafeed config when calling the module setup and so i don't think should be used here.
It looks like the standard Datafeed interface would be better suited throughout this PR.
| terms: { | ||
| field: 'influencer_field_value', | ||
| size: maxResults !== undefined ? maxResults : 2, | ||
| size: !!maxResults ? maxResults : 2, |
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.
this change is subtle but using a falsey check like !! rather than an explicit check for undefined changes its behaviour.
if maxResults is 0 it would now default to 2
Not that 0 is a sensible number, it's just generally dangerous IMO using falsey checks for variables that are numbers.
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.
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.
Updated here 7355559
| fields: fieldNames, | ||
| }); | ||
| const aggregatableFields: string[] = []; | ||
| const datafeedAggConfig = datafeedConfig?.aggregations ?? datafeedConfig?.aggs; |
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.
nit, datafeedAggregations or even just aggregations might be a better name for this as datafeedAggConfig is a bit too similar to datafeedConfig. I missed the difference when first reading it.
The same in other files in this PR.
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.
Updated here f54c8e8
|
|
||
| // if datafeed has aggregation, require job config to include a valid summary_doc_field_name | ||
| const datafeedAggConfig = job.datafeed_config?.aggregations ?? job.datafeed_config?.aggs; | ||
| if (datafeedAggConfig !== undefined && !job.analysis_config?.summary_count_field_name) { |
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.
in the two conditions here, one checks for undefined and one checks for !.
Is there a reason for the difference? or could they both be undefined checks?
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 see that this was two ifs combined based on a previous comment.
being a fussy nitpicker i think they should be the same so not to raised questions further down the line.
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.
Updated here f54c8e8
…ggregation-fields
jgowdyelastic
left a comment
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
|
@elasticmachine merge upstream |
peteharverson
left a comment
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.
Tested and LGTM.
In the follow-up we should try and disable links to the Single Metric Viewer for the configs which we don't support and provide e.g. a callout in the Anomaly Explorer to explain why we aren't displaying anomaly charts.
|
@elasticmachine merge upstream |
💚 Build SucceededMetrics [docs]Module Count
Async chunks
Distributable file count
History
To update your PR or re-run it, just comment with: |
…ection jobs (elastic#81923) Co-authored-by: Kibana Machine <[email protected]>
…ly detection jobs (#81923) (#83569) Co-authored-by: Kibana Machine <[email protected]> Co-authored-by: Kibana Machine <[email protected]>
* master: (51 commits) [ML] Persisted URL state for the Data frame analytics jobs and models pages (elastic#83439) adds xpack.security.authc.selector.enabled setting (elastic#83551) skip flaky suite (elastic#77279) [ML] Improve support for script and aggregation fields in anomaly detection jobs (elastic#81923) [Workplace Search] Migrate SourcesLogic from ent-search (elastic#83544) [ML] Add UI test for feature importance features (elastic#82677) [Maps] Improve icons for all layer types (elastic#83503) Replace experimental badge with Beta (elastic#83468) [Fleet][EPM] Unified install and archive (elastic#83384) Move src/legacy/server/keystore to src/cli (elastic#83483) Used SO for saving the API key IDs that should be deleted (elastic#82211) [Uptime] Mock implementation to account for math flakiness test (elastic#83535) [Workplace Search] Enable check for org context based on URL (elastic#83487) [App Search] Added all Document related routes and logic (elastic#83324) [Alerting UI] Fix console error when setting connector params (elastic#83333) [Discover] Allow custom name for fields via index pattern field management (elastic#70039) [Uptime] Fix monitor list down histogram (elastic#83411) remove headers timeout hack, rely on nodejs timeouts (elastic#83419) [ML] Update console autocomplete for ML data frame evaluate API (elastic#83151) [Lens] Color in dimension trigger (elastic#76871) ...

Summary
This PR improves support for anomaly charts in the Anomaly Explorer and Single Metric Viewer for jobs which use scripted or aggregation fields in their datafeed configuration and where model plot is not enabled.
script_fieldas apartition_field_namefails validation in anomaly detection advanced job wizard[ML] Using a
script_fieldas apartition_field_namefails validation in AD advanced job wizard #76075 (we now check for the cardinality using the whole script_field)Before

After

Fix datafeed preview to work when something else other than
bucketsis used for aggregationFix anomalies chart advanced wizard not validating correctly for datafeed configs with nested aggregations
Also contains a fix for anomalies not showing in Anomaly Explorer charts when no influencer detected:
Before

After

Note that the following items will be addressed in a follow-up:
bucketsis usedChecklist
Delete any items that are not applicable to this PR.