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] Adds explain log rate spikes feature to the ML plugin #135948

Merged
merged 11 commits into from
Jul 12, 2022

Conversation

alvarezmelissa87
Copy link
Contributor

@alvarezmelissa87 alvarezmelissa87 commented Jul 7, 2022

Summary

Part of #136265.

This is a follow up to the following PRs: Plugin Setup (#131317), Page Setup (#132121), API endpoint with license check (#135058, #135431), DualBrush component (#135318).

Adds initial UI for Explain log rate spikes view

  • Use full data button
  • Datepicker
  • Doc count chart
  • Spike analysis table

image

For a follow up:

Checklist

@alvarezmelissa87 alvarezmelissa87 self-assigned this Jul 7, 2022
@alvarezmelissa87 alvarezmelissa87 changed the title [ML] Explain log rate spikes: Part 1 [ML] Explain log rate spikes: UI Part 1 Jul 7, 2022
@alvarezmelissa87 alvarezmelissa87 force-pushed the log-rate-spike-part-1 branch from a923280 to 849e33a Compare July 8, 2022 12:00
@alvarezmelissa87 alvarezmelissa87 added :ml v8.4.0 release_note:skip Skip the PR/issue when compiling release notes labels Jul 8, 2022
@alvarezmelissa87
Copy link
Contributor Author

Known issues:

  • when using the refresh button next to the progress bar duplicate elements are returned - this needs to be addressed in the useFetchStream hook that returns the data.changePoints passed to the spike analysis table.

@alvarezmelissa87 alvarezmelissa87 force-pushed the log-rate-spike-part-1 branch from 65033a0 to 070f01f Compare July 8, 2022 21:13
@alvarezmelissa87 alvarezmelissa87 marked this pull request as ready for review July 8, 2022 21:13
@alvarezmelissa87 alvarezmelissa87 requested a review from a team as a code owner July 8, 2022 21:13
@elasticmachine
Copy link
Contributor

Pinging @elastic/ml-ui (:ml)

@alvarezmelissa87 alvarezmelissa87 requested a review from qn895 July 8, 2022 21:13
pagination={pagination}
loading={loading}
error={error}
// sorting={sorting}
Copy link
Contributor

Choose a reason for hiding this comment

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

Have you left this in for a follow-up to add in row selection functionality?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes 👍

pagination={pagination}
loading={loading}
error={error}
// sorting={sorting}
Copy link
Contributor

Choose a reason for hiding this comment

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

The table should be sorted by p-value, ascending, by default. My table doesn't look like it's sorted currently (the one in your screenshot does though).

Copy link
Contributor

Choose a reason for hiding this comment

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

As discussed, sorting will be done in a follow-up

autoRefreshSelector?: boolean;
}

