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] AIOps: Supports text fields in log rate analysis #165124

Merged
Merged
Show file tree
Hide file tree
Changes from 48 commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
b2a00fb
poc
walterra Aug 29, 2023
b5d7560
linting
walterra Aug 29, 2023
5c520b7
fix imports
walterra Aug 30, 2023
2e3381c
move route inline code to fetch function
walterra Aug 30, 2023
4f5a8fc
fix pValue check
walterra Aug 30, 2023
79db419
cleanup
walterra Aug 30, 2023
f971eea
cleanup. results will have a type attribute
walterra Aug 30, 2023
1026748
mini histograms for category items
walterra Aug 31, 2023
6406c62
truncate field values after 3 lines
walterra Sep 20, 2023
0fef89e
fix types
walterra Sep 20, 2023
ec5f405
fix test assertions
walterra Sep 21, 2023
e1dacc5
break out css
walterra Sep 26, 2023
df03ec3
fix handling of multiple text field names
walterra Sep 28, 2023
3626e50
revert x-pack/packages/ml/chi2test/package.json to main
walterra Sep 28, 2023
b420f94
revert x-pack/packages/ml/chi2test/tsconfig.json to main
walterra Sep 28, 2023
bbcb2b4
tweak mock structure
walterra Sep 28, 2023
7dfb86e
fix jest test
walterra Sep 28, 2023
8dc7258
fix log pattern sparklines and document count chart
walterra Sep 28, 2023
d6740d8
improve types for significant term type
walterra Sep 28, 2023
baf4c0f
fix test data
walterra Sep 28, 2023
16dd091
disable log pattern analysis link if table item is a log pattern itself
walterra Sep 28, 2023
d4ae3f0
fix jest test
walterra Sep 29, 2023
987de66
add JSDoc
walterra Sep 29, 2023
103384b
fix loading percentage for combined log pattern and keyword histogram…
walterra Sep 29, 2023
d7ecabb
fix getting counts for baseline and deviation for categories
walterra Sep 29, 2023
bf9dc00
use msearch fetch category counts
walterra Sep 29, 2023
47aee3d
change category limit from 1000 to 100
walterra Sep 29, 2023
8d96ef5
Merge branch 'main' into 163690-ml-aiops-log-rate-text-field-support
walterra Sep 29, 2023
8388542
disable top field values for text fields
walterra Sep 29, 2023
7f8c339
remove commented console.log
walterra Sep 29, 2023
b2bf088
Merge branch 'main' into 163690-ml-aiops-log-rate-text-field-support
walterra Oct 2, 2023
3af27fd
grouping support for log patterns
walterra Oct 2, 2023
c92b6fc
fix location for setting fieldValuePairsCount.
walterra Oct 2, 2023
9cf1070
fix JSDoc
walterra Oct 2, 2023
9de3370
Revert "fix JSDoc"
walterra Oct 2, 2023
b140e1c
fix types
walterra Oct 2, 2023
d79e61c
Merge branch 'main' into 163690-ml-aiops-log-rate-text-field-support
walterra Oct 2, 2023
b26882e
Merge branch 'main' into 163690-ml-aiops-log-rate-text-field-support
walterra Oct 2, 2023
bfeac60
Merge branch 'main' into 163690-ml-aiops-log-rate-text-field-support
walterra Oct 2, 2023
0f92071
Merge branch '163690-ml-aiops-log-rate-text-field-support' of github.…
walterra Oct 2, 2023
30422fb
revert CATEGORY_LIMIT back from 100 to 1000.
walterra Oct 3, 2023
635178a
remove limit of 100 elements
walterra Oct 3, 2023
3788153
remove unnecessary return statement
walterra Oct 3, 2023
2908e07
Merge branch 'main' into 163690-ml-aiops-log-rate-text-field-support
walterra Oct 3, 2023
b5955eb
do not run chi2test when there are no categories
walterra Oct 3, 2023
6724294
adds key/type info to groups
walterra Oct 3, 2023
534ee5e
fix regrouping with text fields
walterra Oct 3, 2023
d72b43d
show icon with tooltip for log pattern item
walterra Oct 3, 2023
ca3c271
Merge branch 'main' into 163690-ml-aiops-log-rate-text-field-support
walterra Oct 3, 2023
6ad57d9
fix mini histograms for groups with log patterns
walterra Oct 3, 2023
a8bb5cf
fix types/tests
walterra Oct 3, 2023
6587927
fix render loop when multiple group rows get expanded
walterra Oct 3, 2023
d553acf
Merge branch 'main' into 163690-ml-aiops-log-rate-text-field-support
walterra Oct 3, 2023
81ab9b9
update expected data
walterra Oct 3, 2023
7e8b263
do not use kibana sample data logs
walterra Oct 3, 2023
be5c07f
Merge branch 'main' into 163690-ml-aiops-log-rate-text-field-support
walterra Oct 4, 2023
8197b1e
Merge branch 'main' into 163690-ml-aiops-log-rate-text-field-support
walterra Oct 4, 2023
0b5f2d0
Merge branch 'main' into 163690-ml-aiops-log-rate-text-field-support
walterra Oct 4, 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
2 changes: 2 additions & 0 deletions x-pack/packages/ml/agg_utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export type {
} from './src/fetch_histograms_for_fields';
export { isMultiBucketAggregate } from './src/is_multi_bucket_aggregate';
export { isSignificantTerm } from './src/type_guards';
export { SIGNIFICANT_TERM_TYPE } from './src/types';
export type {
AggCardinality,
SignificantTerm,
Expand All @@ -27,6 +28,7 @@ export type {
SignificantTermGroupHistogram,
SignificantTermHistogram,
SignificantTermHistogramItem,
SignificantTermType,
HistogramField,
NumericColumnStats,
NumericColumnStatsMap,
Expand Down
2 changes: 2 additions & 0 deletions x-pack/packages/ml/agg_utils/src/type_guards.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ describe('isSignificantTerm', () => {
expect(isSignificantTerm({ fieldValue: '500' })).toBeFalsy();
expect(
isSignificantTerm({
key: 'response_code:500',
type: 'keyword',
fieldName: 'response_code',
fieldValue: '500',
doc_count: 1819,
Expand Down
2 changes: 2 additions & 0 deletions x-pack/packages/ml/agg_utils/src/type_guards.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import type { SignificantTerm } from './types';
*/
export function isSignificantTerm(arg: unknown): arg is SignificantTerm {
return isPopulatedObject(arg, [
'key',
'type',
'fieldName',
'fieldValue',
'doc_count',
Expand Down
30 changes: 30 additions & 0 deletions x-pack/packages/ml/agg_utils/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,24 @@ export interface HistogramField {
type: KBN_FIELD_TYPES;
}

/**
* Enumeration of significant term types.
*/
export const SIGNIFICANT_TERM_TYPE = {
KEYWORD: 'keyword',
LOG_PATTERN: 'log_pattern',
} as const;

/**
* Type for significant term type keys.
*/
type SignificantTermTypeKeys = keyof typeof SIGNIFICANT_TERM_TYPE;

/**
* Represents the type of significant term as determined by the SIGNIFICANT_TERM_TYPE enumeration.
*/
export type SignificantTermType = typeof SIGNIFICANT_TERM_TYPE[SignificantTermTypeKeys];

/**
* Represents significant term metadata for a field/value pair.
* This interface is used as a custom type within Log Rate Analysis
Expand All @@ -97,6 +115,12 @@ export interface HistogramField {
* @extends FieldValuePair
*/
export interface SignificantTerm extends FieldValuePair {
/** The key associated with the significant term. */
key: string;

/** The type of the significant term. */
type: SignificantTermType;

/** The document count for the significant term. */
doc_count: number;

Expand Down Expand Up @@ -169,6 +193,12 @@ export interface SignificantTermGroupHistogram {
* @interface
*/
export interface SignificantTermGroupItem extends FieldValuePair {
/** The key associated with the significant term. */
key: string;

/** The type of the significant term. */
type: SignificantTermType;

/** The document count associated with this item. */
docCount: number;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,84 +12,100 @@ export const finalSignificantTermGroups: SignificantTermGroup[] = [
docCount: 632,
group: [
{
docCount: 790,
duplicate: 2,
key: 'url:login.php',
type: 'keyword',
fieldName: 'url',
fieldValue: 'login.php',
docCount: 790,
duplicate: 2,
pValue: 0.012783309213417932,
},
{
docCount: 632,
duplicate: 2,
key: 'user:Peter',
type: 'keyword',
fieldName: 'user',
fieldValue: 'Peter',
docCount: 632,
duplicate: 2,
pValue: 0.012783309213417932,
},
],
id: '1982924514',
id: '1937394803',
pValue: 0.012783309213417932,
},
{
docCount: 792,
group: [
{
docCount: 792,
duplicate: 2,
key: 'response_code:500',
type: 'keyword',
fieldName: 'response_code',
fieldValue: '500',
docCount: 792,
duplicate: 2,
pValue: 0.012783309213417932,
},
{
docCount: 792,
duplicate: 2,
key: 'url:home.php',
type: 'keyword',
fieldName: 'url',
fieldValue: 'home.php',
docCount: 792,
duplicate: 2,
pValue: 0.00974308761016614,
},
],
id: '2052830342',
id: '2675980076',
pValue: 0.00974308761016614,
},
{
docCount: 790,
group: [
{
docCount: 792,
duplicate: 2,
key: 'response_code:500',
type: 'keyword',
fieldName: 'response_code',
fieldValue: '500',
docCount: 792,
duplicate: 2,
pValue: 0.012783309213417932,
},
{
docCount: 790,
duplicate: 2,
key: 'url:login.php',
type: 'keyword',
fieldName: 'url',
fieldValue: 'login.php',
docCount: 790,
duplicate: 2,
pValue: 0.012783309213417932,
},
],
id: '3851735068',
id: '3819687732',
pValue: 0.012783309213417932,
},
{
docCount: 636,
group: [
{
docCount: 792,
duplicate: 2,
key: 'url:home.php',
type: 'keyword',
fieldName: 'url',
fieldValue: 'home.php',
docCount: 792,
duplicate: 2,
pValue: 0.00974308761016614,
},
{
docCount: 636,
duplicate: 2,
key: 'user:Peter',
type: 'keyword',
fieldName: 'user',
fieldValue: 'Peter',
docCount: 636,
duplicate: 2,
pValue: 0.00974308761016614,
},
],
id: '92732022',
id: '2091742187',
pValue: 0.00974308761016614,
},
];
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,21 @@ export const significantTermGroups: SignificantTermGroup[] = [
id: '2038579476',
group: [
{
key: 'response_code:500',
type: 'keyword',
fieldName: 'response_code',
fieldValue: '500',
docCount: 1819,
pValue: 2.9589053032077285e-12,
},
{ fieldName: 'url', fieldValue: 'home.php', docCount: 1744, pValue: 0.010770456205312423 },
{
key: 'url:home.php',
type: 'keyword',
fieldName: 'url',
fieldValue: 'home.php',
docCount: 1744,
pValue: 0.010770456205312423,
},
],
docCount: 792,
pValue: 0.010770456205312423,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@
* 2.0.
*/

export const significantTerms = [
import type { SignificantTerm } from '@kbn/ml-agg-utils';

export const significantTerms: SignificantTerm[] = [
{
key: 'user:Peter',
type: 'keyword',
fieldName: 'user',
fieldValue: 'Peter',
doc_count: 1981,
Expand All @@ -18,6 +22,8 @@ export const significantTerms = [
normalizedScore: 0.8328439168064725,
},
{
key: 'response_code:500',
type: 'keyword',
fieldName: 'response_code',
fieldValue: '500',
doc_count: 1819,
Expand All @@ -29,6 +35,8 @@ export const significantTerms = [
normalizedScore: 0.7809229492301661,
},
{
key: 'url:home.php',
type: 'keyword',
fieldName: 'url',
fieldValue: 'home.php',
doc_count: 1744,
Expand All @@ -40,6 +48,8 @@ export const significantTerms = [
normalizedScore: 0.12006631193078789,
},
{
key: 'url:login.php',
type: 'keyword',
fieldName: 'url',
fieldValue: 'login.php',
doc_count: 1738,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,16 @@ export const significantTermGroups: SignificantTermGroup[] = [
id: 'group-1',
group: [
{
key: 'custom_field.keyword:deviation',
type: 'keyword',
fieldName: 'custom_field.keyword',
fieldValue: 'deviation',
docCount: 101,
pValue: 0.01,
},
{
key: 'airline:UAL',
type: 'keyword',
fieldName: 'airline',
fieldValue: 'UAL',
docCount: 101,
Expand All @@ -31,12 +35,16 @@ export const significantTermGroups: SignificantTermGroup[] = [
id: 'group-2',
group: [
{
key: 'custom_field.keyword:deviation',
type: 'keyword',
fieldName: 'custom_field.keyword',
fieldValue: 'deviation',
docCount: 49,
pValue: 0.001,
},
{
key: 'airline:AAL',
type: 'keyword',
fieldName: 'airline',
fieldValue: 'AAL',
docCount: 49,
Expand Down
2 changes: 2 additions & 0 deletions x-pack/plugins/aiops/common/api/stream_reducer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ describe('streamReducer', () => {
initialState,
addSignificantTermsAction([
{
key: 'the-field-name:the-field-value',
type: 'keyword',
fieldName: 'the-field-name',
fieldValue: 'the-field-value',
doc_count: 10,
Expand Down
4 changes: 3 additions & 1 deletion x-pack/plugins/aiops/common/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import type { SignificantTerm, FieldValuePair } from '@kbn/ml-agg-utils';
import type { SignificantTerm, SignificantTermType, FieldValuePair } from '@kbn/ml-agg-utils';

export interface SignificantTermDuplicateGroup {
keys: Pick<SignificantTerm, keyof SignificantTerm>;
Expand All @@ -24,6 +24,8 @@ export interface ItemsetResult {
}

interface SimpleHierarchicalTreeNodeSet extends FieldValuePair {
key: string;
type: SignificantTermType;
docCount: number;
pValue: number | null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import type { GroupTableItem } from '../../components/log_rate_analysis_results_
import { buildExtendedBaseFilterCriteria } from './build_extended_base_filter_criteria';

const selectedSignificantTermMock: SignificantTerm = {
key: 'meta.cloud.instance_id.keyword:1234',
type: 'keyword',
doc_count: 53408,
bg_count: 1154,
fieldName: 'meta.cloud.instance_id.keyword',
Expand Down
Loading