-
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] Entity filter for the Notifications page #142778
[ML] Entity filter for the Notifications page #142778
Conversation
Pinging @elastic/ml-ui (:ml) |
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, added some minor comments, but overall LGTM
}, newQuery); | ||
} | ||
|
||
onChange!(newQuery); |
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.
if there is a risk onChange
might be undefined
, it might be safer to wrap this in a check.
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 is an issue with the types provided by import type { CustomComponentProps } from '@elastic/eui/src/components/search_bar/filters/custom_component_filter';
. onChange
is always defined in this case.
import { countBy } from 'lodash'; | ||
import { useMlApiContext } from '../../contexts/kibana'; | ||
|
||
type EntityType = 'anomaly_detector' | 'data_frame_analytics' | 'trained_models'; |
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 other places in the notifications page inference
is used.
I wonder if we're introducing confusion by using the label Trained models
in this menu, even though it's probably clearer and we used Trained model
everywhere else in the UI.
It's a shame the notifications use inference
as the type.
Not asking for a change here, just thinking out loud.
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.
Agree, it's indeed confusing. Everywhere in the UI code, I refer to this as trained models
.
On the data level for the .ml-notifications*
it's inference
, hence I decided to keep it this way. If I'm not mistaken it's the only exception in the user-facing labels so far.
x-pack/plugins/ml/public/application/notifications/components/ml_entity_selector.tsx
Outdated
Show resolved
Hide resolved
x-pack/plugins/ml/public/application/notifications/components/ml_entity_selector.tsx
Outdated
Show resolved
Hide resolved
import { MlEntitySelector, MlEntitySelectorProps } from './ml_entity_selector'; | ||
|
||
/** | ||
* Custom filter component to use with {@link EuiInMemoryTable} |
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.
Is this component limited to working with notifications only? If not, could it be moved to the top-level components
folder?
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 presume this is the only use case for this component, so I'd rather keep it as is for now.
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! We can always move it at a later date when we find another use case for it.
x-pack/plugins/ml/public/application/notifications/components/ml_entity_selector.tsx
Outdated
Show resolved
Hide resolved
x-pack/plugins/ml/public/application/notifications/components/ml_entity_selector.tsx
Outdated
Show resolved
Hide resolved
x-pack/plugins/ml/public/application/notifications/components/ml_entity_selector.tsx
Outdated
Show resolved
Hide resolved
x-pack/plugins/ml/public/application/notifications/components/notifications_list.tsx
Show resolved
Hide resolved
isLoading={isLoading} | ||
singleSelection={!multiSelect} | ||
selectedOptions={selectedEntities} | ||
options={options} |
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.
Note that I hadn't synchronized the saved objects for the gallery_delete
job here. Therefore the old saved object for this job still existed. Do you think we should be showing notifications for a deleted job in this case @jgowdyelastic ?
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.
Not sure it's possible, because of the space awareness. It'd require an extra API call to retrieve all unique terms for job_id
from .ml-notifications*
, but eventually, we won't be able to resolve what IDs are available for the user (because Kibana saved objects are already deleted).
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 think the alternative is too tricky to implement. We'd have to check every job to see whether it does still exist.
Just to clarify what's happening here...
When a job is deleted, it happens in the background in es, Kibana does not know when the job has actually been deleted so we can't be sure when to delete the saved object.
It was decided that leaving these orphaned saved objects behind was not a problem. They are deleted on sync or when a new job arrives with the same name.
The reason gallery_delete
is showing up here is because the saved object still exists.
IMO the behaviour here is ok. It's not ideal, but the alternative of checking whether a job really still exists before listing its messages would add an overhead.
💚 Build Succeeded
Metrics [docs]Module Count
Async chunks
History
To update your PR or re-run it, just comment with: cc @darnautov |
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 latest changes and LGTM
Summary
Even though it's possible to add
job_id
to the query string from the beginning, it wasn't obvious due to lacking of the UI filter.This PR adds a custom control that allows selection of different ML entities.
What's supported
Corner cases
There is no uniqueness of entity IDs across different types, i.e. it's possible to have anomaly detection and data frame analytics jobs with the same ID, e.g.
my_job
. In this case, the entity picker will highlight all entities with provided ID as selected that mentioned in the query string.Checklist