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] Explain Log Rate Spikes: Support to filter fields from grouping #153864

Merged
merged 23 commits into from
Apr 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
7e3f861
support to filter fields from grouping
walterra Mar 28, 2023
63dec48
move field selection popover to its own component
walterra Mar 29, 2023
280972c
fix grouping edge cases
walterra Mar 29, 2023
b15c397
cleanup css
walterra Mar 29, 2023
a8747ba
jest tests
walterra Mar 30, 2023
67ba5b3
update api integration tests
walterra Mar 30, 2023
19449fa
fix jest tests
walterra Mar 30, 2023
a93dade
Merge branch 'main' into ml-153753-field-selection
walterra Mar 30, 2023
d764d4a
functional tests for field selector popover
walterra Mar 30, 2023
ea9490c
tweak popover layout
walterra Mar 30, 2023
16f6714
tweak analysis toolbar
walterra Mar 31, 2023
fc70403
Merge branch 'main' into ml-153753-field-selection
walterra Mar 31, 2023
481b2f5
Merge branch 'main' into ml-153753-field-selection
walterra Mar 31, 2023
2970400
Merge branch 'main' into ml-153753-field-selection
walterra Apr 3, 2023
4b99b91
Merge branch 'main' into ml-153753-field-selection
walterra Apr 4, 2023
640ee58
Merge branch 'ml-153753-field-selection' of github.com:walterra/kiban…
walterra Apr 4, 2023
23d542e
Merge branch 'main' into ml-153753-field-selection
walterra Apr 11, 2023
16a3325
tweak popover help text
walterra Apr 11, 2023
ae9ba6b
tweak button texts
walterra Apr 11, 2023
8b9f799
Disable Apply button when form hadn't been touched. Disable select/de…
walterra Apr 11, 2023
45e900b
Fix to reset unique field names when analysis is rerun.
walterra Apr 11, 2023
767eb1c
Fix data-test-subj
walterra Apr 11, 2023
da01672
Merge branch 'main' into ml-153753-field-selection
walterra Apr 11, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import React from 'react';
import React, { type FC } from 'react';

