diff --git a/x-pack/plugins/synthetics/public/apps/synthetics/components/monitor_details/hooks/use_monitor_query_id.ts b/x-pack/plugins/synthetics/public/apps/synthetics/components/monitor_details/hooks/use_monitor_query_id.ts index 4b1e88461fa161..ab908652d23846 100644 --- a/x-pack/plugins/synthetics/public/apps/synthetics/components/monitor_details/hooks/use_monitor_query_id.ts +++ b/x-pack/plugins/synthetics/public/apps/synthetics/components/monitor_details/hooks/use_monitor_query_id.ts @@ -5,18 +5,11 @@ * 2.0. */ -import { useParams } from 'react-router-dom'; import { ConfigKey } from '../../../../../../common/runtime_types'; import { useSelectedMonitor } from './use_selected_monitor'; export const useMonitorQueryId = () => { - const { monitorId } = useParams<{ monitorId: string }>(); - const { monitor } = useSelectedMonitor(); - if (monitor && monitor.origin === 'project') { - return monitor[ConfigKey.CUSTOM_HEARTBEAT_ID]!; - } - - return monitorId; + return monitor?.[ConfigKey.MONITOR_QUERY_ID]; }; diff --git a/x-pack/plugins/synthetics/public/apps/synthetics/components/monitor_details/hooks/use_ping_statuses.tsx b/x-pack/plugins/synthetics/public/apps/synthetics/components/monitor_details/hooks/use_ping_statuses.tsx index ca107c7af3ae1a..cb408678c022cd 100644 --- a/x-pack/plugins/synthetics/public/apps/synthetics/components/monitor_details/hooks/use_ping_statuses.tsx +++ b/x-pack/plugins/synthetics/public/apps/synthetics/components/monitor_details/hooks/use_ping_statuses.tsx @@ -8,7 +8,7 @@ import { useEffect, useCallback, useRef } from 'react'; import { useSelector, useDispatch } from 'react-redux'; -import { PingStatus } from '../../../../../../common/runtime_types'; +import { ConfigKey, PingStatus } from '../../../../../../common/runtime_types'; import { getMonitorPingStatusesAction, selectIsMonitorStatusesLoading, @@ -35,8 +35,11 @@ export const usePingStatuses = ({ const location = useSelectedLocation(); const pingStatusesSelector = useCallback(() => { - return selectPingStatusesForMonitorAndLocationAsc(monitor?.id ?? '', location?.label ?? ''); - }, [monitor?.id, location?.label]); + return selectPingStatusesForMonitorAndLocationAsc( + monitor?.[ConfigKey.CONFIG_ID] ?? '', + location?.label ?? '' + ); + }, [monitor, location?.label]); const isLoading = useSelector(selectIsMonitorStatusesLoading); const pingStatuses = useSelector(pingStatusesSelector()) as PingStatus[]; const dispatch = useDispatch(); diff --git a/x-pack/plugins/synthetics/public/apps/synthetics/components/monitor_details/hooks/use_selected_monitor.tsx b/x-pack/plugins/synthetics/public/apps/synthetics/components/monitor_details/hooks/use_selected_monitor.tsx index 6e4d972fb445b9..12fb086326f003 100644 --- a/x-pack/plugins/synthetics/public/apps/synthetics/components/monitor_details/hooks/use_selected_monitor.tsx +++ b/x-pack/plugins/synthetics/public/apps/synthetics/components/monitor_details/hooks/use_selected_monitor.tsx @@ -8,6 +8,7 @@ import { useEffect, useMemo } from 'react'; import { useDispatch, useSelector } from 'react-redux'; import { useParams } from 'react-router-dom'; +import { ConfigKey } from '../../../../../../common/runtime_types'; import { getMonitorAction, selectEncryptedSyntheticsSavedMonitors, @@ -20,16 +21,16 @@ export const useSelectedMonitor = () => { const monitorsList = useSelector(selectEncryptedSyntheticsSavedMonitors); const { loading: monitorListLoading } = useSelector(selectMonitorListState); const monitorFromList = useMemo( - () => monitorsList.find((monitor) => monitor.id === monitorId) ?? null, + () => monitorsList.find((monitor) => monitor[ConfigKey.CONFIG_ID] === monitorId) ?? null, [monitorId, monitorsList] ); - const { syntheticsMonitor, syntheticsMonitorLoading } = useSelector(selectorMonitorDetailsState); const dispatch = useDispatch(); - const isMonitorFromListValid = monitorId && monitorFromList && monitorFromList?.id === monitorId; + const isMonitorFromListValid = + monitorId && monitorFromList && monitorFromList[ConfigKey.CONFIG_ID] === monitorId; const isLoadedSyntheticsMonitorValid = - monitorId && syntheticsMonitor && syntheticsMonitor?.id === monitorId; + monitorId && syntheticsMonitor && syntheticsMonitor[ConfigKey.CONFIG_ID] === monitorId; const availableMonitor = isLoadedSyntheticsMonitorValid ? syntheticsMonitor : isMonitorFromListValid diff --git a/x-pack/plugins/synthetics/public/apps/synthetics/components/monitor_details/monitor_errors/failed_tests.tsx b/x-pack/plugins/synthetics/public/apps/synthetics/components/monitor_details/monitor_errors/failed_tests.tsx index 8db063f50d63a9..c801036e78fd58 100644 --- a/x-pack/plugins/synthetics/public/apps/synthetics/components/monitor_details/monitor_errors/failed_tests.tsx +++ b/x-pack/plugins/synthetics/public/apps/synthetics/components/monitor_details/monitor_errors/failed_tests.tsx @@ -7,7 +7,7 @@ import React from 'react'; import { useKibana } from '@kbn/kibana-react-plugin/public'; -import { useParams } from 'react-router-dom'; +import { useMonitorQueryId } from '../hooks/use_monitor_query_id'; import { ClientPluginsStart } from '../../../../../plugin'; export const MonitorFailedTests = ({ time }: { time: { to: string; from: string } }) => { @@ -15,7 +15,11 @@ export const MonitorFailedTests = ({ time }: { time: { to: string; from: string const { ExploratoryViewEmbeddable } = observability; - const { monitorId } = useParams<{ monitorId: string }>(); + const monitorId = useMonitorQueryId(); + + if (!monitorId) { + return null; + } return ( { const monitorId = useMonitorQueryId(); + if (!monitorId) { + return null; + } + return ( { - +

{OVERVIEW_LABEL}

@@ -52,7 +52,7 @@ export const MonitorErrors = () => {
- +

{FAILED_TESTS_LABEL}

@@ -62,7 +62,7 @@ export const MonitorErrors = () => {
- +

{ERRORS_LABEL}

@@ -70,7 +70,7 @@ export const MonitorErrors = () => {
- +

{FAILED_TESTS_BY_STEPS_LABEL} diff --git a/x-pack/plugins/synthetics/public/apps/synthetics/components/monitor_details/monitor_status/monitor_status_header.tsx b/x-pack/plugins/synthetics/public/apps/synthetics/components/monitor_details/monitor_status/monitor_status_header.tsx index 8de032f1ccd536..dc01cf6c97e5ad 100644 --- a/x-pack/plugins/synthetics/public/apps/synthetics/components/monitor_details/monitor_status/monitor_status_header.tsx +++ b/x-pack/plugins/synthetics/public/apps/synthetics/components/monitor_details/monitor_status/monitor_status_header.tsx @@ -17,6 +17,7 @@ import { import { css } from '@emotion/css'; import { useHistory } from 'react-router-dom'; +import { ConfigKey } from '../../../../../../common/runtime_types'; import { MONITOR_HISTORY_ROUTE } from '../../../../../../common/constants'; import { stringifyUrlParams } from '../../../utils/url_params'; import { useGetUrlParams } from '../../../hooks'; @@ -69,9 +70,12 @@ export const MonitorStatusHeader = ({ { const monitorId = useMonitorQueryId(); - if (!selectedLocation) { + if (!selectedLocation || !monitorId) { return null; } diff --git a/x-pack/plugins/synthetics/public/apps/synthetics/components/monitor_details/monitor_summary/availability_sparklines.tsx b/x-pack/plugins/synthetics/public/apps/synthetics/components/monitor_details/monitor_summary/availability_sparklines.tsx index 905c7c899b6e84..2197d443b469ca 100644 --- a/x-pack/plugins/synthetics/public/apps/synthetics/components/monitor_details/monitor_summary/availability_sparklines.tsx +++ b/x-pack/plugins/synthetics/public/apps/synthetics/components/monitor_details/monitor_summary/availability_sparklines.tsx @@ -29,7 +29,7 @@ export const AvailabilitySparklines = (props: AvailabilitySparklinesProps) => { const selectedLocation = useSelectedLocation(); - if (!selectedLocation) { + if (!selectedLocation || !monitorId) { return null; } diff --git a/x-pack/plugins/synthetics/public/apps/synthetics/components/monitor_details/monitor_summary/duration_panel.tsx b/x-pack/plugins/synthetics/public/apps/synthetics/components/monitor_details/monitor_summary/duration_panel.tsx index 21e9f7fd9ed966..0bfbc9d145a2bd 100644 --- a/x-pack/plugins/synthetics/public/apps/synthetics/components/monitor_details/monitor_summary/duration_panel.tsx +++ b/x-pack/plugins/synthetics/public/apps/synthetics/components/monitor_details/monitor_summary/duration_panel.tsx @@ -27,7 +27,7 @@ export const DurationPanel = (props: DurationPanelProps) => { const monitorId = useMonitorQueryId(); - if (!selectedLocation) { + if (!selectedLocation || !monitorId) { return null; } diff --git a/x-pack/plugins/synthetics/public/apps/synthetics/components/monitor_details/monitor_summary/duration_sparklines.tsx b/x-pack/plugins/synthetics/public/apps/synthetics/components/monitor_details/monitor_summary/duration_sparklines.tsx index dfdba4dc11a931..cc755a4a3553a6 100644 --- a/x-pack/plugins/synthetics/public/apps/synthetics/components/monitor_details/monitor_summary/duration_sparklines.tsx +++ b/x-pack/plugins/synthetics/public/apps/synthetics/components/monitor_details/monitor_summary/duration_sparklines.tsx @@ -8,7 +8,7 @@ import React from 'react'; import { useKibana } from '@kbn/kibana-react-plugin/public'; import { ReportTypes, useTheme } from '@kbn/observability-plugin/public'; -import { useParams } from 'react-router-dom'; +import { useMonitorQueryId } from '../hooks/use_monitor_query_id'; import { ClientPluginsStart } from '../../../../../plugin'; import { useSelectedLocation } from '../hooks/use_selected_location'; @@ -23,13 +23,12 @@ export const DurationSparklines = (props: DurationSparklinesProps) => { observability: { ExploratoryViewEmbeddable }, }, } = useKibana(); - const { monitorId } = useParams<{ monitorId: string }>(); - + const monitorId = useMonitorQueryId(); const theme = useTheme(); const selectedLocation = useSelectedLocation(); - if (!selectedLocation) { + if (!selectedLocation || !monitorId) { return null; } @@ -48,7 +47,7 @@ export const DurationSparklines = (props: DurationSparklinesProps) => { dataType: 'synthetics', selectedMetricField: 'monitor.duration.us', reportDefinitions: { - config_id: [monitorId], + 'monitor.id': [monitorId], 'observer.geo.name': [selectedLocation?.label], }, color: theme.eui.euiColorVis1, diff --git a/x-pack/plugins/synthetics/public/apps/synthetics/components/monitor_details/monitor_summary/duration_trend.tsx b/x-pack/plugins/synthetics/public/apps/synthetics/components/monitor_details/monitor_summary/duration_trend.tsx index 000706140d2671..3df65533802474 100644 --- a/x-pack/plugins/synthetics/public/apps/synthetics/components/monitor_details/monitor_summary/duration_trend.tsx +++ b/x-pack/plugins/synthetics/public/apps/synthetics/components/monitor_details/monitor_summary/duration_trend.tsx @@ -25,7 +25,7 @@ export const MonitorDurationTrend = (props: MonitorDurationTrendProps) => { const monitorId = useMonitorQueryId(); const selectedLocation = useSelectedLocation(); - if (!selectedLocation) { + if (!selectedLocation || !monitorId) { return null; } diff --git a/x-pack/plugins/synthetics/public/apps/synthetics/components/monitor_details/monitor_summary/monitor_complete_count.tsx b/x-pack/plugins/synthetics/public/apps/synthetics/components/monitor_details/monitor_summary/monitor_complete_count.tsx index 7740ba9ce0670e..fd2e9f5f1b2bc3 100644 --- a/x-pack/plugins/synthetics/public/apps/synthetics/components/monitor_details/monitor_summary/monitor_complete_count.tsx +++ b/x-pack/plugins/synthetics/public/apps/synthetics/components/monitor_details/monitor_summary/monitor_complete_count.tsx @@ -23,6 +23,10 @@ export const MonitorCompleteCount = (props: MonitorCompleteCountProps) => { const monitorId = useMonitorQueryId(); + if (!monitorId) { + return null; + } + return ( { const { euiTheme } = useEuiTheme(); + if (!monitorId) { + return null; + } + return ( { if ( (latestPing && latestPing?.config_id !== monitorId) || - (monitor && monitor.id !== monitorId) + (monitor && monitor[ConfigKey.CONFIG_ID] !== monitorId) ) { return ; } diff --git a/x-pack/plugins/synthetics/public/apps/synthetics/components/monitor_details/monitor_summary/monitor_errors_count.tsx b/x-pack/plugins/synthetics/public/apps/synthetics/components/monitor_details/monitor_summary/monitor_errors_count.tsx index b430ac206315bf..8ebc48ea38da98 100644 --- a/x-pack/plugins/synthetics/public/apps/synthetics/components/monitor_details/monitor_summary/monitor_errors_count.tsx +++ b/x-pack/plugins/synthetics/public/apps/synthetics/components/monitor_details/monitor_summary/monitor_errors_count.tsx @@ -26,7 +26,7 @@ export const MonitorErrorsCount = (props: MonitorErrorsCountProps) => { const selectedLocation = useSelectedLocation(); - if (!selectedLocation) { + if (!selectedLocation || !monitorId) { return null; } diff --git a/x-pack/plugins/synthetics/public/apps/synthetics/components/monitor_details/monitor_summary/monitor_total_runs_count.tsx b/x-pack/plugins/synthetics/public/apps/synthetics/components/monitor_details/monitor_summary/monitor_total_runs_count.tsx index 25689d7b1a79dc..f6886a2cf2f632 100644 --- a/x-pack/plugins/synthetics/public/apps/synthetics/components/monitor_details/monitor_summary/monitor_total_runs_count.tsx +++ b/x-pack/plugins/synthetics/public/apps/synthetics/components/monitor_details/monitor_summary/monitor_total_runs_count.tsx @@ -23,6 +23,10 @@ export const MonitorTotalRunsCount = (props: MonitorTotalRunsCountProps) => { const monitorId = useMonitorQueryId(); + if (!monitorId) { + return null; + } + return ( diff --git a/x-pack/plugins/synthetics/public/apps/synthetics/components/monitors_page/hooks/use_inline_errors.ts b/x-pack/plugins/synthetics/public/apps/synthetics/components/monitors_page/hooks/use_inline_errors.ts index c8dac37aebcb7c..800692d2847264 100644 --- a/x-pack/plugins/synthetics/public/apps/synthetics/components/monitors_page/hooks/use_inline_errors.ts +++ b/x-pack/plugins/synthetics/public/apps/synthetics/components/monitors_page/hooks/use_inline_errors.ts @@ -89,7 +89,7 @@ export function useInlineErrors({ filter: getInlineErrorFilters(), }, }, - collapse: { field: 'config_id' }, + collapse: { field: 'monitor.id' }, sort: sortFieldMap[sortField] ? [{ [sortFieldMap[sortField]]: sortOrder }] : undefined, }, }, diff --git a/x-pack/plugins/synthetics/public/apps/synthetics/components/monitors_page/hooks/use_inline_errors_count.ts b/x-pack/plugins/synthetics/public/apps/synthetics/components/monitors_page/hooks/use_inline_errors_count.ts index be6e80e3f84695..0ef0c8d3bb2020 100644 --- a/x-pack/plugins/synthetics/public/apps/synthetics/components/monitors_page/hooks/use_inline_errors_count.ts +++ b/x-pack/plugins/synthetics/public/apps/synthetics/components/monitors_page/hooks/use_inline_errors_count.ts @@ -30,7 +30,7 @@ export function useInlineErrorsCount() { }, aggs: { total: { - cardinality: { field: 'config_id' }, + cardinality: { field: 'monitor.id' }, }, }, }, diff --git a/x-pack/plugins/synthetics/public/apps/synthetics/components/monitors_page/management/monitor_list_table/monitor_details_link.tsx b/x-pack/plugins/synthetics/public/apps/synthetics/components/monitors_page/management/monitor_list_table/monitor_details_link.tsx index 8a92811b9b5c8b..701fd0d0580ed2 100644 --- a/x-pack/plugins/synthetics/public/apps/synthetics/components/monitors_page/management/monitor_list_table/monitor_details_link.tsx +++ b/x-pack/plugins/synthetics/public/apps/synthetics/components/monitors_page/management/monitor_list_table/monitor_details_link.tsx @@ -31,7 +31,10 @@ export const MonitorDetailsLink = ({ const locationId = lastSelectedLocationId && monitorHasLocation ? lastSelectedLocationId : firstMonitorLocationId; - const monitorDetailLinkUrl = useMonitorDetailLocator({ monitorId: monitor.id, locationId }); + const monitorDetailLinkUrl = useMonitorDetailLocator({ + monitorId: monitor[ConfigKey.CONFIG_ID], + locationId, + }); return ( <> diff --git a/x-pack/plugins/synthetics/public/apps/synthetics/hooks/use_last_x_checks.ts b/x-pack/plugins/synthetics/public/apps/synthetics/hooks/use_last_x_checks.ts index 17455ba09bb50d..fd9ee82ecbb9c7 100644 --- a/x-pack/plugins/synthetics/public/apps/synthetics/hooks/use_last_x_checks.ts +++ b/x-pack/plugins/synthetics/public/apps/synthetics/hooks/use_last_x_checks.ts @@ -44,7 +44,7 @@ export function useLastXChecks({ EXCLUDE_RUN_ONCE_FILTER, { term: { - config_id: monitorId, + 'monitor.id': monitorId, }, }, ], diff --git a/x-pack/plugins/synthetics/public/apps/synthetics/state/monitor_details/api.ts b/x-pack/plugins/synthetics/public/apps/synthetics/state/monitor_details/api.ts index c0c8d9ac6dbc47..e04d36d26082f5 100644 --- a/x-pack/plugins/synthetics/public/apps/synthetics/state/monitor_details/api.ts +++ b/x-pack/plugins/synthetics/public/apps/synthetics/state/monitor_details/api.ts @@ -75,7 +75,6 @@ export const fetchSyntheticsMonitor = async ({ return { ...savedObject.attributes, - id: savedObject.id, updated_at: savedObject.updated_at, } as EncryptedSyntheticsSavedMonitor; }; diff --git a/x-pack/plugins/synthetics/public/apps/synthetics/state/monitor_list/selectors.ts b/x-pack/plugins/synthetics/public/apps/synthetics/state/monitor_list/selectors.ts index d53e6ea9f2b7f4..1463cd2ba5e3c5 100644 --- a/x-pack/plugins/synthetics/public/apps/synthetics/state/monitor_list/selectors.ts +++ b/x-pack/plugins/synthetics/public/apps/synthetics/state/monitor_list/selectors.ts @@ -7,7 +7,7 @@ import { createSelector } from 'reselect'; -import { EncryptedSyntheticsSavedMonitor } from '../../../../../common/runtime_types'; +import { ConfigKey, EncryptedSyntheticsSavedMonitor } from '../../../../../common/runtime_types'; import { SyntheticsAppState } from '../root_reducer'; export const selectMonitorListState = (state: SyntheticsAppState) => state.monitorList; @@ -16,7 +16,7 @@ export const selectEncryptedSyntheticsSavedMonitors = createSelector( (state) => state.data.monitors.map((monitor) => ({ ...monitor.attributes, - id: monitor.id, + id: monitor.attributes[ConfigKey.MONITOR_QUERY_ID], updated_at: monitor.updated_at, })) as EncryptedSyntheticsSavedMonitor[] ); diff --git a/x-pack/plugins/synthetics/public/legacy_uptime/components/monitor_management/hooks/use_inline_errors.test.tsx b/x-pack/plugins/synthetics/public/legacy_uptime/components/monitor_management/hooks/use_inline_errors.test.tsx index 5f331ee5f48c80..5d5aad7a37a875 100644 --- a/x-pack/plugins/synthetics/public/legacy_uptime/components/monitor_management/hooks/use_inline_errors.test.tsx +++ b/x-pack/plugins/synthetics/public/legacy_uptime/components/monitor_management/hooks/use_inline_errors.test.tsx @@ -33,7 +33,7 @@ describe('useInlineErrors', function () { 3, { body: { - collapse: { field: 'config_id' }, + collapse: { field: 'monitor.id' }, query: { bool: { filter: [ diff --git a/x-pack/plugins/synthetics/public/legacy_uptime/components/monitor_management/hooks/use_inline_errors.ts b/x-pack/plugins/synthetics/public/legacy_uptime/components/monitor_management/hooks/use_inline_errors.ts index 9970622ca416b4..9086ce641870db 100644 --- a/x-pack/plugins/synthetics/public/legacy_uptime/components/monitor_management/hooks/use_inline_errors.ts +++ b/x-pack/plugins/synthetics/public/legacy_uptime/components/monitor_management/hooks/use_inline_errors.ts @@ -89,7 +89,7 @@ export function useInlineErrors({ filter: getInlineErrorFilters(), }, }, - collapse: { field: 'config_id' }, + collapse: { field: 'monitor.id' }, sort: [{ [sortFieldMap[sortField]]: sortOrder }], }, }, diff --git a/x-pack/plugins/synthetics/public/legacy_uptime/components/monitor_management/hooks/use_inline_errors_count.test.tsx b/x-pack/plugins/synthetics/public/legacy_uptime/components/monitor_management/hooks/use_inline_errors_count.test.tsx index e12dbe88d2d2b0..4c9d555a5cdec2 100644 --- a/x-pack/plugins/synthetics/public/legacy_uptime/components/monitor_management/hooks/use_inline_errors_count.test.tsx +++ b/x-pack/plugins/synthetics/public/legacy_uptime/components/monitor_management/hooks/use_inline_errors_count.test.tsx @@ -33,7 +33,7 @@ describe('useInlineErrorsCount', function () { 2, { body: { - aggs: { total: { cardinality: { field: 'config_id' } } }, + aggs: { total: { cardinality: { field: 'monitor.id' } } }, query: { bool: { filter: [ diff --git a/x-pack/plugins/synthetics/public/legacy_uptime/components/monitor_management/hooks/use_inline_errors_count.ts b/x-pack/plugins/synthetics/public/legacy_uptime/components/monitor_management/hooks/use_inline_errors_count.ts index dc69346e6c9a50..154d7921d3b75f 100644 --- a/x-pack/plugins/synthetics/public/legacy_uptime/components/monitor_management/hooks/use_inline_errors_count.ts +++ b/x-pack/plugins/synthetics/public/legacy_uptime/components/monitor_management/hooks/use_inline_errors_count.ts @@ -30,7 +30,7 @@ export function useInlineErrorsCount() { }, aggs: { total: { - cardinality: { field: 'config_id' }, + cardinality: { field: 'monitor.id' }, }, }, }, diff --git a/x-pack/plugins/synthetics/public/legacy_uptime/components/monitor_management/monitor_list/actions.test.tsx b/x-pack/plugins/synthetics/public/legacy_uptime/components/monitor_management/monitor_list/actions.test.tsx index 589403dcfee0a5..930d89f97af2af 100644 --- a/x-pack/plugins/synthetics/public/legacy_uptime/components/monitor_management/monitor_list/actions.test.tsx +++ b/x-pack/plugins/synthetics/public/legacy_uptime/components/monitor_management/monitor_list/actions.test.tsx @@ -23,7 +23,7 @@ describe('', () => { it('navigates to edit monitor flow on edit pencil', () => { render( ', () => { { id: 'test-id', attributes: { + [ConfigKey.CONFIG_ID]: 'test-id', [ConfigKey.MONITOR_SOURCE_TYPE]: SourceType.PROJECT, } as BrowserFields, }, @@ -48,13 +49,14 @@ describe('', () => { it('disables deleting for project monitors', () => { render( void; @@ -31,12 +31,19 @@ interface Props { monitors: MonitorManagementListResult['monitors']; } -export const Actions = ({ id, name, onUpdate, isDisabled, errorSummaries, monitors }: Props) => { +export const Actions = ({ + configId, + name, + onUpdate, + isDisabled, + errorSummaries, + monitors, +}: Props) => { const { basePath } = useContext(UptimeSettingsContext); - let errorSummary = errorSummaries?.find((summary) => summary.config_id === id); + let errorSummary = errorSummaries?.find((summary) => summary.config_id === configId); - const monitor = monitors.find((monitorT) => monitorT.id === id); + const monitor = monitors.find((monitorT) => monitorT.id === configId); const isProjectMonitor = (monitor?.attributes as BrowserFields)[ConfigKey.MONITOR_SOURCE_TYPE] === SourceType.PROJECT; @@ -60,7 +67,7 @@ export const Actions = ({ id, name, onUpdate, isDisabled, errorSummaries, monito @@ -80,7 +87,7 @@ export const Actions = ({ id, name, onUpdate, isDisabled, errorSummaries, monito diff --git a/x-pack/plugins/synthetics/public/legacy_uptime/components/monitor_management/monitor_list/delete_monitor.test.tsx b/x-pack/plugins/synthetics/public/legacy_uptime/components/monitor_management/monitor_list/delete_monitor.test.tsx index 248ed91115c0c4..e708be5c8921f8 100644 --- a/x-pack/plugins/synthetics/public/legacy_uptime/components/monitor_management/monitor_list/delete_monitor.test.tsx +++ b/x-pack/plugins/synthetics/public/legacy_uptime/components/monitor_management/monitor_list/delete_monitor.test.tsx @@ -6,8 +6,7 @@ */ import React from 'react'; -import { screen } from '@testing-library/react'; -import userEvent from '@testing-library/user-event'; +import { screen, fireEvent } from '@testing-library/react'; import { render } from '../../../lib/helper/rtl_helpers'; import * as fetchers from '../../../state/api/monitor_management'; import { FETCH_STATUS, useFetcher as originalUseFetcher } from '@kbn/observability-plugin/public'; @@ -21,7 +20,7 @@ import { SourceType, } from '../../../../../common/runtime_types'; -describe('', () => { +describe('', () => { const onUpdate = jest.fn(); const useFetcher = spyOnUseFetcher({}); @@ -29,13 +28,13 @@ describe('', () => { useFetcher.mockImplementation(originalUseFetcher); const deleteMonitor = jest.spyOn(fetchers, 'deleteMonitor'); const id = 'test-id'; - render(); + render(); expect(deleteMonitor).not.toBeCalled(); - userEvent.click(screen.getByRole('button')); + fireEvent.click(screen.getByRole('button')); - userEvent.click(screen.getByTestId('confirmModalConfirmButton')); + fireEvent.click(screen.getByTestId('confirmModalConfirmButton')); expect(deleteMonitor).toBeCalledWith({ id }); }); @@ -45,15 +44,16 @@ describe('', () => { const name = 'sample monitor'; render( ', () => { /> ); - userEvent.click(screen.getByLabelText('Delete monitor').closest('span') as HTMLElement); + fireEvent.click(screen.getByLabelText('Delete monitor')); expect(onUpdate).toHaveBeenCalled(); }); @@ -75,15 +75,16 @@ describe('', () => { }); render( void; @@ -36,9 +36,9 @@ export const DeleteMonitor = ({ const { status } = useFetcher(() => { if (isDeleting) { - return deleteMonitor({ id }); + return deleteMonitor({ id: configId }); } - }, [id, isDeleting]); + }, [configId, isDeleting]); const handleDelete = () => { showDeleteModal(); diff --git a/x-pack/plugins/synthetics/public/legacy_uptime/components/monitor_management/monitor_list/monitor_list.test.tsx b/x-pack/plugins/synthetics/public/legacy_uptime/components/monitor_management/monitor_list/monitor_list.test.tsx index d35ee0e41cf943..73d0dd1bbaa95d 100644 --- a/x-pack/plugins/synthetics/public/legacy_uptime/components/monitor_management/monitor_list/monitor_list.test.tsx +++ b/x-pack/plugins/synthetics/public/legacy_uptime/components/monitor_management/monitor_list/monitor_list.test.tsx @@ -29,6 +29,7 @@ describe('', () => { id: `test-monitor-id-${i}`, updated_at: '123', attributes: { + config_id: `test-monitor-id-${i}`, name: `test-monitor-${i}`, enabled: true, schedule: { diff --git a/x-pack/plugins/synthetics/public/legacy_uptime/components/monitor_management/monitor_list/monitor_list.tsx b/x-pack/plugins/synthetics/public/legacy_uptime/components/monitor_management/monitor_list/monitor_list.tsx index c603035130ca33..7e475a0c7116ac 100644 --- a/x-pack/plugins/synthetics/public/legacy_uptime/components/monitor_management/monitor_list/monitor_list.tsx +++ b/x-pack/plugins/synthetics/public/legacy_uptime/components/monitor_management/monitor_list/monitor_list.tsx @@ -77,7 +77,6 @@ export const MonitorManagementList = ({ () => list.monitors.map((monitor) => ({ ...monitor.attributes, - id: monitor.id, })), [list.monitors] ); @@ -127,7 +126,7 @@ export const MonitorManagementList = ({ render: (name: string, monitor: EncryptedSyntheticsMonitorWithId) => ( {name} @@ -192,7 +191,7 @@ export const MonitorManagementList = ({ }), render: (_enabled: boolean, monitor: EncryptedSyntheticsMonitorWithId) => ( ( >; - const { items, loading } = useStdErrorLogs({ configId, checkGroup }); + const { items, loading } = useStdErrorLogs({ monitorId, checkGroup }); const { discover, observability } = useKibana().services; diff --git a/x-pack/plugins/synthetics/public/legacy_uptime/components/synthetics/check_steps/use_std_error_logs.ts b/x-pack/plugins/synthetics/public/legacy_uptime/components/synthetics/check_steps/use_std_error_logs.ts index d6abd2445a9a7b..c2ef56213c48ea 100644 --- a/x-pack/plugins/synthetics/public/legacy_uptime/components/synthetics/check_steps/use_std_error_logs.ts +++ b/x-pack/plugins/synthetics/public/legacy_uptime/components/synthetics/check_steps/use_std_error_logs.ts @@ -11,16 +11,16 @@ import { selectDynamicSettings } from '../../../state/selectors'; import { Ping } from '../../../../../common/runtime_types'; export const useStdErrorLogs = ({ - configId, + monitorId, checkGroup, }: { - configId?: string; + monitorId?: string; checkGroup?: string; }) => { const { settings } = useSelector(selectDynamicSettings); const { data, loading } = useEsSearch( createEsParams({ - index: !configId && !checkGroup ? '' : settings?.heartbeatIndices, + index: !monitorId && !checkGroup ? '' : settings?.heartbeatIndices, body: { size: 1000, query: { @@ -31,11 +31,11 @@ export const useStdErrorLogs = ({ 'synthetics.type': 'stderr', }, }, - ...(configId + ...(monitorId ? [ { term: { - config_id: configId, + 'monitor.id': monitorId, }, }, ] diff --git a/x-pack/plugins/synthetics/server/common/pings/query_pings.ts b/x-pack/plugins/synthetics/server/common/pings/query_pings.ts index ac0c0b98a56264..0a156405022483 100644 --- a/x-pack/plugins/synthetics/server/common/pings/query_pings.ts +++ b/x-pack/plugins/synthetics/server/common/pings/query_pings.ts @@ -103,7 +103,7 @@ export async function queryPings( bool: { filter: [ { range: { '@timestamp': { gte: from, lte: to } } }, - ...(monitorId ? [{ term: { config_id: monitorId } }] : []), + ...(monitorId ? [{ term: { 'monitor.id': monitorId } }] : []), ...(status ? [{ term: { 'monitor.status': status } }] : []), ] as QueryDslQueryContainer[], ...REMOVE_NON_SUMMARY_BROWSER_CHECKS, diff --git a/x-pack/plugins/synthetics/server/legacy_uptime/routes/monitors/monitor_status.ts b/x-pack/plugins/synthetics/server/legacy_uptime/routes/monitors/monitor_status.ts index 2bf898bf309d4c..19cd8ecc237895 100644 --- a/x-pack/plugins/synthetics/server/legacy_uptime/routes/monitors/monitor_status.ts +++ b/x-pack/plugins/synthetics/server/legacy_uptime/routes/monitors/monitor_status.ts @@ -47,7 +47,7 @@ export const createGetStatusBarRoute: UMRestApiRouteFactory = (libs: UMServerLib type: syntheticsMonitorType, perPage: 1, page: 1, - filter: `${syntheticsMonitorType}.id: "${syntheticsMonitorType}:${monitorId}" OR ${syntheticsMonitorType}.attributes.${ConfigKey.CUSTOM_HEARTBEAT_ID}: "${monitorId}"`, + filter: `${syntheticsMonitorType}.attributes.${ConfigKey.MONITOR_QUERY_ID}: "${monitorId}"`, }); if (!monitorSavedObject) { diff --git a/x-pack/plugins/synthetics/server/routes/monitor_cruds/add_monitor.ts b/x-pack/plugins/synthetics/server/routes/monitor_cruds/add_monitor.ts index 138224a5a11ea3..dad93a0f60aae9 100644 --- a/x-pack/plugins/synthetics/server/routes/monitor_cruds/add_monitor.ts +++ b/x-pack/plugins/synthetics/server/routes/monitor_cruds/add_monitor.ts @@ -167,6 +167,8 @@ export const syncNewMonitor = async ({ let monitorSavedObject: SavedObject | null = null; const monitorWithNamespace = { ...normalizedMonitor, + [ConfigKey.MONITOR_QUERY_ID]: normalizedMonitor[ConfigKey.CUSTOM_HEARTBEAT_ID] || newMonitorId, + [ConfigKey.CONFIG_ID]: newMonitorId, [ConfigKey.NAMESPACE]: preserveNamespace ? normalizedMonitor[ConfigKey.NAMESPACE] : getMonitorNamespace(server, request, normalizedMonitor[ConfigKey.NAMESPACE]), diff --git a/x-pack/plugins/synthetics/server/routes/monitor_cruds/bulk_cruds/add_monitor_bulk.ts b/x-pack/plugins/synthetics/server/routes/monitor_cruds/bulk_cruds/add_monitor_bulk.ts index 1d8ed3dc9eb676..48c045f602311b 100644 --- a/x-pack/plugins/synthetics/server/routes/monitor_cruds/bulk_cruds/add_monitor_bulk.ts +++ b/x-pack/plugins/synthetics/server/routes/monitor_cruds/bulk_cruds/add_monitor_bulk.ts @@ -62,11 +62,18 @@ export const syncNewMonitorBulk = async ({ spaceId: string; }) => { let newMonitors: SavedObjectsBulkResponse | null = null; - - const monitorsToCreate = normalizedMonitors.map((monitor) => ({ - id: uuidV4(), - monitor: monitor as MonitorFields, - })); + const monitorsToCreate = normalizedMonitors.map((monitor) => { + const monitorSavedObjectId = uuidV4(); + return { + id: monitorSavedObjectId, + monitor: { + ...monitor, + [ConfigKey.CONFIG_ID]: monitorSavedObjectId, + [ConfigKey.MONITOR_QUERY_ID]: + monitor[ConfigKey.CUSTOM_HEARTBEAT_ID] || monitorSavedObjectId, + } as MonitorFields, + }; + }); try { const [createdMonitors, { syncErrors }] = await Promise.all([ diff --git a/x-pack/plugins/synthetics/server/routes/monitor_cruds/bulk_cruds/delete_monitor_bulk.ts b/x-pack/plugins/synthetics/server/routes/monitor_cruds/bulk_cruds/delete_monitor_bulk.ts index 3c83514155747a..189da5d9825be8 100644 --- a/x-pack/plugins/synthetics/server/routes/monitor_cruds/bulk_cruds/delete_monitor_bulk.ts +++ b/x-pack/plugins/synthetics/server/routes/monitor_cruds/bulk_cruds/delete_monitor_bulk.ts @@ -41,7 +41,7 @@ export const deleteMonitorBulk = async ({ const deleteSyncPromise = syntheticsMonitorClient.deleteMonitors( monitors.map((normalizedMonitor) => ({ ...normalizedMonitor.attributes, - id: normalizedMonitor.attributes[ConfigKey.CUSTOM_HEARTBEAT_ID] || normalizedMonitor.id, + id: normalizedMonitor.attributes[ConfigKey.MONITOR_QUERY_ID], })) as EncryptedSyntheticsMonitorWithId[], request, savedObjectsClient, diff --git a/x-pack/plugins/synthetics/server/routes/monitor_cruds/bulk_cruds/edit_monitor_bulk.ts b/x-pack/plugins/synthetics/server/routes/monitor_cruds/bulk_cruds/edit_monitor_bulk.ts index 3f89aab5f1cc2d..8cc6c5c8d30a83 100644 --- a/x-pack/plugins/synthetics/server/routes/monitor_cruds/bulk_cruds/edit_monitor_bulk.ts +++ b/x-pack/plugins/synthetics/server/routes/monitor_cruds/bulk_cruds/edit_monitor_bulk.ts @@ -60,7 +60,12 @@ export const syncEditedMonitorBulk = async ({ monitorsToUpdate.map(({ previousMonitor, monitorWithRevision }) => ({ type: syntheticsMonitorType, id: previousMonitor.id, - attributes: monitorWithRevision, + attributes: { + ...monitorWithRevision, + [ConfigKey.CONFIG_ID]: previousMonitor.id, + [ConfigKey.MONITOR_QUERY_ID]: + monitorWithRevision[ConfigKey.CUSTOM_HEARTBEAT_ID] || previousMonitor.id, + }, })) ); savedObjectsSuccessful = true; @@ -74,7 +79,12 @@ export const syncEditedMonitorBulk = async ({ try { const editSyncPromise = await syntheticsMonitorClient.editMonitors( monitorsToUpdate.map(({ normalizedMonitor, previousMonitor }) => ({ - monitor: normalizedMonitor as MonitorFields, + monitor: { + ...(normalizedMonitor as MonitorFields), + [ConfigKey.CONFIG_ID]: previousMonitor.id, + [ConfigKey.MONITOR_QUERY_ID]: + normalizedMonitor[ConfigKey.CUSTOM_HEARTBEAT_ID] || previousMonitor.id, + }, id: previousMonitor.id, previousMonitor, })), diff --git a/x-pack/plugins/synthetics/server/routes/monitor_cruds/delete_monitor.ts b/x-pack/plugins/synthetics/server/routes/monitor_cruds/delete_monitor.ts index 831f4b2c341e8b..25c484cfea6e75 100644 --- a/x-pack/plugins/synthetics/server/routes/monitor_cruds/delete_monitor.ts +++ b/x-pack/plugins/synthetics/server/routes/monitor_cruds/delete_monitor.ts @@ -110,9 +110,7 @@ export const deleteMonitor = async ({ [ { ...normalizedMonitor.attributes, - id: - (normalizedMonitor.attributes as MonitorFields)[ConfigKey.CUSTOM_HEARTBEAT_ID] || - monitorId, + id: (normalizedMonitor.attributes as MonitorFields)[ConfigKey.MONITOR_QUERY_ID], }, ], request, diff --git a/x-pack/plugins/synthetics/server/routes/monitor_cruds/edit_monitor.test.ts b/x-pack/plugins/synthetics/server/routes/monitor_cruds/edit_monitor.test.ts index 88a60907baf34a..8fd8ac6d150735 100644 --- a/x-pack/plugins/synthetics/server/routes/monitor_cruds/edit_monitor.test.ts +++ b/x-pack/plugins/synthetics/server/routes/monitor_cruds/edit_monitor.test.ts @@ -16,7 +16,6 @@ import { import { UptimeServerSetup } from '../../legacy_uptime/lib/adapters'; import { SyntheticsService } from '../../synthetics_service/synthetics_service'; import { SyntheticsMonitorClient } from '../../synthetics_service/synthetics_monitor/synthetics_monitor_client'; -import { formatSecrets } from '../../synthetics_service/utils'; jest.mock('../telemetry/monitor_upgrade_sender', () => ({ sendTelemetryEvents: jest.fn(), @@ -79,7 +78,7 @@ describe('syncEditedMonitor', () => { } as unknown as SyntheticsMonitor; const previousMonitor = { - id: 'saved-obj-id', + id: '7af7e2f0-d5dc-11ec-87ac-bdfdb894c53d', attributes: { name: editedMonitor.name, locations: [] } as any, type: 'synthetics-monitor', references: [], @@ -94,7 +93,6 @@ describe('syncEditedMonitor', () => { it('includes the isEdit flag', async () => { await syncEditedMonitor({ normalizedMonitor: editedMonitor, - monitorWithRevision: formatSecrets(editedMonitor), previousMonitor, decryptedPreviousMonitor: previousMonitor as unknown as SavedObject, @@ -109,14 +107,14 @@ describe('syncEditedMonitor', () => { expect(syntheticsService.editConfig).toHaveBeenCalledWith( expect.arrayContaining([ expect.objectContaining({ - id: 'saved-obj-id', + id: '7af7e2f0-d5dc-11ec-87ac-bdfdb894c53d', }), ]) ); expect(serverMock.authSavedObjectsClient?.update).toHaveBeenCalledWith( 'synthetics-monitor', - 'saved-obj-id', + '7af7e2f0-d5dc-11ec-87ac-bdfdb894c53d', expect.objectContaining({ enabled: true, }) diff --git a/x-pack/plugins/synthetics/server/routes/monitor_cruds/edit_monitor.ts b/x-pack/plugins/synthetics/server/routes/monitor_cruds/edit_monitor.ts index 086ce90744ca93..2afba69e56f96b 100644 --- a/x-pack/plugins/synthetics/server/routes/monitor_cruds/edit_monitor.ts +++ b/x-pack/plugins/synthetics/server/routes/monitor_cruds/edit_monitor.ts @@ -90,7 +90,6 @@ export const editSyntheticsMonitorRoute: SyntheticsRestApiRouteFactory = () => ( ...validationResult.decodedMonitor, revision: (previousMonitor.attributes[ConfigKey.REVISION] || 0) + 1, }; - const formattedMonitor = formatSecrets(monitorWithRevision); const { errors, editedMonitor: editedMonitorSavedObject } = await syncEditedMonitor({ server, @@ -99,8 +98,7 @@ export const editSyntheticsMonitorRoute: SyntheticsRestApiRouteFactory = () => ( syntheticsMonitorClient, savedObjectsClient, request, - normalizedMonitor: validationResult.decodedMonitor, - monitorWithRevision: formattedMonitor, + normalizedMonitor: monitorWithRevision, spaceId, }); @@ -125,7 +123,6 @@ export const editSyntheticsMonitorRoute: SyntheticsRestApiRouteFactory = () => ( export const syncEditedMonitor = async ({ normalizedMonitor, - monitorWithRevision, previousMonitor, decryptedPreviousMonitor, server, @@ -135,7 +132,6 @@ export const syncEditedMonitor = async ({ spaceId, }: { normalizedMonitor: SyntheticsMonitor; - monitorWithRevision: SyntheticsMonitorWithSecrets; previousMonitor: SavedObject; decryptedPreviousMonitor: SavedObject; server: UptimeServerSetup; @@ -145,16 +141,24 @@ export const syncEditedMonitor = async ({ spaceId: string; }) => { try { + const monitorWithId = { + ...normalizedMonitor, + [ConfigKey.MONITOR_QUERY_ID]: + normalizedMonitor[ConfigKey.CUSTOM_HEARTBEAT_ID] || previousMonitor.id, + [ConfigKey.CONFIG_ID]: previousMonitor.id, + }; + const formattedMonitor = formatSecrets(monitorWithId); + const editedSOPromise = savedObjectsClient.update( syntheticsMonitorType, previousMonitor.id, - monitorWithRevision + formattedMonitor ); const allPrivateLocations = await getSyntheticsPrivateLocations(savedObjectsClient); const editSyncPromise = syntheticsMonitorClient.editMonitors( - [{ monitor: normalizedMonitor as MonitorFields, id: previousMonitor.id, previousMonitor }], + [{ monitor: monitorWithId as MonitorFields, id: previousMonitor.id, previousMonitor }], request, savedObjectsClient, allPrivateLocations, diff --git a/x-pack/plugins/synthetics/server/routes/status/current_status.ts b/x-pack/plugins/synthetics/server/routes/status/current_status.ts index d88c9bc521acda..637990a017f883 100644 --- a/x-pack/plugins/synthetics/server/routes/status/current_status.ts +++ b/x-pack/plugins/synthetics/server/routes/status/current_status.ts @@ -180,7 +180,7 @@ export async function getStatus( if (monitor.attributes[ConfigKey.ENABLED] === false) { disabledCount += monitor.attributes[ConfigKey.LOCATIONS].length; } else { - enabledIds.push(monitor.attributes[ConfigKey.CUSTOM_HEARTBEAT_ID] || monitor.id); + enabledIds.push(monitor.attributes[ConfigKey.MONITOR_QUERY_ID]); maxLocations = Math.max(maxLocations, monitor.attributes.locations.length); maxPeriod = Math.max(maxPeriod, periodToMs(monitor.attributes.schedule)); } diff --git a/x-pack/plugins/synthetics/server/routes/synthetics_service/run_once_monitor.ts b/x-pack/plugins/synthetics/server/routes/synthetics_service/run_once_monitor.ts index 5bbc8c27e3ebe6..a730daa79ef873 100644 --- a/x-pack/plugins/synthetics/server/routes/synthetics_service/run_once_monitor.ts +++ b/x-pack/plugins/synthetics/server/routes/synthetics_service/run_once_monitor.ts @@ -38,6 +38,7 @@ export const runOnceSyntheticsMonitorRoute: SyntheticsRestApiRouteFactory = () = // making it enabled, even if it's disabled in the UI monitor: { ...validationResult.decodedMonitor, enabled: true }, monitorId, + heartbeatId: monitorId, runOnce: true, }), ]); diff --git a/x-pack/plugins/synthetics/server/routes/synthetics_service/test_now_monitor.ts b/x-pack/plugins/synthetics/server/routes/synthetics_service/test_now_monitor.ts index 1c6d6548c575d1..b08dd16871c7b4 100644 --- a/x-pack/plugins/synthetics/server/routes/synthetics_service/test_now_monitor.ts +++ b/x-pack/plugins/synthetics/server/routes/synthetics_service/test_now_monitor.ts @@ -58,9 +58,7 @@ export const testNowMonitorRoute: SyntheticsRestApiRouteFactory = () => ({ // making it enabled, even if it's disabled in the UI monitor: { ...normalizedMonitor.attributes, enabled: true }, monitorId, - customHeartbeatId: (normalizedMonitor.attributes as MonitorFields)[ - ConfigKey.CUSTOM_HEARTBEAT_ID - ], + heartbeatId: (normalizedMonitor.attributes as MonitorFields)[ConfigKey.MONITOR_QUERY_ID], testRunId, }), ]); diff --git a/x-pack/plugins/synthetics/server/synthetics_service/formatters/format_configs.test.ts b/x-pack/plugins/synthetics/server/synthetics_service/formatters/format_configs.test.ts index 7bdbcc9e2554d7..84b9063fcc88bf 100644 --- a/x-pack/plugins/synthetics/server/synthetics_service/formatters/format_configs.test.ts +++ b/x-pack/plugins/synthetics/server/synthetics_service/formatters/format_configs.test.ts @@ -205,17 +205,17 @@ describe('formatMonitorConfig', () => { }); describe('formatHeartbeatRequest', () => { - it('uses custom heartbeat id when defined', () => { + it('uses heartbeat id', () => { const monitorId = 'test-monitor-id'; - const customHeartbeatId = 'test-custom-heartbeat-id'; + const heartbeatId = 'test-custom-heartbeat-id'; const actual = formatHeartbeatRequest({ monitor: testBrowserConfig as SyntheticsMonitor, monitorId, - customHeartbeatId, + heartbeatId, }); expect(actual).toEqual({ ...testBrowserConfig, - id: customHeartbeatId, + id: heartbeatId, fields: { config_id: monitorId, 'monitor.project.name': testBrowserConfig.project_id, @@ -232,6 +232,7 @@ describe('formatHeartbeatRequest', () => { const actual = formatHeartbeatRequest({ monitor: testBrowserConfig as SyntheticsMonitor, monitorId, + heartbeatId: monitorId, }); expect(actual).toEqual({ ...testBrowserConfig, @@ -253,6 +254,7 @@ describe('formatHeartbeatRequest', () => { const actual = formatHeartbeatRequest({ monitor, monitorId, + heartbeatId: monitorId, }); expect(actual).toEqual({ @@ -275,6 +277,7 @@ describe('formatHeartbeatRequest', () => { const actual = formatHeartbeatRequest({ monitor, monitorId, + heartbeatId: monitorId, }); expect(actual).toEqual({ @@ -297,6 +300,7 @@ describe('formatHeartbeatRequest', () => { monitor: testBrowserConfig as SyntheticsMonitor, monitorId, runOnce: true, + heartbeatId: monitorId, }); expect(actual).toEqual({ @@ -320,6 +324,7 @@ describe('formatHeartbeatRequest', () => { monitor: testBrowserConfig as SyntheticsMonitor, monitorId, testRunId, + heartbeatId: monitorId, }); expect(actual).toEqual({ diff --git a/x-pack/plugins/synthetics/server/synthetics_service/formatters/format_configs.ts b/x-pack/plugins/synthetics/server/synthetics_service/formatters/format_configs.ts index 320d3c28b48d38..8c81191ee626be 100644 --- a/x-pack/plugins/synthetics/server/synthetics_service/formatters/format_configs.ts +++ b/x-pack/plugins/synthetics/server/synthetics_service/formatters/format_configs.ts @@ -65,20 +65,20 @@ export const formatMonitorConfig = (configKeys: ConfigKey[], config: Partial { const projectId = (monitor as BrowserFields)[ConfigKey.PROJECT_ID]; return { ...monitor, - id: customHeartbeatId || monitorId, + id: heartbeatId, fields: { config_id: monitorId, 'monitor.project.name': projectId || undefined, diff --git a/x-pack/plugins/synthetics/server/synthetics_service/synthetics_monitor/synthetics_monitor_client.ts b/x-pack/plugins/synthetics/server/synthetics_service/synthetics_monitor/synthetics_monitor_client.ts index 8218a6f0b3baf1..e037f3a6ab75dc 100644 --- a/x-pack/plugins/synthetics/server/synthetics_service/synthetics_monitor/synthetics_monitor_client.ts +++ b/x-pack/plugins/synthetics/server/synthetics_service/synthetics_monitor/synthetics_monitor_client.ts @@ -44,7 +44,7 @@ export class SyntheticsMonitorClient { const config = formatHeartbeatRequest({ monitor, monitorId: id, - customHeartbeatId: monitor[ConfigKey.CUSTOM_HEARTBEAT_ID], + heartbeatId: monitor[ConfigKey.MONITOR_QUERY_ID], }); const { privateLocations, publicLocations } = this.parseLocations(config); @@ -96,7 +96,7 @@ export class SyntheticsMonitorClient { const editedConfig = formatHeartbeatRequest({ monitor: editedMonitor.monitor, monitorId: editedMonitor.id, - customHeartbeatId: (editedMonitor.monitor as MonitorFields)[ConfigKey.CUSTOM_HEARTBEAT_ID], + heartbeatId: (editedMonitor.monitor as MonitorFields)[ConfigKey.MONITOR_QUERY_ID], }); const { publicLocations, privateLocations } = this.parseLocations(editedConfig); if (publicLocations.length > 0) { diff --git a/x-pack/plugins/synthetics/server/synthetics_service/synthetics_service.ts b/x-pack/plugins/synthetics/server/synthetics_service/synthetics_service.ts index 4c893d1abd18b4..3136fd6cab07a4 100644 --- a/x-pack/plugins/synthetics/server/synthetics_service/synthetics_service.ts +++ b/x-pack/plugins/synthetics/server/synthetics_service/synthetics_service.ts @@ -458,7 +458,7 @@ export class SyntheticsService { return formatHeartbeatRequest({ monitor: normalizeSecrets(monitor).attributes, monitorId: monitor.id, - customHeartbeatId: attributes[ConfigKey.CUSTOM_HEARTBEAT_ID], + heartbeatId: attributes[ConfigKey.MONITOR_QUERY_ID], }); }) ); diff --git a/x-pack/test/api_integration/apis/synthetics/add_monitor_private_location.ts b/x-pack/test/api_integration/apis/synthetics/add_monitor_private_location.ts index f8131592c399f7..c9b97c96c95858 100644 --- a/x-pack/test/api_integration/apis/synthetics/add_monitor_private_location.ts +++ b/x-pack/test/api_integration/apis/synthetics/add_monitor_private_location.ts @@ -148,7 +148,15 @@ export default function ({ getService }: FtrProviderContext) { .send(httpMonitorJson); expect(apiResponse.body.attributes).eql( - omit({ ...httpMonitorJson, revision: 2 }, secretKeys) + omit( + { + ...httpMonitorJson, + [ConfigKey.MONITOR_QUERY_ID]: apiResponse.body.id, + [ConfigKey.CONFIG_ID]: apiResponse.body.id, + revision: 2, + }, + secretKeys + ) ); }); diff --git a/x-pack/test/api_integration/apis/synthetics/edit_monitor.ts b/x-pack/test/api_integration/apis/synthetics/edit_monitor.ts index 6d9b1db7a753fc..209ba0c4d9a38c 100644 --- a/x-pack/test/api_integration/apis/synthetics/edit_monitor.ts +++ b/x-pack/test/api_integration/apis/synthetics/edit_monitor.ts @@ -99,7 +99,7 @@ export default function ({ getService }: FtrProviderContext) { }; const modifiedMonitor = { - ...newMonitor, + ...savedMonitor, ...updates, [ConfigKey.METADATA]: { ...newMonitor[ConfigKey.METADATA],