-
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] Add option to Advanced Settings to set default time range filter for AD jobs #76347
Conversation
@@ -5,3 +5,5 @@ | |||
*/ | |||
|
|||
export const FILE_DATA_VISUALIZER_MAX_FILE_SIZE = 'ml:fileDataVisualizerMaxFileSize'; | |||
export const ANOMALY_DETECTION_ENABLE_TIME_RANGE = 'ml:anomalyDetectionDefaultTimeRangeEnable'; |
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.
Setting the name this way because seems like the settings are ordered by these strings alphabetically.
@@ -5,3 +5,5 @@ | |||
*/ | |||
|
|||
export const FILE_DATA_VISUALIZER_MAX_FILE_SIZE = 'ml:fileDataVisualizerMaxFileSize'; | |||
export const ANOMALY_DETECTION_ENABLE_TIME_RANGE = 'ml:anomalyDetectionDefaultTimeRangeEnable'; | |||
export const ANOMALY_DETECTION_DEFAULT_TIME_RANGE = 'ml:anomalyDetectionDefaultTimeRangeSet'; |
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.
Since this setting looks very similar to timepicker:timeDefaults
, I wonder if we should give it a similar name?
export const ANOMALY_DETECTION_DEFAULT_TIME_RANGE = 'ml:anomalyDetectionDefaultTimeRangeSet'; | |
export const ANOMALY_DETECTION_DEFAULT_TIME_RANGE = 'ml:anomalyDetectionTimeDefaults'; |
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've added some text suggestions.
@@ -30,5 +34,41 @@ export function registerKibanaSettings(coreSetup: CoreSetup) { | |||
}), | |||
}, | |||
}, | |||
[ANOMALY_DETECTION_ENABLE_TIME_RANGE]: { | |||
name: i18n.translate('xpack.ml.advancedSettings.enableAnomalyDetectionDefaultTimeRangeName', { | |||
defaultMessage: 'Enable default time range for anomaly detection jobs.', |
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 I'm understanding correctly and these two settings must be used together, I suggest synching the title more closely:
defaultMessage: 'Enable default time range for anomaly detection jobs.', | |
defaultMessage: 'Enable time filter defaults', |
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 changed it to 'Enable time filter defaults for anomaly detection jobs' because this setting is specific to that area
description: i18n.translate( | ||
'xpack.ml.advancedSettings.anomalyDetectionDefaultTimeRangeDesc', | ||
{ | ||
defaultMessage: 'Use a default time range to view anomaly detection jobs.', |
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 I'm understanding correctly that this applies only to specific interfaces, I suggest we mention them here:
defaultMessage: 'Use a default time range to view anomaly detection jobs.', | |
defaultMessage: 'Use the default time filter in the Single Metric Viewer and Anomaly Explorer.', |
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 41af491
description: i18n.translate( | ||
'xpack.ml.advancedSettings.anomalyDetectionDefaultTimeRangeDesc', | ||
{ | ||
defaultMessage: 'The default time range to view anomaly detection jobs.', |
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 suggest we use text closer to what's used for the timepicker:timeDefaults. For example:
defaultMessage: 'The default time range to view anomaly detection jobs.', | |
defaultMessage: 'The time filter selection to use when viewing anomaly detection job results.', |
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 41af491
description: i18n.translate( | ||
'xpack.ml.advancedSettings.anomalyDetectionDefaultTimeRangeDesc', | ||
{ | ||
defaultMessage: 'The default time range to view anomaly detection jobs.', |
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.
The default time range...
If you want a link to the list of accepted formats, perhaps it can be copied from the way data.advancedSettings.timepicker.quickRangesText uses {acceptedFormatsLink} in ui_settings.ts. I'm not convinced that link is necessary here, however.
@@ -5,3 +5,5 @@ | |||
*/ | |||
|
|||
export const FILE_DATA_VISUALIZER_MAX_FILE_SIZE = 'ml:fileDataVisualizerMaxFileSize'; | |||
export const ANOMALY_DETECTION_ENABLE_TIME_RANGE = 'ml:anomalyDetectionDefaultTimeRangeEnable'; |
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 you accept my suggestion for renaming the other setting, this one should be updated to match:
export const ANOMALY_DETECTION_ENABLE_TIME_RANGE = 'ml:anomalyDetectionDefaultTimeRangeEnable'; | |
export const ANOMALY_DETECTION_ENABLE_TIME_RANGE = 'ml:anomalyDetectionTimeDefaultsEnable'; |
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 4155201 ... although now the order is changed where the toggle to set it comes after the json field. Not totally ideal but I'm not sure what's a good solution around making the names in alphabetical order.
Pinging @elastic/ml-ui (:ml) |
'xpack.ml.advancedSettings.enableAnomalyDetectionDefaultTimeRangeDesc', | ||
{ | ||
defaultMessage: | ||
'Use the default time filter in the Single Metric Viewer and Anomaly Explorer.', |
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 this needs an extra sentence to explain what happens if this is not enabled. Something like If not enabled, the results for the full time range of the job will be displayed.
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.
Something like ... "If not enabled, the results....
LGTM, except I'd replace "will be" with "are".
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 it to Use the default time filter in the Single Metric Viewer and Anomaly Explorer. If not enabled, the results for the full time range of the job are displayed.
here 1118b3e
@@ -30,5 +34,43 @@ export function registerKibanaSettings(coreSetup: CoreSetup) { | |||
}), | |||
}, | |||
}, | |||
[ANOMALY_DETECTION_ENABLE_TIME_RANGE]: { | |||
name: i18n.translate('xpack.ml.advancedSettings.enableAnomalyDetectionDefaultTimeRangeName', { | |||
defaultMessage: 'Enable time filter defaults for anomaly detection jobs', |
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.
Or as this only applies to the results pages, should this be Enable time filter defaults for anomaly detection results
?
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 1118b3e
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.
Some more text suggestions!
toastNotifications.addWarning( | ||
i18n.translate('xpack.ml.explorer.invalidTimeRangeInUrlCallout', { | ||
defaultMessage: | ||
'The time filter changed to the full range for this job due to invalid default time filter. Please check the advanced settings for {field}.', |
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 - suggest changing to The time filter was changed to the full range for this job due to an invalid default time filter. Please check the advanced settings for {field}.
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.
Please check the advanced settings.
Another nit: The style guidelines recommend omitting "Please". I'd suggest "Check the advanced settings...".
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 it to The time filter was changed to the full range due to an invalid default time filter. Check the advanced settings for {field}.
here 1118b3e
defaultMessage: | ||
'The time filter changed to the full range for this job due to invalid default time filter. Please check the advanced settings for {field}.', | ||
values: { | ||
field: ANOMALY_DETECTION_DEFAULT_TIME_RANGE, |
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.
The message either needs changing to remove for this job
or else you need to pass in the number of jobs selected in the view and change to for these jobs
if more than one is selected.
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 removed the for this job
part to make it more concise and I think it reads okay. Updated here 1118b3e
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 removed the "for this job" part...
Should it be removed from the UI text on the Advanced Settings page too?
x-pack/plugins/ml/public/application/timeseriesexplorer/timeseriesexplorer.js
Outdated
Show resolved
Hide resolved
import { MlSummaryJobs } from '../../../../../common/types/anomaly_detection_jobs'; | ||
import { useCreateADLinks } from '../../../components/custom_hooks/use_create_ad_links'; | ||
|
||
// @ts-ignore no module file |
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.
looks like this comment can go
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.
Removed here 1118b3e
defaultMessage: 'Time filter defaults', | ||
}), | ||
type: 'json', | ||
value: `{ |
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 it worth pulling these defaults out into constants like our existing file data viz setting.
this could be stored as a real json object constant and stringified when adding it here.
JSON.stringify(FOO, null, 2)
for the correct formatting.
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 is super neat! Updated here 1118b3e
Although I put the new settings in the settings
constants instead of creating a new file because I didn't think it was big enough. Although I'm happy to create a new file for them!
@@ -5,3 +5,11 @@ | |||
*/ | |||
|
|||
export const FILE_DATA_VISUALIZER_MAX_FILE_SIZE = 'ml:fileDataVisualizerMaxFileSize'; | |||
export const ANOMALY_DETECTION_ENABLE_TIME_RANGE = 'ml:anomalyDetection:results:enableTmeDefaults'; |
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 there's a letter missing:
export const ANOMALY_DETECTION_ENABLE_TIME_RANGE = 'ml:anomalyDetection:results:enableTmeDefaults'; | |
export const ANOMALY_DETECTION_ENABLE_TIME_RANGE = 'ml:anomalyDetection:results:enableTimeDefaults'; |
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! Fixed in ab8b130
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 edits and LGTM
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 SucceededBuild metrics@kbn/optimizer bundle module count
async chunks size
page load bundle size
History
To update your PR or re-run it, just comment with: |
* master: (47 commits) Do not require id & description when creating a logstash pipeline (elastic#76616) Remove commented src/core/tsconfig file (elastic#76792) Replaced whitelistedHosts with allowedHosts in actions ascii docs (elastic#76731) [Dashboard First] Genericize Attribute Service (elastic#76057) [ci-metrics] unify distributable file count metrics (elastic#76448) [Security Solution][Detections] Handle conflicts on alert status update (elastic#75492) [eslint] convert to @typescript-eslint/no-unused-expressions (elastic#76471) [DOCS] Add default time range filter to advanced settings (elastic#76414) [Security Solution] Refactor NetworkTopNFlow to use Search Strategy (elastic#76249) [Dashboard] Update Index Patterns when Child Index Patterns Change (elastic#76356) [ML] Add option to Advanced Settings to set default time range filter for AD jobs (elastic#76347) Add CSM app to CODEOWNERS (elastic#76793) [Security Solution][Exceptions] - Updates exception item find sort field (elastic#76685) [Security Solution][Detections][Tech Debt] - Move to using common io-ts types (elastic#75009) [Lens] Drag dimension to replace (elastic#75895) URI encode the index names we fetch in the fetchIndices lib function. (elastic#76584) [Security Solution] Resolver retrieve entity id of documents without field mapped (elastic#76562) [Ingest Manager] validate agent route using AJV instead kbn-config-schema (elastic#76546) Updated non-dev usages of node-forge (elastic#76699) [Ingest Pipelines] Processor forms for processors K-S (elastic#75638) ...
Summary
This PR adds Advanced Setting for anomaly detection default time filter time range.
When the setting is enabled, links to the Single Metric Viewer and the Anomaly Explorer from the Jobs Management list would be using the filter by default.
Current it supports quick options as well as "absolute" options:
Although more validations would be needed if there's any invalid terms for either "from" or "to".
Also updated:
Checklist
Delete any items that are not applicable to this PR.