-
Notifications
You must be signed in to change notification settings - Fork 8.6k
[Synthetics] Schema configuration and Server side changes for CCS settings #262497
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
Merged
Merged
Changes from 28 commits
Commits
Show all changes
59 commits
Select commit
Hold shift + click to select a range
1e35b0d
Define CCS settings and remote monitor io-ts types
mgiota a7c72dd
remove storedSyntheticsCCSSettingsSchema, not needed, it is a new SO
mgiota 937691f
Add CCS settings API, saved object, and route wrapper wiring
mgiota 1e1aeb8
Changes from node scripts/check_mappings_update --fix
kibanamachine 82672ca
Changes from node scripts/eslint_all_files --no-cache --fix
kibanamachine efb4d05
add unit tests for get_synthetics_indices and settings repository
mgiota 825bce9
fix failing check_registered_types tests
mgiota 53f7ba1
CI fixes
mgiota 55db7fe
add maxSize to the remoteKibanaUrls schema
mgiota 247e55a
Merge branch 'main' into ccs/types-and-settings-api
mgiota d5a79c8
Add kibanaUrl deep-link resolution plumbing for CCS (#259268)
mgiota 1ba8f33
add unit tests for remote_result_utils
mgiota a563e17
Decorate ping results with remote cluster info for CCS (#259267)
mgiota 18f4d03
Changes from node scripts/eslint_all_files --no-cache --fix
kibanamachine 113ada6
Register synthetics-ccs-settings in the previouslyRegisteredTypes gua…
mgiota 67dc454
Add remote cluster configuration UI to Synthetics Settings page (#259…
mgiota b6b39ca
Merge branch 'main' into ccs/types-and-settings-api
mgiota 5792e2b
fix jest mock
mgiota c8fa165
Changes from node scripts/eslint_all_files --no-cache --fix
kibanamachine 8912e77
fix forwardCompatibility CI error
mgiota 6b6e5ee
fix useFetcher hook unnecessary dependency error
mgiota 4cf4fc4
fix mock issue
mgiota 307fba2
Changes from node scripts/jest_integration -u src/core/server/integra…
kibanamachine c716317
Merge branch 'main' into ccs/types-and-settings-api
mgiota 67f30f4
feat(synthetics): support remote monitors in overview status service
mgiota 404d3fe
feat(synthetics): gate CCS settings UI behind experimental feature flag
mgiota ad62f59
fix type issues
mgiota 2e4e96b
fix(synthetics): remove no-op ternary in remote monitor schedule field
mgiota 14b6d7c
Changes from node scripts/eslint_all_files --no-cache --fix
kibanamachine f2fac50
fix type issues
mgiota 92ed41c
Changes from node scripts/eslint_all_files --no-cache --fix
kibanamachine 705d450
fix failing unit tests
mgiota 6b38e73
Merge branch 'main' into ccs/types-and-settings-api
mgiota a943bd7
Merge branch 'main' into ccs/types-and-settings-api
mgiota f9d381c
Merge branch 'main' into ccs/types-and-settings-api
mgiota f0293f0
Merge branch 'main' into ccs/types-and-settings-api
mgiota d69c474
Merge branch 'main' into ccs/types-and-settings-api
mgiota b525a35
Merge branch 'main' into ccs/types-and-settings-api
mgiota 209c664
Merge branch 'main' into ccs/types-and-settings-api
mgiota deeccc9
Merge branch 'main' into ccs/types-and-settings-api
mgiota e6759a6
Merge CCS settings into existing dynamic settings saved object
mgiota ef80ca7
Changes from node scripts/check_mappings_update --fix
kibanamachine 11d7fc8
reverts saved object changes
mgiota 577db60
fix failing unit tests
mgiota f2cfd29
fix(synthetics): gate remote monitor detection behind CCS feature flag
mgiota 9ca5221
remove leftover artifacts after using existing dynamic settings saved…
mgiota a58a069
add isCCSEnabled utility helper
mgiota 2648664
ccs test coverage
mgiota 2e9bff7
fix(synthetics): reduce test memory footprint for overview status pag…
mgiota 190913f
revert changes to overview_status_service, this will be handled in th…
mgiota 4afce36
fix(synthetics): fix CCS settings form test mocking for isCCSEnabled …
mgiota ee18bcd
Merge branch 'main' into ccs/types-and-settings-api
mgiota 2869239
revert remoteKibanaUrls changes
mgiota dc70043
fix failing unit tests
mgiota 461fd1c
Changes from node scripts/eslint_all_files --no-cache --fix
kibanamachine dc28bb5
types cleanup
mgiota ebb6f5b
more test coverage
mgiota 0e20e3c
Merge branch 'main' into ccs/types-and-settings-api
mgiota 6149283
remove ccs_settings route & use existing dynamic_settings route
mgiota File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
74 changes: 74 additions & 0 deletions
74
x-pack/solutions/observability/plugins/synthetics/common/get_synthetics_indices.test.ts
This file contains hidden or 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,74 @@ | ||
| /* | ||
| * 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 { SYNTHETICS_INDEX_PATTERN } from './constants'; | ||
| import { getSyntheticsIndices } from './get_synthetics_indices'; | ||
|
|
||
| describe('getSyntheticsIndices', () => { | ||
| it('returns only the local index when CCS is disabled', () => { | ||
| const result = getSyntheticsIndices({ | ||
| useAllRemoteClusters: false, | ||
| selectedRemoteClusters: [], | ||
| }); | ||
| expect(result).toStrictEqual([SYNTHETICS_INDEX_PATTERN]); | ||
| }); | ||
|
|
||
| it('returns a wildcard remote and the local index when useAllRemoteClusters is true', () => { | ||
| const result = getSyntheticsIndices({ | ||
| useAllRemoteClusters: true, | ||
| selectedRemoteClusters: [], | ||
| remoteClusters: [ | ||
| { name: 'cluster1', isConnected: true }, | ||
| { name: 'cluster2', isConnected: true }, | ||
| ], | ||
| }); | ||
| expect(result).toStrictEqual([SYNTHETICS_INDEX_PATTERN, `*:${SYNTHETICS_INDEX_PATTERN}`]); | ||
| }); | ||
|
|
||
| it('returns only connected clusters from the selected list', () => { | ||
| const result = getSyntheticsIndices({ | ||
| useAllRemoteClusters: false, | ||
| selectedRemoteClusters: ['cluster1', 'cluster3'], | ||
| remoteClusters: [ | ||
| { name: 'cluster1', isConnected: true }, | ||
| { name: 'cluster2', isConnected: true }, | ||
| { name: 'cluster3', isConnected: false }, | ||
| ], | ||
| }); | ||
| expect(result).toStrictEqual([ | ||
| SYNTHETICS_INDEX_PATTERN, | ||
| `cluster1:${SYNTHETICS_INDEX_PATTERN}`, | ||
| ]); | ||
| }); | ||
|
|
||
| it('excludes clusters not in the selected list even if connected', () => { | ||
| const result = getSyntheticsIndices({ | ||
| useAllRemoteClusters: false, | ||
| selectedRemoteClusters: ['cluster1'], | ||
| remoteClusters: [ | ||
| { name: 'cluster1', isConnected: true }, | ||
| { name: 'cluster2', isConnected: true }, | ||
| ], | ||
| }); | ||
| expect(result).toStrictEqual([ | ||
| SYNTHETICS_INDEX_PATTERN, | ||
| `cluster1:${SYNTHETICS_INDEX_PATTERN}`, | ||
| ]); | ||
| }); | ||
|
|
||
| it('returns only the local index when selected clusters are all disconnected', () => { | ||
| const result = getSyntheticsIndices({ | ||
| useAllRemoteClusters: false, | ||
| selectedRemoteClusters: ['cluster1', 'cluster2'], | ||
| remoteClusters: [ | ||
| { name: 'cluster1', isConnected: false }, | ||
| { name: 'cluster2', isConnected: false }, | ||
| ], | ||
| }); | ||
| expect(result).toStrictEqual([SYNTHETICS_INDEX_PATTERN]); | ||
| }); | ||
| }); |
44 changes: 44 additions & 0 deletions
44
x-pack/solutions/observability/plugins/synthetics/common/get_synthetics_indices.ts
This file contains hidden or 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,44 @@ | ||
| /* | ||
| * 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 { SYNTHETICS_INDEX_PATTERN } from './constants'; | ||
|
|
||
| interface Props { | ||
| useAllRemoteClusters: boolean; | ||
| selectedRemoteClusters: string[]; | ||
| remoteClusters?: Array<{ name: string; isConnected: boolean }>; | ||
| } | ||
|
|
||
| /** | ||
| * @returns the local synthetics index or the remote cluster indices based on the CCS settings. | ||
| * If `useAllRemoteClusters` is false and no remote clusters are selected, returns only the local index. | ||
| * If `useAllRemoteClusters` is true, returns both the local index and a wildcard remote index. | ||
| * If specific clusters are selected, returns the local index plus indices for connected selected clusters. | ||
| */ | ||
| export const getSyntheticsIndices = ({ | ||
| useAllRemoteClusters, | ||
| selectedRemoteClusters, | ||
| remoteClusters = [], | ||
| }: Props): string[] => { | ||
| if (!useAllRemoteClusters && selectedRemoteClusters.length === 0) { | ||
| return [SYNTHETICS_INDEX_PATTERN]; | ||
| } | ||
|
|
||
| if (useAllRemoteClusters) { | ||
| return [SYNTHETICS_INDEX_PATTERN, `*:${SYNTHETICS_INDEX_PATTERN}`]; | ||
| } | ||
|
|
||
| return remoteClusters.reduce( | ||
| (acc, { name, isConnected }) => { | ||
| if (isConnected && selectedRemoteClusters.includes(name)) { | ||
| acc.push(`${name}:${SYNTHETICS_INDEX_PATTERN}`); | ||
| } | ||
| return acc; | ||
| }, | ||
| [SYNTHETICS_INDEX_PATTERN] as string[] | ||
| ); | ||
| }; |
22 changes: 22 additions & 0 deletions
22
x-pack/solutions/observability/plugins/synthetics/common/runtime_types/ccs_settings.ts
This file contains hidden or 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,22 @@ | ||
| /* | ||
| * 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 * as t from 'io-ts'; | ||
|
|
||
| export const remoteSyntheticsClusterSchema = t.type({ | ||
| name: t.string, | ||
| isConnected: t.boolean, | ||
| }); | ||
|
|
||
| export const syntheticsCCSSettingsSchema = t.type({ | ||
| useAllRemoteClusters: t.boolean, | ||
| selectedRemoteClusters: t.array(t.string), | ||
| remoteKibanaUrls: t.record(t.string, t.string), | ||
| }); | ||
|
|
||
| export type RemoteSyntheticsCluster = t.TypeOf<typeof remoteSyntheticsClusterSchema>; | ||
| export type SyntheticsCCSSettings = t.TypeOf<typeof syntheticsCCSSettingsSchema>; |
This file contains hidden or 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 hidden or 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 hidden or 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
15 changes: 15 additions & 0 deletions
15
x-pack/solutions/observability/plugins/synthetics/common/runtime_types/remote.ts
This file contains hidden or 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,15 @@ | ||
| /* | ||
| * 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 * as t from 'io-ts'; | ||
|
|
||
| export const remoteMonitorInfoSchema = t.type({ | ||
| remoteName: t.string, | ||
| kibanaUrl: t.string, | ||
| }); | ||
|
|
||
| export type RemoteMonitorInfo = t.TypeOf<typeof remoteMonitorInfoSchema>; |
This file contains hidden or 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
39 changes: 39 additions & 0 deletions
39
.../public/apps/synthetics/components/settings/remote_clusters/hooks/use_get_ccs_settings.ts
This file contains hidden or 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,39 @@ | ||
| /* | ||
| * 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 { useContext } from 'react'; | ||
| import { useFetcher } from '@kbn/observability-shared-plugin/public'; | ||
| import type { SyntheticsCCSSettings } from '../../../../../../../common/runtime_types'; | ||
| import { SYNTHETICS_API_URLS } from '../../../../../../../common/constants'; | ||
| import { apiService } from '../../../../../../utils/api_service'; | ||
| import { SyntheticsRefreshContext } from '../../../../contexts'; | ||
|
|
||
| export const DEFAULT_CCS_SETTINGS: SyntheticsCCSSettings = { | ||
| useAllRemoteClusters: false, | ||
| selectedRemoteClusters: [], | ||
| remoteKibanaUrls: {}, | ||
| }; | ||
|
|
||
| const fetchCCSSettings = async () => { | ||
| try { | ||
| return await apiService.get<SyntheticsCCSSettings>(SYNTHETICS_API_URLS.CCS_SETTINGS); | ||
| } catch (e) { | ||
| return DEFAULT_CCS_SETTINGS; | ||
| } | ||
| }; | ||
|
|
||
| export const useGetCCSSettings = () => { | ||
| const { lastRefresh } = useContext(SyntheticsRefreshContext); | ||
|
|
||
| const { data, error, loading } = useFetcher(fetchCCSSettings, [lastRefresh]); | ||
|
|
||
| return { | ||
| data: data ?? DEFAULT_CCS_SETTINGS, | ||
| error, | ||
| loading, | ||
| }; | ||
| }; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mgiota i wonder if we need to add an extra saved object type for this? why not keep those things part of existing settings saved object?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@shahzad31 Yep good point, I thought about that. The existing settings are a global singleton (
namespaceType: 'single'), but CCS settings need to be per-space (multiple-isolated) so different spaces can configure different remote clusters. These namespace types are mutually exclusive on a single saved object type, so a separate type is necessary. What do you think?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@shahzad31 As discussed I used existing dynamic settings saved object. Revert changes in following commits e6759a6 and 11d7fc8