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.
[8.x] [Response Ops][Alerting] Creating global service for fetching a…
…nd caching rules settings (elastic#192404) (elastic#193011) # Backport This will backport the following commits from `main` to `8.x`: - [[Response Ops][Alerting] Creating global service for fetching and caching rules settings (elastic#192404)](elastic#192404) <!--- Backport version: 9.4.3 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Ying Mao","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-09-16T13:22:44Z","message":"[Response Ops][Alerting] Creating global service for fetching and caching rules settings (elastic#192404)\n\nResolves elastic#184321 and\r\nhttps://github.com/elastic/issues/149884\r\n\r\n## Summary\r\n\r\nCreated a `RulesSettingsService` that caches flapping and query delay\r\nsettings per space for 1 minute so rules are not accessing the SO index\r\nwith every execution.\r\n\r\nAlso moved all classes related to the rules settings into the\r\n`rules_settings` folder so some of these changes are just renaming\r\nchanges.\r\n\r\n## To Verify\r\n1. Add some logging to\r\n`x-pack/plugins/alerting/server/rules_settings/rules_settings_service.ts`\r\nto indicate when settings are being fetched and when they're returning\r\nfrom the cache.\r\n2. Create and run some rules in different spaces to see that flapping\r\nand query delay settings are being returned from the cache when the\r\ncache has not expired.\r\n\r\n---------\r\n\r\nCo-authored-by: Elastic Machine <[email protected]>","sha":"7a0fe2e83683cf38c537694daa88a3a75bfe3e57","branchLabelMapping":{"^v9.0.0$":"main","^v8.16.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Feature:Alerting","release_note:skip","Team:ResponseOps","v9.0.0","backport:prev-minor","v8.16.0"],"title":"[Response Ops][Alerting] Creating global service for fetching and caching rules settings","number":192404,"url":"https://github.com/elastic/kibana/pull/192404","mergeCommit":{"message":"[Response Ops][Alerting] Creating global service for fetching and caching rules settings (elastic#192404)\n\nResolves elastic#184321 and\r\nhttps://github.com/elastic/issues/149884\r\n\r\n## Summary\r\n\r\nCreated a `RulesSettingsService` that caches flapping and query delay\r\nsettings per space for 1 minute so rules are not accessing the SO index\r\nwith every execution.\r\n\r\nAlso moved all classes related to the rules settings into the\r\n`rules_settings` folder so some of these changes are just renaming\r\nchanges.\r\n\r\n## To Verify\r\n1. Add some logging to\r\n`x-pack/plugins/alerting/server/rules_settings/rules_settings_service.ts`\r\nto indicate when settings are being fetched and when they're returning\r\nfrom the cache.\r\n2. Create and run some rules in different spaces to see that flapping\r\nand query delay settings are being returned from the cache when the\r\ncache has not expired.\r\n\r\n---------\r\n\r\nCo-authored-by: Elastic Machine <[email protected]>","sha":"7a0fe2e83683cf38c537694daa88a3a75bfe3e57"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/192404","number":192404,"mergeCommit":{"message":"[Response Ops][Alerting] Creating global service for fetching and caching rules settings (elastic#192404)\n\nResolves elastic#184321 and\r\nhttps://github.com/elastic/issues/149884\r\n\r\n## Summary\r\n\r\nCreated a `RulesSettingsService` that caches flapping and query delay\r\nsettings per space for 1 minute so rules are not accessing the SO index\r\nwith every execution.\r\n\r\nAlso moved all classes related to the rules settings into the\r\n`rules_settings` folder so some of these changes are just renaming\r\nchanges.\r\n\r\n## To Verify\r\n1. Add some logging to\r\n`x-pack/plugins/alerting/server/rules_settings/rules_settings_service.ts`\r\nto indicate when settings are being fetched and when they're returning\r\nfrom the cache.\r\n2. Create and run some rules in different spaces to see that flapping\r\nand query delay settings are being returned from the cache when the\r\ncache has not expired.\r\n\r\n---------\r\n\r\nCo-authored-by: Elastic Machine <[email protected]>","sha":"7a0fe2e83683cf38c537694daa88a3a75bfe3e57"}},{"branch":"8.x","label":"v8.16.0","branchLabelMappingKey":"^v8.16.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> Co-authored-by: Ying Mao <[email protected]>
- Loading branch information
1 parent
02f8d09
commit 7939f22
Showing
38 changed files
with
563 additions
and
157 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
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
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
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
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.
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
File renamed without changes.
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
File renamed without changes.
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
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
23 changes: 23 additions & 0 deletions
23
x-pack/plugins/alerting/server/rules_settings/rules_settings_service.mock.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,23 @@ | ||
/* | ||
* 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 { DEFAULT_FLAPPING_SETTINGS, DEFAULT_QUERY_DELAY_SETTINGS } from '../types'; | ||
|
||
const createRulesSettingsServiceMock = () => { | ||
return jest.fn().mockImplementation(() => { | ||
return { | ||
getSettings: jest.fn().mockReturnValue({ | ||
queryDelaySettings: DEFAULT_QUERY_DELAY_SETTINGS, | ||
flappingSettings: DEFAULT_FLAPPING_SETTINGS, | ||
}), | ||
}; | ||
}); | ||
}; | ||
|
||
export const rulesSettingsServiceMock = { | ||
create: createRulesSettingsServiceMock(), | ||
}; |
Oops, something went wrong.