-
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
[ML] Extends support for anomaly charts when model plot is enabled #34079
[ML] Extends support for anomaly charts when model plot is enabled #34079
Conversation
Pinging @elastic/ml-ui |
💚 Build Succeeded |
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 couple of comments, but generally it all LGTM
// of objects in the form { fieldName: airline, fieldValue: AAL, fieldType: partition } | ||
export function getEntityFieldList(record) { | ||
const entityFields = []; | ||
if (_.get(record, 'partition_field_name') !== 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.
Using _.get
for these checks unnecessary IMO.
this check could just be record.partition_field_name !== undefined
.
Edit:
I just noticed this code was moved from somewhere else. so ignore this if you don't want the code churn.
At some point we should look to review _.get
usage as it was flagged by kibana as potentially dangerous due to prototype pollution. If we ever use it to get a user defined key, that should change.
I'd also personally like to change any situations like the one above where it's being used to get a single, non-nested key, as it's unnecessary and adds complexity.
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.
Agreed. Seeing as this is a new function, I'll switch the _.get
to e.g. record.partition_field_name
here.
// plus varp and info_content functions. | ||
isModelPlotChartable = (mlFunctionToESAggregation(functionName) !== null) || | ||
(['varp', 'high_varp', 'low_varp', 'info_content', | ||
'high_info_content', 'low_info_content'].indexOf(functionName) > -1); |
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.
.includes
rather than .indexOf
could be used here.
Doesn't gain anything really, but i think it reads a bit better.
$scope.hasResults = false; | ||
$scope.loading = false; | ||
$scope.dataNotChartable = true; | ||
$scope.$applyAsync(); |
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.
it doesn't look like a promise is being used in this code, is this $applyAsync
needed?
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.
Yes this $applyAsync
is needed. When you are viewing an entity which triggers this block, if you then hard refresh the page, the $applyAsync
is needed to get the view to update correctly and show the correct error message on initial load.
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
💚 Build Succeeded |
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 ⚡
…lastic#34079) * [ML] Extends support for anomaly charts when model plot is enabled * [ML] Edits to util functions following review
Summary
Previously anomaly charts were only shown in the Anomaly Explorer, and a detector was only visible in the Single Metric Viewer, if the detector
function_description
was one ofmean
,min
,max
,sum
,count
,distinct_count
,median
, orrare
and the detector did not use a scripted field that was defined in the datafeed configuration.If model plot has been enabled, this PR extends support for charts in the Anomaly Explorer, and the detector is visible in the Single Metric Viewer, to detectors where:
field_name
of the detector is a script field defined in the datafeed configurationfunction_description
of the detector isvarp
function_description
of the detector isinfo_content
mlcategory
e.g. of a chart in the Anomaly Explorer for an
info_content
job where model plot has been enabled:Checklist
For maintainers
See #22922.
Fixes #32124.