import {
useEuiTheme,
Expand Down Expand Up @@ -34,19 +34,20 @@ interface ProgressControlProps {
shouldRerunAnalysis: boolean;
}

export function ProgressControls({
export const ProgressControls: FC<ProgressControlProps> = ({
children,
progress,
progressMessage,
onRefresh,
onCancel,
isRunning,
shouldRerunAnalysis,
}: ProgressControlProps) {
}) => {
const { euiTheme } = useEuiTheme();
const runningProgressBarStyles = useAnimatedProgressBarBackground(euiTheme.colors.success);

return (
<EuiFlexGroup>
<EuiFlexGroup alignItems="center">
<EuiFlexItem>
<EuiFlexGroup direction="column" gutterSize="none">
<EuiFlexItem data-test-subj="aiopProgressTitle">
Expand Down Expand Up @@ -78,6 +79,7 @@ export function ProgressControls({
size="s"
onClick={onRefresh}
color={shouldRerunAnalysis ? 'warning' : 'primary'}
fill
>
<EuiFlexGroup>
<EuiFlexItem>
Expand Down Expand Up @@ -105,11 +107,12 @@ export function ProgressControls({
</EuiButton>
)}
{isRunning && (
<EuiButton data-test-subj="aiopsCancelAnalysisButton" size="s" onClick={onCancel}>
<EuiButton data-test-subj="aiopsCancelAnalysisButton" size="s" onClick={onCancel} fill>
<FormattedMessage id="xpack.aiops.cancelAnalysisButtonTitle" defaultMessage="Cancel" />
</EuiButton>
)}
</EuiFlexItem>
{children}
</EuiFlexGroup>
);
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -6,48 +6,48 @@
*/

export const significantTerms = [
{
fieldName: 'user',
fieldValue: 'Peter',
doc_count: 1981,
bg_count: 553,
total_doc_count: 4669,
total_bg_count: 1975,
score: 47.38899434932384,
pValue: 2.62555579103777e-21,
normalizedScore: 0.8328439168064725,
},
{
fieldName: 'response_code',
fieldValue: '500',
doc_count: 1819,
bg_count: 553,
total_doc_count: 4671,
total_doc_count: 4669,
total_bg_count: 1975,
score: 26.546201745993947,
pValue: 2.9589053032077285e-12,
normalizedScore: 0.7814127409489161,
score: 26.347710713220195,
pValue: 3.6085657805889595e-12,
normalizedScore: 0.7809229492301661,
},
{
fieldName: 'url',
fieldValue: 'home.php',
doc_count: 1744,
bg_count: 632,
total_doc_count: 4671,
total_doc_count: 4669,
total_bg_count: 1975,
score: 4.53094842981472,
pValue: 0.010770456205312423,
normalizedScore: 0.10333028878375965,
score: 4.631197208465419,
pValue: 0.00974308761016614,
normalizedScore: 0.12006631193078789,
},
{
fieldName: 'url',
fieldValue: 'login.php',
doc_count: 1738,
bg_count: 632,
total_doc_count: 4671,
total_bg_count: 1975,
score: 4.53094842981472,
pValue: 0.010770456205312423,
normalizedScore: 0.10333028878375965,
},
{
fieldName: 'user',
fieldValue: 'Peter',
doc_count: 1981,
bg_count: 553,
total_doc_count: 4671,
total_doc_count: 4669,
total_bg_count: 1975,
score: 47.34435085428873,
pValue: 2.7454255728359757e-21,
normalizedScore: 0.8327337555873047,
score: 4.359614926663956,
pValue: 0.012783309213417932,
normalizedScore: 0.07472703283204607,
},
];
10 changes: 10 additions & 0 deletions x-pack/plugins/aiops/common/api/explain_log_rate_spikes/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export const API_ACTION_NAME = {
PING: 'ping',
RESET_ALL: 'reset_all',
RESET_ERRORS: 'reset_errors',
RESET_GROUPS: 'reset_groups',
UPDATE_LOADING_STATE: 'update_loading_state',
} as const;
export type ApiActionName = typeof API_ACTION_NAME[keyof typeof API_ACTION_NAME];
Expand Down Expand Up @@ -119,6 +120,14 @@ export function resetAllAction(): ApiActionResetAll {
return { type: API_ACTION_NAME.RESET_ALL };
}

interface ApiActionResetGroups {
type: typeof API_ACTION_NAME.RESET_GROUPS;
}

export function resetGroupsAction(): ApiActionResetGroups {
return { type: API_ACTION_NAME.RESET_GROUPS };
}

interface ApiActionUpdateLoadingState {
type: typeof API_ACTION_NAME.UPDATE_LOADING_STATE;
payload: {
Expand Down Expand Up @@ -148,4 +157,5 @@ export type AiopsExplainLogRateSpikesApiAction =
| ApiActionPing
| ApiActionResetAll
| ApiActionResetErrors
| ApiActionResetGroups
| ApiActionUpdateLoadingState;
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export {
pingAction,
resetAllAction,
resetErrorsAction,
resetGroupsAction,
updateLoadingStateAction,
API_ACTION_NAME,
} from './actions';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export const aiopsExplainLogRateSpikesSchema = schema.object({
remainingFieldCandidates: schema.maybe(schema.arrayOf(schema.string())),
// TODO Improve schema
significantTerms: schema.maybe(schema.arrayOf(schema.any())),
regroupOnly: schema.maybe(schema.boolean()),
})
),
/** Probability used for the random sampler aggregations */
Expand Down
27 changes: 26 additions & 1 deletion x-pack/plugins/aiops/common/api/stream_reducer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,14 @@
* 2.0.
*/

import { significantTerms } from '../__mocks__/artificial_logs/significant_terms';
import { finalSignificantTermGroups } from '../__mocks__/artificial_logs/final_significant_term_groups';

import {
addSignificantTermsAction,
addSignificantTermsGroupAction,
resetAllAction,
resetGroupsAction,
updateLoadingStateAction,
} from './explain_log_rate_spikes';
import { initialState, streamReducer } from './stream_reducer';
Expand All @@ -29,7 +34,7 @@ describe('streamReducer', () => {
});
});

it('adds significant term, then resets state again', () => {
it('adds significant term, then resets all state again', () => {
const state1 = streamReducer(
initialState,
addSignificantTermsAction([
Expand All @@ -53,4 +58,24 @@ describe('streamReducer', () => {

expect(state2.significantTerms).toHaveLength(0);
});

it('adds significant terms and groups, then resets groups only', () => {
const state1 = streamReducer(initialState, addSignificantTermsAction(significantTerms));

expect(state1.significantTerms).toHaveLength(4);
expect(state1.significantTermsGroups).toHaveLength(0);

const state2 = streamReducer(
state1,
addSignificantTermsGroupAction(finalSignificantTermGroups)
);

expect(state2.significantTerms).toHaveLength(4);
expect(state2.significantTermsGroups).toHaveLength(4);

const state3 = streamReducer(state2, resetGroupsAction());

expect(state3.significantTerms).toHaveLength(4);
expect(state3.significantTermsGroups).toHaveLength(0);
});
});
2 changes: 2 additions & 0 deletions x-pack/plugins/aiops/common/api/stream_reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ export function streamReducer(
return { ...state, errors: [...state.errors, action.payload] };
case API_ACTION_NAME.RESET_ERRORS:
return { ...state, errors: [] };
case API_ACTION_NAME.RESET_GROUPS:
return { ...state, significantTermsGroups: [] };
case API_ACTION_NAME.RESET_ALL:
return initialState;
case API_ACTION_NAME.UPDATE_LOADING_STATE:
Expand Down
Loading