Skip to content
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] Data Frame Analytics custom URLs: adds ability to set custom time range in urls #155337

Conversation

alvarezmelissa87
Copy link
Contributor

@alvarezmelissa87 alvarezmelissa87 commented Apr 20, 2023

Summary

Related meta issue: #150375

This PR adds a custom time range picker to the custom urls UI for Data Frame Analytics jobs.
When not selected, the timerange will default to the global timerange - this is the same behavior as before.

image

image

image

Checklist

Delete any items that are not applicable to this PR.

@alvarezmelissa87 alvarezmelissa87 added :ml release_note:skip Skip the PR/issue when compiling release notes Feature:Data Frame Analytics ML data frame analytics features v8.8.0 labels Apr 20, 2023
@alvarezmelissa87 alvarezmelissa87 self-assigned this Apr 20, 2023
@alvarezmelissa87 alvarezmelissa87 requested a review from a team as a code owner April 20, 2023 01:35
@elasticmachine
Copy link
Contributor

Pinging @elastic/ml-ui (:ml)

{showCustomTimeRangeSelector ? (
<>
<EuiSpacer size="s" />
<EuiFormRow
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the destination data view of the job has a timestamp field, and the target page is either Dashboard or Discover with a data view that has a timestamp field, it would be good to include an extra option here as well as the custom time range option, where the user can specify an interval. The action here would be to open the target page showing interval either side of the time of the row the action is being run on, similar to the option we have for anomaly detection job custom URLs:

image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This item is part of the overall meta issue #150375 and can be done in a separate PR 👍

Copy link
Contributor

@peteharverson peteharverson left a 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

},
} = useMlKibana();

const onCustomTimeRangeSwitchChange = (e: {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The type of e can be e: React.ChangeEvent<HTMLInputElement>

But a neater way might be to just pass in a boolean and call onCustomTimeRangeSwitchChange with onChange={(e) => onCustomTimeRangeSwitchChange(e.target.checked)}
This is the style we've used the most in our code.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call - updated to use the consistent style in eca357a

@@ -29,10 +30,11 @@ import { DataView } from '@kbn/data-views-plugin/public';
import { CustomUrlSettings, isValidCustomUrlSettingsTimeRange } from './utils';
import { isValidLabel } from '../../../util/custom_url_utils';
import { type DataFrameAnalyticsConfig } from '../../../../../common/types/data_frame_analytics';
import { Job, isAnomalyDetectionJob } from '../../../../../common/types/anomaly_detection_jobs';
import { Job } from '../../../../../common/types/anomaly_detection_jobs';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
import { Job } from '../../../../../common/types/anomaly_detection_jobs';
import { type Job } from '../../../../../common/types/anomaly_detection_jobs';

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated in eca357a

@@ -252,12 +254,19 @@ async function buildDashboardUrlFromSettings(settings: CustomUrlSettings): Promi
}

const dashboard = getDashboard();
let customStart;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these two new blocks of code are identical, could they be moved to a small function that takes in settings?
it could even incorporate the customStart ?? '$earliest$' check later and just return from and to

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved to a separate function in eca357a

@alvarezmelissa87
Copy link
Contributor Author

@elasticmachine merge upstream

@alvarezmelissa87
Copy link
Contributor Author

This has been updated with final suggestions 🙏 cc @jgowdyelastic, @peteharverson

Copy link
Member

@jgowdyelastic jgowdyelastic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@alvarezmelissa87
Copy link
Contributor Author

@elasticmachine merge upstream

@kibana-ci
Copy link
Collaborator

💛 Build succeeded, but was flaky

Failed CI Steps

Test Failures

  • [job] [logs] FTR Configs #27 / analytics instrumented events from the browser Event "viewport_resize" should emit a "viewport_resize" event when the browser is resized
  • [job] [logs] FTR Configs #51 / machine learning - short tests model management trained models for ML power user with imported models stops deployment of the imported model pt_tiny_ner

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
ml 1719 1720 +1

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
ml 3.4MB 3.4MB +2.6KB
Unknown metric groups

ESLint disabled line counts

id before after diff
enterpriseSearch 17 19 +2
securitySolution 395 398 +3
total +5

Total ESLint disabled count

id before after diff
enterpriseSearch 18 20 +2
securitySolution 475 478 +3
total +5

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

cc @alvarezmelissa87

@alvarezmelissa87 alvarezmelissa87 merged commit d5f12ac into elastic:main Apr 24, 2023
@alvarezmelissa87 alvarezmelissa87 deleted the ml-custom-urls-add-timepicker-for-dfa branch April 24, 2023 22:20
@kibanamachine kibanamachine added the backport:skip This commit does not require backporting label Apr 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting Feature:Data Frame Analytics ML data frame analytics features :ml release_note:skip Skip the PR/issue when compiling release notes v8.8.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants