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] ML on Kibana Management: Add ability to pass a group ID filter to job management page #74533

Conversation

alvarezmelissa87
Copy link
Contributor

@alvarezmelissa87 alvarezmelissa87 commented Aug 6, 2020

Summary

Fixes #70574

  • Anomaly detection job management page:
    • handles list of group ids passed in URL by filtering table for specified group ids.
    • with mlManagement groupIds set in the URL
    • still supports mlManagement jobId set in the URL

image

  • Kibana management page anomaly detection jobs table:

    • group badges now link to job management page for selected groups
  • Updates getJobIdUrl to create urls for group ids as well as job ids and updates function name to getSelectedIdsUrl to be more general.

Checklist

Delete any items that are not applicable to this PR.

@elasticmachine
Copy link
Contributor

Pinging @elastic/ml-ui (:ml)

@qn895
Copy link
Member

qn895 commented Aug 6, 2020

Tested and functionality works well 👍


export function getSelectedJobIdFromUrl(url) {
export function getSelectedIdFromUrl(url) {
const result = {};
Copy link
Member

@jgowdyelastic jgowdyelastic Aug 10, 2020

Choose a reason for hiding this comment

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

total nit, result isn't really needed. there could be two return statements in this function.

const urlParams = getUrlVars(url);
const decodedJson = rison.decode(urlParams.mlManagement);
return decodedJson.jobId;

result.ids = isGroup ? decodedJson.groupIds : decodedJson.jobId;
Copy link
Member

Choose a reason for hiding this comment

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

a simpler approach here might be to have this function return jobId: string or groupIds: string[]
as having a property called ids contain a single string is confusing.

Copy link
Member

Choose a reason for hiding this comment

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

edit after testing, i see that decodedJson.jobId is now a string array. I've added a comment below about how I think this probably should still be a single string, seeing as we can't filter on multiple job ids.


export function getSelectedIdsUrl(
tabId: string,
ids: string | string[],
Copy link
Member

Choose a reason for hiding this comment

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

getSelectedIdsUrl is only ever called with a single group Id in an array.
Why does this need to support multiple group ids? should it also support multiple job ids?

Copy link
Member

Choose a reason for hiding this comment

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

After testing this I see that we do create a URL containing an array of job IDs, but using the property jobId.
IMO this should be a single job id.

Copy link
Member

Choose a reason for hiding this comment

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

rather than having a isGroup modifier parameter, we could have two functions getJobIdUrl and getGroupIdsUrl which both call a non-exported common function for creating the url

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for taking a look @jgowdyelastic 🙏

  • Support for multiple group ids is requested in the related issue for this as the table also supports it.
  • I'd originally put the job Id in the array for consistency and possible support of multiple ids. Taking your feedback into account, I agree it should be just a string until we do support multiple ids (which I don't think we need to anytime soon).

To conclude, groupIds will be an array of ids and jobId will be a string of just one id. I agree that breaking it up into two functions instead of using the isGroup parameter would be cleaner. 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jgowdyelastic - all suggestions added in 812cd04

@alvarezmelissa87 alvarezmelissa87 force-pushed the ml-anomaly-detection-pass-group-in-url branch from 7245d89 to 3e9c17b Compare August 10, 2020 13:35
ANOMALY_DETECTION = 'jobs',
}

function getSelectedIdsUrl(tabId, settings: any): string {
Copy link
Member

@jgowdyelastic jgowdyelastic Aug 10, 2020

Choose a reason for hiding this comment

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

sorry to be nit-picky. for type-completeness we should give settings its real type here, even if it's basic like [key: string]: string | string[]

@qn895
Copy link
Member

qn895 commented Aug 10, 2020

Tested and LGTM! Although I also agree with Jame's comment to define the type of the settings in getSelectedIdsUrl.

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.

Tested, LGTM

@@ -0,0 +1,39 @@
/*
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you please implement it as a method in ML URL generator?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is an existing issue for consolidating the url generating functions for 7.10 that @qn895 is working on so this will be addressed by that afaik.
#69265 (comment)

setSelectedJobIdFromUrlInitialized(true);
setSearchQueryText(selectedJobIdFromUrl);
if (selectedIdFromUrlInitialized === false && analytics.length > 0) {
const { jobId, groupIds } = getSelectedIdFromUrl(window.location.href);
Copy link
Contributor

Choose a reason for hiding this comment

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

We should not access window.location.href directly. Would be great to receive it from the router state instead

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍 To be done in a follow up.

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Build metrics

async chunks size

id value diff baseline
ml 7.9MB +4.9KB 7.9MB

History

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

@alvarezmelissa87 alvarezmelissa87 merged commit 4ee483b into elastic:master Aug 10, 2020
alvarezmelissa87 added a commit to alvarezmelissa87/kibana that referenced this pull request Aug 10, 2020
…o job management page (elastic#74533)

* handle group id in url for anomaly detection

* filter analytics list by group id.

* handle list of groupIds

* ensure analytics can handle jobid in url. rename util function

* add tests for getSelectedIdFromUrl and getGroupQueryText

* keep groupIds as array of strings and jobId as single string

* fix tests and update types
# Conflicts:
#	x-pack/plugins/ml/public/application/jobs/jobs_list/components/jobs_list/jobs_list.js
@alvarezmelissa87 alvarezmelissa87 deleted the ml-anomaly-detection-pass-group-in-url branch August 10, 2020 21:27
alvarezmelissa87 added a commit that referenced this pull request Aug 11, 2020
…o job management page (#74533) (#74713)

* handle group id in url for anomaly detection

* filter analytics list by group id.

* handle list of groupIds

* ensure analytics can handle jobid in url. rename util function

* add tests for getSelectedIdFromUrl and getGroupQueryText

* keep groupIds as array of strings and jobId as single string

* fix tests and update types
# Conflicts:
#	x-pack/plugins/ml/public/application/jobs/jobs_list/components/jobs_list/jobs_list.js
gmmorris added a commit to gmmorris/kibana that referenced this pull request Aug 11, 2020
…-task

* master: (42 commits)
  Allow any hostname for chromium proxy bypass (elastic#74693)
  [ML] ML on Kibana Management: Add ability to pass a group ID filter to job management page (elastic#74533)
  [Metrics UI] Fix No Data preview pluralization (elastic#74399)
  [Bug][Security_Solution][Telemetry] Capitalize S in macOS (elastic#74688)
  Remove karma tests  from legacy maps (elastic#74668)
  [Ingest Manager] stop creating events-* index pattern and placeholder index (elastic#74683)
  [Enterprise Search] Update the browser/document title on plugin navigation (elastic#74392)
  [visualizations] Add i18n translation for 'No results found' (elastic#74619)
  [maps] convert vector style properties to TS (elastic#74553)
  bump geckodriver binary to 0.27 (elastic#74638)
  fix: update apm agents to catch abort requests (elastic#74658)
  [Security Solution] Resolver children pagination (elastic#74603)
  add memoryStatus to df analytics page and analytics table in management (elastic#74570)
  [Ingest Manager] Allow prerelease in package version (elastic#74452)
  [App Arch]: remove legacy karma tests (elastic#74599)
  [i18n] revert reverted changes (elastic#74633)
  [Lens] Clear out all attribute properties before updating (elastic#74483)
  [Uptime] Fix full reloads while navigating to alert/ml (elastic#73796)
  Index pattern field class refactor (elastic#73180)
  [ML] Functional tests - stabilize DFA job type check (elastic#74631)
  ...
gmmorris added a commit to gmmorris/kibana that referenced this pull request Aug 11, 2020
* master: (339 commits)
  [Ingest Node Pipelines] Sentence-case processor names (elastic#74645)
  Bump angular dependency from 1.7.9 to 1.8.0 (elastic#74482)
  [ML] Fixing schema for custom rule conditions (elastic#74676)
  [ML] Refactor in preparation for new es client (elastic#74552)
  [ML] Adding initial file analysis overrides (elastic#74376)
  Allow any hostname for chromium proxy bypass (elastic#74693)
  [ML] ML on Kibana Management: Add ability to pass a group ID filter to job management page (elastic#74533)
  [Metrics UI] Fix No Data preview pluralization (elastic#74399)
  [Bug][Security_Solution][Telemetry] Capitalize S in macOS (elastic#74688)
  Remove karma tests  from legacy maps (elastic#74668)
  [Ingest Manager] stop creating events-* index pattern and placeholder index (elastic#74683)
  [Enterprise Search] Update the browser/document title on plugin navigation (elastic#74392)
  [visualizations] Add i18n translation for 'No results found' (elastic#74619)
  [maps] convert vector style properties to TS (elastic#74553)
  bump geckodriver binary to 0.27 (elastic#74638)
  fix: update apm agents to catch abort requests (elastic#74658)
  [Security Solution] Resolver children pagination (elastic#74603)
  add memoryStatus to df analytics page and analytics table in management (elastic#74570)
  [Ingest Manager] Allow prerelease in package version (elastic#74452)
  [App Arch]: remove legacy karma tests (elastic#74599)
  ...
jloleysens added a commit to jloleysens/kibana that referenced this pull request Aug 11, 2020
…nes/processor-forms-a-d

* 'master' of github.com:elastic/kibana: (26 commits)
  [Telemetry][API Integration] size_in_bytes to be a number (elastic#74664)
  [ILM] Convert node details flyout to TS (elastic#73707)
  [Ingest Node Pipelines] Sentence-case processor names (elastic#74645)
  Bump angular dependency from 1.7.9 to 1.8.0 (elastic#74482)
  [ML] Fixing schema for custom rule conditions (elastic#74676)
  [ML] Refactor in preparation for new es client (elastic#74552)
  [ML] Adding initial file analysis overrides (elastic#74376)
  Allow any hostname for chromium proxy bypass (elastic#74693)
  [ML] ML on Kibana Management: Add ability to pass a group ID filter to job management page (elastic#74533)
  [Metrics UI] Fix No Data preview pluralization (elastic#74399)
  [Bug][Security_Solution][Telemetry] Capitalize S in macOS (elastic#74688)
  Remove karma tests  from legacy maps (elastic#74668)
  [Ingest Manager] stop creating events-* index pattern and placeholder index (elastic#74683)
  [Enterprise Search] Update the browser/document title on plugin navigation (elastic#74392)
  [visualizations] Add i18n translation for 'No results found' (elastic#74619)
  [maps] convert vector style properties to TS (elastic#74553)
  bump geckodriver binary to 0.27 (elastic#74638)
  fix: update apm agents to catch abort requests (elastic#74658)
  [Security Solution] Resolver children pagination (elastic#74603)
  add memoryStatus to df analytics page and analytics table in management (elastic#74570)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[ML] Add ability to pass a group ID filter to the job management page
6 participants