forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Custom threshold] Add log rate analysis to the alert details page fo…
…r one document count aggregation (elastic#174031) Closes elastic#171163 ## Summary This PR adds log rate analysis to the alert details page for one document count aggregation if the user has a license above platinum. This is a similar implementation in the log threshold alert details page. ![image](https://github.com/elastic/kibana/assets/12370520/29cd29bf-ead5-4574-8121-739d3ed11fe7) ## 🧪 How to test? - Create a Custom threshold rule with only one document count aggregation - Optional filter, document count aggregation filter, and group by information will be applied to the query of this component. - Go to the alert details page, you should see the log rate analysis on this page --------- Co-authored-by: kibanamachine <[email protected]>
- Loading branch information
1 parent
35514f7
commit 702b207
Showing
23 changed files
with
816 additions
and
70 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
28 changes: 28 additions & 0 deletions
28
x-pack/plugins/observability/common/utils/get_interval_in_seconds.test.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,28 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
import { getIntervalInSeconds } from './get_interval_in_seconds'; | ||
|
||
describe('getIntervalInSeconds', () => { | ||
const testData = [ | ||
{ interval: '5ms', result: 0.005 }, | ||
{ interval: '70s', result: 70 }, | ||
{ interval: '25m', result: 1500 }, | ||
{ interval: '10h', result: 36000 }, | ||
{ interval: '3d', result: 259200 }, | ||
{ interval: '1w', result: 604800 }, | ||
{ interval: '1y', result: 30758400 }, | ||
]; | ||
|
||
it.each(testData)('getIntervalInSeconds($interval) = $result', ({ interval, result }) => { | ||
expect(getIntervalInSeconds(interval)).toBe(result); | ||
}); | ||
|
||
it('Throws error if interval is not valid', () => { | ||
expect(() => getIntervalInSeconds('invalid')).toThrow('Invalid interval string format.'); | ||
}); | ||
}); |
32 changes: 32 additions & 0 deletions
32
x-pack/plugins/observability/common/utils/get_interval_in_seconds.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,32 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
const intervalUnits = ['y', 'M', 'w', 'd', 'h', 'm', 's', 'ms']; | ||
const INTERVAL_STRING_RE = new RegExp('^([0-9\\.]*)\\s*(' + intervalUnits.join('|') + ')$'); | ||
|
||
interface UnitsToSeconds { | ||
[unit: string]: number; | ||
} | ||
|
||
const units: UnitsToSeconds = { | ||
ms: 0.001, | ||
s: 1, | ||
m: 60, | ||
h: 3600, | ||
d: 86400, | ||
w: 86400 * 7, | ||
M: 86400 * 30, | ||
y: 86400 * 356, | ||
}; | ||
|
||
export const getIntervalInSeconds = (interval: string): number => { | ||
const matches = interval.match(INTERVAL_STRING_RE); | ||
if (matches) { | ||
return parseFloat(matches[1]) * units[matches[2]]; | ||
} | ||
throw new Error('Invalid interval string format.'); | ||
}; |
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
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
File renamed without changes.
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
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
Oops, something went wrong.