export const useTimefilter = ({
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the analysis re-run when the time range is changed? It looks like it currently always uses the full time range of the data view.

Copy link
Contributor

Choose a reason for hiding this comment

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

In this PR the parameters to run the analysis are not passed on yet. Suggest to do that as part of the follow up that will add the brushes.

Copy link
Contributor

Choose a reason for hiding this comment

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

OK, makes sense to do that in the brushes PR.

<ExplainLogRateSpikesLazy {...props} />
</LazyWrapper>
);
export const ExplainLogRateSpikes: FC<ExplainLogRateSpikesProps> = (props) => {
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 try to keep this component as small as possible, otherwise it will grow the loading bundle, ideally this file should not change at all. You could for example create a new component ExplainLogRateSpikesUrlStateWrapper that gets consumed here as ExplainLogRateSpikesUrlStateWrapperLazy. This new component would then contain ExplainLogRateSpikes.

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 in fd3cbb696ab1d3bc4f6c9cbcfd9f29124e986bf1

Copy link
Contributor

Choose a reason for hiding this comment

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

Can the UrlStateContextProvider and related code (e.g. setUrlState) also be moved into ExplainLogRateSpikesWrapperLazy?

Copy link
Contributor

Choose a reason for hiding this comment

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

Looking at the code again, it seems you moved it correctly to the inner component already 👍 but just missed removing it here?

@@ -4,15 +4,20 @@
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

// @ts-nocheck // remove
Copy link
Contributor

Choose a reason for hiding this comment

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

Are the changes in this file necessary? Since we hopefully copied everything over we need to aiops we should aim for leaving data visualizer related files untouched.

Copy link
Contributor Author

@alvarezmelissa87 alvarezmelissa87 Jul 11, 2022

Choose a reason for hiding this comment

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

Nope, shouldn't be - good catch - removed in fd3cbb696ab1d3bc4f6c9cbcfd9f29124e986bf1 👍

Copy link
Contributor

@walterra walterra left a comment

Choose a reason for hiding this comment

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

Looks good overall! Left a few comments about data-visualizer related comments as well as the structure of components regarding the lazy setup.

const timeZone = getTimezone(uiSettings);

return (
<div style={{ width: width ?? '100%' }} data-test-subj="dataVisualizerDocumentCountChart">
Copy link
Contributor

Choose a reason for hiding this comment

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

Reference to dataVisualizer should be changed to aiops.

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 fd3cbb696ab1d3bc4f6c9cbcfd9f29124e986bf1

AiOpsStartDependencies & {
storage: IStorageWrapper;
};
export type DataVisualizerKibanaReactContextValue = KibanaReactContextValue<StartServices>;
Copy link
Contributor

Choose a reason for hiding this comment

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

Reference to DataVisualizer should be changed to AiOps.

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 fd3cbb696ab1d3bc4f6c9cbcfd9f29124e986bf1

status: number;
}

export interface DVResponseError {
Copy link
Contributor

Choose a reason for hiding this comment

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

This file uses a DV prefix in several places, suggest to rename to AiOps.

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 fd3cbb696ab1d3bc4f6c9cbcfd9f29124e986bf1

@walterra
Copy link
Contributor

About the known issue with the refresh button: I will create a separate PR to fix this, this bug was already present before this PR.


export const AIOPS_FROZEN_TIER_PREFERENCE = 'aiOps.frozenDataTierPreference';

export type DV = Partial<{
Copy link
Contributor

Choose a reason for hiding this comment

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

Still some more DV references in this file.

message: string;
}

export interface DVErrorObject {
Copy link
Contributor

Choose a reason for hiding this comment

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

Still some more DV prefixes in this file.

@@ -25,6 +27,6 @@ const LazyWrapper: FC = ({ children }) => (
*/
export const ExplainLogRateSpikes: FC<ExplainLogRateSpikesProps> = (props) => (
<LazyWrapper>
<ExplainLogRateSpikesLazy {...props} />
<ExplainLogRateSpikesWrapperLazy {...props} />{' '}
Copy link
Contributor

@walterra walterra Jul 12, 2022

Choose a reason for hiding this comment

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

Guess the {' '} part can be removed, might be a leftover from an auto-format gone wrong.

setPageIndex(index);
setPageSize(size);

// onTableChange(tableSettings);
Copy link
Member

Choose a reason for hiding this comment

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

Can this commented code be removed?


const size = 0;
const filterCriteria = buildBaseFilterCriteria(timeFieldName, earliestMs, latestMs, {
match_all: {},
Copy link
Member

Choose a reason for hiding this comment

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

Should this be using searchQuery instead of match_all? If not, would be good to clean up searchQuery or add a comment.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep - I'll be adding search support in a follow up 👍

}
}

export function useOverallStats<TParams extends OverallStatsSearchStrategyParams>(
Copy link
Member

Choose a reason for hiding this comment

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

useOverallStats doesn't make sense here in this context since you only need the document count. Suggestion to rename this file, this hook, and setOverallStats.

autoRefreshSelector: true,
});

const fieldStatsRequest: OverallStatsSearchStrategyParams | undefined = useMemo(
Copy link
Member

Choose a reason for hiding this comment

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

Suggestion to rename reference to fieldStats and OverallStats here since this seems to be a carry-over from DV.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Renamed all suggested in 02c5863

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

@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
aiops 248 284 +36

Async chunks

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

id before after diff
aiops 380.1KB 409.2KB +29.1KB

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
aiops 3.7KB 4.6KB +935.0B
Unknown metric groups

ESLint disabled line counts

id before after diff
aiops 5 14 +9

Total ESLint disabled count

id before after diff
aiops 5 14 +9

History

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

cc @alvarezmelissa87

@alvarezmelissa87 alvarezmelissa87 merged commit 4ad614c into elastic:main Jul 12, 2022
@kibanamachine kibanamachine added the backport:skip This commit does not require backporting label Jul 12, 2022
@alvarezmelissa87 alvarezmelissa87 deleted the log-rate-spike-part-1 branch July 12, 2022 18:42
@peteharverson peteharverson changed the title [ML] Explain log rate spikes: UI Part 1 [ML] Adds explain log rate spikes feature to the ML plugin Jul 29, 2022
@peteharverson peteharverson added release_note:feature Makes this part of the condensed release notes and removed release_note:skip Skip the PR/issue when compiling release notes labels Jul 29, 2022
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 :ml release_note:feature Makes this part of the condensed release notes v8.4.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants