-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ML] AIOps: Tweak function API for fetchTopCategories/fetchTopTerms (#…
…189863) ## Summary Follow up to #187669. Part of #187684. Fixes #176387. (Ran the flaky test runner on AIOps functional tests) - Fixes the `size: 0` option to be properly nested for `createCategoryRequest()`. - Changes the arguments structure for `fetchTopCategories` and `fetchTopTerms` from individual arguments to an options object to be more in line with the other functions used for log rate analysis. - Adds jest unit test for `fetchTopCategories` and `fetchTopTerms`. ### Checklist - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios - [x] [Flaky Test Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was used on any tests changed - [x] This was checked for breaking API changes and was [labeled appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)
- Loading branch information
Showing
13 changed files
with
1,872 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
x-pack/packages/ml/aiops_log_rate_analysis/queries/__mocks__/top_categories_result.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
export const topCategoriesResultMock = [ | ||
{ | ||
bg_count: 0, | ||
doc_count: 1642, | ||
fieldName: 'message', | ||
fieldValue: | ||
'71.231.222.196 - - [2018-08-13T05:04:08.731Z] "GET /kibana/kibana-6.3.2-windows-x86_64.zip HTTP/1.1" 200 15139 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:6.0a1) Gecko/20110421 Firefox/6.0a1"', | ||
key: 'GET HTTP/1.1 Mozilla/5.0 X11 Linux x86_64 rv Gecko/20110421 Firefox/6.0a1', | ||
normalizedScore: 0, | ||
pValue: 1, | ||
score: 0, | ||
total_bg_count: 0, | ||
total_doc_count: 0, | ||
type: 'log_pattern', | ||
}, | ||
{ | ||
bg_count: 0, | ||
doc_count: 1488, | ||
fieldName: 'message', | ||
fieldValue: | ||
'7.210.210.41 - - [2018-08-13T04:20:49.558Z] "GET /elasticsearch/elasticsearch-6.3.2.deb HTTP/1.1" 404 6699 "-" "Mozilla/5.0 (X11; Linux i686) AppleWebKit/534.24 (KHTML, like Gecko) Chrome/11.0.696.50 Safari/534.24"', | ||
key: 'GET HTTP/1.1 Mozilla/5.0 X11 Linux i686 AppleWebKit/534.24 KHTML like Gecko Chrome/11.0.696.50 Safari/534.24', | ||
normalizedScore: 0, | ||
pValue: 1, | ||
score: 0, | ||
total_bg_count: 0, | ||
total_doc_count: 0, | ||
type: 'log_pattern', | ||
}, | ||
]; |
75 changes: 75 additions & 0 deletions
75
...k/packages/ml/aiops_log_rate_analysis/queries/__mocks__/top_categories_search_response.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
export const topCategoriesSearchResponseMock = { | ||
took: 98, | ||
responses: [ | ||
{ | ||
took: 98, | ||
timed_out: false, | ||
_shards: { total: 1, successful: 1, skipped: 0, failed: 0 }, | ||
hits: { total: { value: 4413, relation: 'eq' }, max_score: null, hits: [] }, | ||
aggregations: { | ||
categories: { | ||
buckets: [ | ||
{ | ||
doc_count: 1642, | ||
key: 'GET HTTP/1.1 Mozilla/5.0 X11 Linux x86_64 rv Gecko/20110421 Firefox/6.0a1', | ||
regex: | ||
'.*?GET.+?HTTP/1\\.1.+?Mozilla/5\\.0.+?X11.+?Linux.+?x86_64.+?rv.+?Gecko/20110421.+?Firefox/6\\.0a1.*?', | ||
max_matching_length: 233, | ||
examples: { | ||
hits: { | ||
total: { value: 1642, relation: 'eq' }, | ||
max_score: null, | ||
hits: [ | ||
{ | ||
_index: '.ds-kibana_sample_data_logs-2024.07.08-000001', | ||
_id: 'zpkLk5AB4oRN3GwDmOW1', | ||
_score: null, | ||
_source: { | ||
message: | ||
'71.231.222.196 - - [2018-08-13T05:04:08.731Z] "GET /kibana/kibana-6.3.2-windows-x86_64.zip HTTP/1.1" 200 15139 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:6.0a1) Gecko/20110421 Firefox/6.0a1"', | ||
}, | ||
sort: [1721624648731], | ||
}, | ||
], | ||
}, | ||
}, | ||
}, | ||
{ | ||
doc_count: 1488, | ||
key: 'GET HTTP/1.1 Mozilla/5.0 X11 Linux i686 AppleWebKit/534.24 KHTML like Gecko Chrome/11.0.696.50 Safari/534.24', | ||
regex: | ||
'.*?GET.+?HTTP/1\\.1.+?Mozilla/5\\.0.+?X11.+?Linux.+?i686.+?AppleWebKit/534\\.24.+?KHTML.+?like.+?Gecko.+?Chrome/11\\.0\\.696\\.50.+?Safari/534\\.24.*?', | ||
max_matching_length: 266, | ||
examples: { | ||
hits: { | ||
total: { value: 1488, relation: 'eq' }, | ||
max_score: null, | ||
hits: [ | ||
{ | ||
_index: '.ds-kibana_sample_data_logs-2024.07.08-000001', | ||
_id: 'VpkLk5AB4oRN3GwDmOW1', | ||
_score: null, | ||
_source: { | ||
message: | ||
'7.210.210.41 - - [2018-08-13T04:20:49.558Z] "GET /elasticsearch/elasticsearch-6.3.2.deb HTTP/1.1" 404 6699 "-" "Mozilla/5.0 (X11; Linux i686) AppleWebKit/534.24 (KHTML, like Gecko) Chrome/11.0.696.50 Safari/534.24"', | ||
}, | ||
sort: [1721622049558], | ||
}, | ||
], | ||
}, | ||
}, | ||
}, | ||
], | ||
}, | ||
}, | ||
status: 200, | ||
}, | ||
], | ||
}; |
Oops, something went wrong.