mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
[Synthetics] rename files (#187486)
## Summary Renames some files in the synthetics plugin to remove references to Uptime.
This commit is contained in:
parent
3b396850e8
commit
84ca0e85b5
52 changed files with 189 additions and 182 deletions
|
@ -129,12 +129,14 @@ export const TCPAdvancedCodec = t.intersection([
|
|||
export type TCPAdvancedFields = t.TypeOf<typeof TCPAdvancedCodec>;
|
||||
|
||||
// TCPFields
|
||||
// All fields for TCP monitor, excluding sensitive fields
|
||||
export const EncryptedTCPFieldsCodec = t.intersection([
|
||||
TCPSimpleFieldsCodec,
|
||||
TCPAdvancedFieldsCodec,
|
||||
TLSFieldsCodec,
|
||||
]);
|
||||
|
||||
// All fields for TCP monitor, including sensitive fields
|
||||
export const TCPFieldsCodec = t.intersection([
|
||||
EncryptedTCPFieldsCodec,
|
||||
TCPSensitiveAdvancedFieldsCodec,
|
||||
|
@ -218,12 +220,14 @@ export const HTTPAdvancedCodec = t.intersection([
|
|||
]);
|
||||
|
||||
// HTTPFields
|
||||
// All fields for HTTP monitor, excluding sensitive fields
|
||||
export const EncryptedHTTPFieldsCodec = t.intersection([
|
||||
HTTPSimpleFieldsCodec,
|
||||
HTTPAdvancedFieldsCodec,
|
||||
TLSFieldsCodec,
|
||||
]);
|
||||
|
||||
// All fields for HTTP monitor, including sensitive fields
|
||||
export const HTTPFieldsCodec = t.intersection([
|
||||
EncryptedHTTPFieldsCodec,
|
||||
HTTPSensitiveAdvancedFieldsCodec,
|
||||
|
@ -291,12 +295,14 @@ export const BrowserAdvancedFieldsCodec = t.intersection([
|
|||
BrowserSensitiveAdvancedFieldsCodec,
|
||||
]);
|
||||
|
||||
// All fields for Browser monitor, excluding sensitive fields
|
||||
export const EncryptedBrowserFieldsCodec = t.intersection([
|
||||
EncryptedBrowserSimpleFieldsCodec,
|
||||
EncryptedBrowserAdvancedFieldsCodec,
|
||||
TLSFieldsCodec,
|
||||
]);
|
||||
|
||||
// All fields for Browser monitor, including sensitive fields
|
||||
export const BrowserFieldsCodec = t.intersection([
|
||||
BrowserSimpleFieldsCodec,
|
||||
BrowserAdvancedFieldsCodec,
|
||||
|
@ -311,7 +317,7 @@ export const MonitorFieldsCodec = t.intersection([
|
|||
BrowserFieldsCodec,
|
||||
]);
|
||||
|
||||
// Monitor, represents one of (Icmp | Tcp | Http | Browser)
|
||||
// Monitor, represents one of (Icmp | Tcp | Http | Browser) decrypted
|
||||
export const SyntheticsMonitorCodec = t.union([
|
||||
HTTPFieldsCodec,
|
||||
TCPFieldsCodec,
|
||||
|
@ -319,6 +325,7 @@ export const SyntheticsMonitorCodec = t.union([
|
|||
BrowserFieldsCodec,
|
||||
]);
|
||||
|
||||
// Monitor, represents one of (Icmp | Tcp | Http | Browser) encrypted
|
||||
export const EncryptedSyntheticsMonitorCodec = t.union([
|
||||
EncryptedHTTPFieldsCodec,
|
||||
EncryptedTCPFieldsCodec,
|
||||
|
|
|
@ -25,12 +25,9 @@ import {
|
|||
MonitorStatusActionGroup,
|
||||
SYNTHETICS_RULE_TYPES_ALERT_CONTEXT,
|
||||
} from '../../common/constants/synthetics_alerts';
|
||||
import {
|
||||
getUptimeIndexPattern,
|
||||
IndexPatternTitleAndFields,
|
||||
} from '../legacy_uptime/lib/requests/get_index_pattern';
|
||||
import { getUptimeIndexPattern, IndexPatternTitleAndFields } from '../queries/get_index_pattern';
|
||||
import { StatusCheckFilters } from '../../common/runtime_types';
|
||||
import { UptimeEsClient } from '../lib';
|
||||
import { SyntheticsEsClient } from '../lib';
|
||||
import { getMonitorSummary } from './status_rule/message_utils';
|
||||
import {
|
||||
SyntheticsCommonState,
|
||||
|
@ -311,14 +308,14 @@ export const RECOVERED_LABEL = i18n.translate('xpack.synthetics.monitorStatus.re
|
|||
});
|
||||
|
||||
export const formatFilterString = async (
|
||||
uptimeEsClient: UptimeEsClient,
|
||||
syntheticsEsClient: SyntheticsEsClient,
|
||||
filters?: StatusCheckFilters,
|
||||
search?: string
|
||||
) =>
|
||||
await generateFilterDSL(
|
||||
() =>
|
||||
getUptimeIndexPattern({
|
||||
uptimeEsClient,
|
||||
syntheticsEsClient,
|
||||
}),
|
||||
filters,
|
||||
search
|
||||
|
|
|
@ -38,7 +38,7 @@ describe('StatusRuleExecutor', () => {
|
|||
|
||||
const serverMock: SyntheticsServerSetup = {
|
||||
logger,
|
||||
uptimeEsClient: mockEsClient,
|
||||
syntheticsEsClient: mockEsClient,
|
||||
authSavedObjectsClient: soClient,
|
||||
config: {
|
||||
service: {
|
||||
|
|
|
@ -11,7 +11,7 @@ import {
|
|||
} from '@kbn/core-saved-objects-api-server';
|
||||
import { ElasticsearchClient } from '@kbn/core-elasticsearch-server';
|
||||
import { SyntheticsServerSetup } from '../../types';
|
||||
import { UptimeEsClient } from '../../lib';
|
||||
import { SyntheticsEsClient } from '../../lib';
|
||||
import { SYNTHETICS_INDEX_PATTERN } from '../../../common/constants';
|
||||
import {
|
||||
getAllMonitors,
|
||||
|
@ -42,7 +42,7 @@ export interface AlertOverviewStatus
|
|||
export class StatusRuleExecutor {
|
||||
previousStartedAt: Date | null;
|
||||
params: StatusRuleParams;
|
||||
esClient: UptimeEsClient;
|
||||
esClient: SyntheticsEsClient;
|
||||
soClient: SavedObjectsClientContract;
|
||||
server: SyntheticsServerSetup;
|
||||
syntheticsMonitorClient: SyntheticsMonitorClient;
|
||||
|
@ -59,7 +59,7 @@ export class StatusRuleExecutor {
|
|||
this.previousStartedAt = previousStartedAt;
|
||||
this.params = p;
|
||||
this.soClient = soClient;
|
||||
this.esClient = new UptimeEsClient(this.soClient, scopedClient, {
|
||||
this.esClient = new SyntheticsEsClient(this.soClient, scopedClient, {
|
||||
heartbeatIndices: SYNTHETICS_INDEX_PATTERN,
|
||||
});
|
||||
this.server = server;
|
||||
|
|
|
@ -38,7 +38,7 @@ describe('tlsRuleExecutor', () => {
|
|||
|
||||
const serverMock: SyntheticsServerSetup = {
|
||||
logger,
|
||||
uptimeEsClient: mockEsClient,
|
||||
syntheticsEsClient: mockEsClient,
|
||||
authSavedObjectsClient: soClient,
|
||||
config: {
|
||||
service: {
|
||||
|
|
|
@ -31,12 +31,12 @@ import {
|
|||
import { SyntheticsMonitorClient } from '../../synthetics_service/synthetics_monitor/synthetics_monitor_client';
|
||||
import { monitorAttributes } from '../../../common/types/saved_objects';
|
||||
import { AlertConfigKey } from '../../../common/constants/monitor_management';
|
||||
import { UptimeEsClient } from '../../lib';
|
||||
import { SyntheticsEsClient } from '../../lib';
|
||||
|
||||
export class TLSRuleExecutor {
|
||||
previousStartedAt: Date | null;
|
||||
params: TLSParams;
|
||||
esClient: UptimeEsClient;
|
||||
esClient: SyntheticsEsClient;
|
||||
soClient: SavedObjectsClientContract;
|
||||
server: SyntheticsServerSetup;
|
||||
syntheticsMonitorClient: SyntheticsMonitorClient;
|
||||
|
@ -53,7 +53,7 @@ export class TLSRuleExecutor {
|
|||
this.previousStartedAt = previousStartedAt;
|
||||
this.params = p;
|
||||
this.soClient = soClient;
|
||||
this.esClient = new UptimeEsClient(this.soClient, scopedClient, {
|
||||
this.esClient = new SyntheticsEsClient(this.soClient, scopedClient, {
|
||||
heartbeatIndices: SYNTHETICS_INDEX_PATTERN,
|
||||
});
|
||||
this.server = server;
|
||||
|
@ -124,7 +124,7 @@ export class TLSRuleExecutor {
|
|||
}
|
||||
|
||||
const { certs, total }: CertResult = await getSyntheticsCerts({
|
||||
uptimeEsClient: this.esClient,
|
||||
syntheticsEsClient: this.esClient,
|
||||
pageIndex: 0,
|
||||
size: 1000,
|
||||
notValidAfter: `now+${expiryThreshold}d`,
|
||||
|
|
|
@ -11,7 +11,7 @@ import {
|
|||
QueryDslQueryContainer,
|
||||
} from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||
import { SUMMARY_FILTER } from '../../../common/constants/client_defaults';
|
||||
import { UptimeEsClient } from '../../lib';
|
||||
import { SyntheticsEsClient } from '../../lib';
|
||||
import {
|
||||
GetPingsParams,
|
||||
HttpResponseBody,
|
||||
|
@ -37,10 +37,12 @@ type GetParamsWithFields<F> = GetPingsParams & {
|
|||
type GetParamsWithoutFields = GetPingsParams;
|
||||
|
||||
export async function queryPings<F>(
|
||||
params: (GetParamsWithFields<F> | GetParamsWithoutFields) & { uptimeEsClient: UptimeEsClient }
|
||||
params: (GetParamsWithFields<F> | GetParamsWithoutFields) & {
|
||||
syntheticsEsClient: SyntheticsEsClient;
|
||||
}
|
||||
): Promise<PingsResponse | { total: number; pings: F[] }> {
|
||||
const {
|
||||
uptimeEsClient,
|
||||
syntheticsEsClient,
|
||||
dateRange: { from, to },
|
||||
index,
|
||||
monitorId,
|
||||
|
@ -100,7 +102,7 @@ export async function queryPings<F>(
|
|||
body: {
|
||||
hits: { hits, total },
|
||||
},
|
||||
} = await uptimeEsClient.search({ body: searchBody });
|
||||
} = await syntheticsEsClient.search({ body: searchBody });
|
||||
|
||||
return {
|
||||
total: total.value,
|
||||
|
@ -112,7 +114,7 @@ export async function queryPings<F>(
|
|||
body: {
|
||||
hits: { hits, total },
|
||||
},
|
||||
} = await uptimeEsClient.search({ body: searchBody });
|
||||
} = await syntheticsEsClient.search({ body: searchBody });
|
||||
|
||||
const pings: Ping[] = hits.map((doc: any) => {
|
||||
const { _id, _source } = doc;
|
||||
|
|
|
@ -5,17 +5,17 @@
|
|||
* 2.0.
|
||||
*/
|
||||
|
||||
import { UptimeEsClient } from './lib';
|
||||
import { SyntheticsEsClient } from './lib';
|
||||
import { savedObjectsClientMock, uiSettingsServiceMock } from '@kbn/core/server/mocks';
|
||||
import { elasticsearchClientMock } from '@kbn/core-elasticsearch-client-server-mocks';
|
||||
|
||||
describe('UptimeEsClient', () => {
|
||||
let uptimeEsClient: UptimeEsClient;
|
||||
describe('SyntheticsEsClient', () => {
|
||||
let syntheticsEsClient: SyntheticsEsClient;
|
||||
const savedObjectsClient = savedObjectsClientMock.create();
|
||||
const esClient = elasticsearchClientMock.createClusterClient().asInternalUser;
|
||||
|
||||
beforeEach(() => {
|
||||
uptimeEsClient = new UptimeEsClient(savedObjectsClient, esClient);
|
||||
syntheticsEsClient = new SyntheticsEsClient(savedObjectsClient, esClient);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
|
@ -32,7 +32,7 @@ describe('UptimeEsClient', () => {
|
|||
},
|
||||
};
|
||||
|
||||
const result = await uptimeEsClient.search({
|
||||
const result = await syntheticsEsClient.search({
|
||||
body: {
|
||||
query: {
|
||||
match_all: {},
|
||||
|
@ -69,7 +69,7 @@ describe('UptimeEsClient', () => {
|
|||
const mockError = new Error('Search error');
|
||||
esClient.search.mockRejectedValueOnce(mockError);
|
||||
|
||||
await expect(uptimeEsClient.search(mockSearchParams)).rejects.toThrow(mockError);
|
||||
await expect(syntheticsEsClient.search(mockSearchParams)).rejects.toThrow(mockError);
|
||||
expect(esClient.search).toHaveBeenCalledWith(
|
||||
{
|
||||
index: 'synthetics-*',
|
||||
|
@ -86,7 +86,7 @@ describe('UptimeEsClient', () => {
|
|||
index: 'example',
|
||||
};
|
||||
|
||||
const result = await uptimeEsClient.count(mockCountParams);
|
||||
const result = await syntheticsEsClient.count(mockCountParams);
|
||||
|
||||
expect(esClient.count).toHaveBeenCalledWith(mockCountParams, { meta: true });
|
||||
expect(result).toEqual({
|
||||
|
@ -110,30 +110,30 @@ describe('UptimeEsClient', () => {
|
|||
const mockError = new Error('Count error');
|
||||
esClient.count.mockRejectedValueOnce(mockError);
|
||||
|
||||
await expect(uptimeEsClient.count(mockCountParams)).rejects.toThrow(mockError);
|
||||
await expect(syntheticsEsClient.count(mockCountParams)).rejects.toThrow(mockError);
|
||||
expect(esClient.count).toHaveBeenCalledWith(mockCountParams, { meta: true });
|
||||
});
|
||||
});
|
||||
|
||||
describe('getInspectEnabled', () => {
|
||||
it('should return false if uiSettings is not available', async () => {
|
||||
const result = await uptimeEsClient.getInspectEnabled();
|
||||
const result = await syntheticsEsClient.getInspectEnabled();
|
||||
|
||||
expect(result).toBe(false);
|
||||
});
|
||||
|
||||
it('should return the value from uiSettings if available', async () => {
|
||||
const mockUiSettings = uiSettingsServiceMock.createClient();
|
||||
uptimeEsClient.uiSettings = {
|
||||
syntheticsEsClient.uiSettings = {
|
||||
client: mockUiSettings,
|
||||
} as any;
|
||||
|
||||
// @ts-expect-error
|
||||
mockUiSettings.get.mockReturnValue(true);
|
||||
|
||||
await uptimeEsClient.getInspectEnabled();
|
||||
await syntheticsEsClient.getInspectEnabled();
|
||||
|
||||
expect(uptimeEsClient.isInspectorEnabled).toBe(true);
|
||||
expect(syntheticsEsClient.isInspectorEnabled).toBe(true);
|
||||
expect(mockUiSettings.get).toHaveBeenCalledWith('observability:enableInspectEsQueries');
|
||||
});
|
||||
});
|
||||
|
|
|
@ -36,7 +36,7 @@ export interface CountResponse {
|
|||
indices: string;
|
||||
}
|
||||
|
||||
export class UptimeEsClient {
|
||||
export class SyntheticsEsClient {
|
||||
isDev: boolean;
|
||||
request?: KibanaRequest;
|
||||
baseESClient: ElasticsearchClient;
|
||||
|
|
|
@ -11,10 +11,10 @@ import {
|
|||
getCertsRequestBody,
|
||||
processCertsResult,
|
||||
} from '../../common/requests/get_certs_request_body';
|
||||
import type { UptimeEsClient } from '../lib';
|
||||
import type { SyntheticsEsClient } from '../lib';
|
||||
|
||||
export const getSyntheticsCerts = async (
|
||||
requestParams: GetCertsParams & { uptimeEsClient: UptimeEsClient }
|
||||
requestParams: GetCertsParams & { syntheticsEsClient: SyntheticsEsClient }
|
||||
): Promise<CertResult> => {
|
||||
const result = await getCertsResults(requestParams);
|
||||
|
||||
|
@ -24,15 +24,15 @@ export const getSyntheticsCerts = async (
|
|||
export type CertificatesResults = PromiseType<ReturnType<typeof getCertsResults>>;
|
||||
|
||||
const getCertsResults = async (
|
||||
requestParams: GetCertsParams & { uptimeEsClient: UptimeEsClient }
|
||||
requestParams: GetCertsParams & { syntheticsEsClient: SyntheticsEsClient }
|
||||
) => {
|
||||
const { uptimeEsClient } = requestParams;
|
||||
const { syntheticsEsClient } = requestParams;
|
||||
|
||||
const searchBody = getCertsRequestBody(requestParams);
|
||||
|
||||
const request = { body: searchBody };
|
||||
|
||||
const { body: result } = await uptimeEsClient.search<Ping, typeof request>({
|
||||
const { body: result } = await syntheticsEsClient.search<Ping, typeof request>({
|
||||
body: searchBody,
|
||||
});
|
||||
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
*/
|
||||
|
||||
import { FieldDescriptor, IndexPatternsFetcher } from '@kbn/data-plugin/server';
|
||||
import { SYNTHETICS_INDEX_PATTERN } from '../../../../common/constants';
|
||||
import { UptimeEsClient } from '../../../lib';
|
||||
import { SYNTHETICS_INDEX_PATTERN } from '../../common/constants';
|
||||
import { SyntheticsEsClient } from '../lib';
|
||||
|
||||
export interface IndexPatternTitleAndFields {
|
||||
title: string;
|
||||
|
@ -15,11 +15,11 @@ export interface IndexPatternTitleAndFields {
|
|||
}
|
||||
|
||||
export const getUptimeIndexPattern = async ({
|
||||
uptimeEsClient,
|
||||
syntheticsEsClient,
|
||||
}: {
|
||||
uptimeEsClient: UptimeEsClient;
|
||||
syntheticsEsClient: SyntheticsEsClient;
|
||||
}): Promise<IndexPatternTitleAndFields | undefined> => {
|
||||
const indexPatternsFetcher = new IndexPatternsFetcher(uptimeEsClient.baseESClient);
|
||||
const indexPatternsFetcher = new IndexPatternsFetcher(syntheticsEsClient.baseESClient);
|
||||
|
||||
try {
|
||||
const { fields } = await indexPatternsFetcher.getFieldsForWildcard({
|
|
@ -6,7 +6,7 @@
|
|||
*/
|
||||
|
||||
import { QueryDslQueryContainer } from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||
import { createEsParams, UptimeEsClient } from '../lib';
|
||||
import { createEsParams, SyntheticsEsClient } from '../lib';
|
||||
import { JourneyStep, Ping, SyntheticsJourneyApiResponse } from '../../common/runtime_types';
|
||||
|
||||
export interface GetJourneyDetails {
|
||||
|
@ -16,10 +16,10 @@ export interface GetJourneyDetails {
|
|||
type DocumentSource = (Ping & { '@timestamp': string; synthetics: { type: string } }) | JourneyStep;
|
||||
|
||||
export const getJourneyDetails = async ({
|
||||
uptimeEsClient,
|
||||
syntheticsEsClient,
|
||||
checkGroup,
|
||||
}: GetJourneyDetails & {
|
||||
uptimeEsClient: UptimeEsClient;
|
||||
syntheticsEsClient: SyntheticsEsClient;
|
||||
}): Promise<SyntheticsJourneyApiResponse['details']> => {
|
||||
const params = createEsParams({
|
||||
body: {
|
||||
|
@ -43,7 +43,7 @@ export const getJourneyDetails = async ({
|
|||
},
|
||||
});
|
||||
|
||||
const { body: thisJourney } = await uptimeEsClient.search<DocumentSource, typeof params>(
|
||||
const { body: thisJourney } = await syntheticsEsClient.search<DocumentSource, typeof params>(
|
||||
params,
|
||||
'getJourneyDetailsCurrentJourney'
|
||||
);
|
||||
|
@ -143,11 +143,11 @@ export const getJourneyDetails = async ({
|
|||
});
|
||||
|
||||
const [previousJourneyPromise, nextJourneyPromise] = await Promise.all([
|
||||
uptimeEsClient.search<JourneyStep, typeof previousParams>(
|
||||
syntheticsEsClient.search<JourneyStep, typeof previousParams>(
|
||||
previousParams,
|
||||
'getJourneyDetailsPreviousJourney'
|
||||
),
|
||||
uptimeEsClient.search<JourneyStep, typeof nextParams>(
|
||||
syntheticsEsClient.search<JourneyStep, typeof nextParams>(
|
||||
nextParams,
|
||||
'getJourneyDetailsNextJourney'
|
||||
),
|
||||
|
|
|
@ -48,7 +48,7 @@ describe('getJourneyFailedSteps', () => {
|
|||
it('formats failed steps', async () => {
|
||||
expect(
|
||||
await getJourneyFailedSteps({
|
||||
uptimeEsClient: mockSearchResult(mockData),
|
||||
syntheticsEsClient: mockSearchResult(mockData),
|
||||
checkGroups: ['chg1', 'chg2'],
|
||||
})
|
||||
).toMatchInlineSnapshot(`
|
|
@ -6,19 +6,19 @@
|
|||
*/
|
||||
|
||||
import { QueryDslQueryContainer } from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||
import { UptimeEsClient } from '../../../lib';
|
||||
import { asMutableArray } from '../../../../common/utils/as_mutable_array';
|
||||
import { JourneyStep } from '../../../../common/runtime_types/ping/synthetics';
|
||||
import { SyntheticsEsClient } from '../lib';
|
||||
import { asMutableArray } from '../../common/utils/as_mutable_array';
|
||||
import { JourneyStep } from '../../common/runtime_types/ping/synthetics';
|
||||
|
||||
export interface GetJourneyStepsParams {
|
||||
checkGroups: string[];
|
||||
}
|
||||
|
||||
export const getJourneyFailedSteps = async ({
|
||||
uptimeEsClient,
|
||||
syntheticsEsClient,
|
||||
checkGroups,
|
||||
}: GetJourneyStepsParams & {
|
||||
uptimeEsClient: UptimeEsClient;
|
||||
syntheticsEsClient: SyntheticsEsClient;
|
||||
}): Promise<JourneyStep[]> => {
|
||||
const params = {
|
||||
query: {
|
||||
|
@ -52,7 +52,7 @@ export const getJourneyFailedSteps = async ({
|
|||
size: 500,
|
||||
};
|
||||
|
||||
const { body: result } = await uptimeEsClient.search({ body: params });
|
||||
const { body: result } = await syntheticsEsClient.search({ body: params });
|
||||
|
||||
return result.hits.hits.map(({ _id, _source }) => {
|
||||
const step = Object.assign({ _id }, _source) as JourneyStep;
|
|
@ -26,7 +26,7 @@ describe('getJourneyScreenshot', () => {
|
|||
};
|
||||
expect(
|
||||
await getJourneyScreenshot({
|
||||
uptimeEsClient: mockSearchResult([], {
|
||||
syntheticsEsClient: mockSearchResult([], {
|
||||
step: {
|
||||
image: {
|
||||
hits: {
|
||||
|
@ -93,7 +93,7 @@ describe('getJourneyScreenshot', () => {
|
|||
};
|
||||
expect(
|
||||
await getJourneyScreenshot({
|
||||
uptimeEsClient: mockSearchResult([], {
|
||||
syntheticsEsClient: mockSearchResult([], {
|
||||
step: { image: { hits: { hits: [screenshotRefResult], total: 1 } } },
|
||||
}),
|
||||
checkGroup: 'checkGroup',
|
|
@ -6,8 +6,8 @@
|
|||
*/
|
||||
|
||||
import { QueryDslQueryContainer } from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||
import { UptimeEsClient } from '../../../lib';
|
||||
import { RefResult, FullScreenshot } from '../../../../common/runtime_types/ping/synthetics';
|
||||
import { SyntheticsEsClient } from '../lib';
|
||||
import { RefResult, FullScreenshot } from '../../common/runtime_types/ping/synthetics';
|
||||
|
||||
interface ResultType {
|
||||
_source: RefResult | FullScreenshot;
|
||||
|
@ -20,12 +20,12 @@ export type ScreenshotReturnTypesUnion =
|
|||
export const getJourneyScreenshot = async ({
|
||||
checkGroup,
|
||||
stepIndex,
|
||||
uptimeEsClient,
|
||||
syntheticsEsClient,
|
||||
}: {
|
||||
checkGroup: string;
|
||||
stepIndex: number;
|
||||
} & {
|
||||
uptimeEsClient: UptimeEsClient;
|
||||
syntheticsEsClient: SyntheticsEsClient;
|
||||
}): Promise<ScreenshotReturnTypesUnion> => {
|
||||
const body = {
|
||||
track_total_hits: true,
|
||||
|
@ -64,7 +64,7 @@ export const getJourneyScreenshot = async ({
|
|||
},
|
||||
};
|
||||
|
||||
const result = await uptimeEsClient.search({ body });
|
||||
const result = await syntheticsEsClient.search({ body });
|
||||
|
||||
const screenshotsOrRefs =
|
||||
(result.body.aggregations?.step.image.hits.hits as ResultType[]) ?? null;
|
|
@ -12,7 +12,7 @@ describe('getJourneyScreenshotBlocks', () => {
|
|||
it('returns formatted blocks', async () => {
|
||||
expect(
|
||||
await getJourneyScreenshotBlocks({
|
||||
uptimeEsClient: mockSearchResult([
|
||||
syntheticsEsClient: mockSearchResult([
|
||||
{
|
||||
_id: 'hash1',
|
||||
_source: {
|
|
@ -5,8 +5,8 @@
|
|||
* 2.0.
|
||||
*/
|
||||
|
||||
import { UptimeEsClient } from '../../../lib';
|
||||
import { ScreenshotBlockDoc } from '../../../../common/runtime_types';
|
||||
import { SyntheticsEsClient } from '../lib';
|
||||
import { ScreenshotBlockDoc } from '../../common/runtime_types';
|
||||
|
||||
interface ScreenshotBlockResultType {
|
||||
_id: string;
|
||||
|
@ -20,11 +20,11 @@ interface ScreenshotBlockResultType {
|
|||
|
||||
export const getJourneyScreenshotBlocks = async ({
|
||||
blockIds,
|
||||
uptimeEsClient,
|
||||
syntheticsEsClient,
|
||||
}: {
|
||||
blockIds: string[];
|
||||
} & {
|
||||
uptimeEsClient: UptimeEsClient;
|
||||
syntheticsEsClient: SyntheticsEsClient;
|
||||
}): Promise<ScreenshotBlockDoc[]> => {
|
||||
const body = {
|
||||
query: {
|
||||
|
@ -41,7 +41,7 @@ export const getJourneyScreenshotBlocks = async ({
|
|||
size: 1000,
|
||||
};
|
||||
|
||||
const fetchScreenshotBlocksResult = await uptimeEsClient.search({ body });
|
||||
const fetchScreenshotBlocksResult = await syntheticsEsClient.search({ body });
|
||||
|
||||
return (fetchScreenshotBlocksResult.body.hits.hits as ScreenshotBlockResultType[]).map(
|
||||
({ _id, _source }) => ({
|
|
@ -5,7 +5,7 @@
|
|||
* 2.0.
|
||||
*/
|
||||
|
||||
import { JourneyStep } from '../../../../common/runtime_types/ping/synthetics';
|
||||
import { JourneyStep } from '../../common/runtime_types/ping/synthetics';
|
||||
import { getJourneySteps } from './get_journey_steps';
|
||||
import { getUptimeESMockClient } from './test_helpers';
|
||||
|
||||
|
@ -76,11 +76,11 @@ describe('getJourneySteps request module', () => {
|
|||
});
|
||||
|
||||
it('formats ES result', async () => {
|
||||
const { esClient: mockEsClient, uptimeEsClient } = getUptimeESMockClient();
|
||||
const { esClient: mockEsClient, syntheticsEsClient } = getUptimeESMockClient();
|
||||
|
||||
mockEsClient.search.mockResolvedValueOnce(data);
|
||||
const result: JourneyStep[] = await getJourneySteps({
|
||||
uptimeEsClient,
|
||||
syntheticsEsClient,
|
||||
checkGroup: '2bf952dc-64b5-11eb-8b3b-42010a84000d',
|
||||
});
|
||||
expect(mockEsClient.search).toHaveBeenCalledTimes(1);
|
||||
|
@ -138,14 +138,14 @@ describe('getJourneySteps request module', () => {
|
|||
});
|
||||
|
||||
it('notes screenshot exists when a document of type step/screenshot is included', async () => {
|
||||
const { esClient: mockEsClient, uptimeEsClient } = getUptimeESMockClient();
|
||||
const { esClient: mockEsClient, syntheticsEsClient } = getUptimeESMockClient();
|
||||
|
||||
data.body.hits.hits[0]._source.synthetics.type = 'step/screenshot';
|
||||
data.body.hits.hits[0]._source.synthetics.step.index = 2;
|
||||
mockEsClient.search.mockResolvedValueOnce(data);
|
||||
|
||||
const result: JourneyStep[] = await getJourneySteps({
|
||||
uptimeEsClient,
|
||||
syntheticsEsClient,
|
||||
checkGroup: '2bf952dc-64b5-11eb-8b3b-42010a84000d',
|
||||
});
|
||||
|
|
@ -6,9 +6,9 @@
|
|||
*/
|
||||
|
||||
import { QueryDslQueryContainer } from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||
import { UptimeEsClient } from '../../../lib';
|
||||
import { asMutableArray } from '../../../../common/utils/as_mutable_array';
|
||||
import { JourneyStep } from '../../../../common/runtime_types/ping/synthetics';
|
||||
import { SyntheticsEsClient } from '../lib';
|
||||
import { asMutableArray } from '../../common/utils/as_mutable_array';
|
||||
import { JourneyStep } from '../../common/runtime_types/ping/synthetics';
|
||||
|
||||
export interface GetJourneyStepsParams {
|
||||
checkGroup: string;
|
||||
|
@ -17,10 +17,10 @@ export interface GetJourneyStepsParams {
|
|||
type ResultType = JourneyStep & { '@timestamp': string };
|
||||
|
||||
export const getJourneySteps = async ({
|
||||
uptimeEsClient,
|
||||
syntheticsEsClient,
|
||||
checkGroup,
|
||||
}: GetJourneyStepsParams & {
|
||||
uptimeEsClient: UptimeEsClient;
|
||||
syntheticsEsClient: SyntheticsEsClient;
|
||||
}): Promise<JourneyStep[]> => {
|
||||
const params = {
|
||||
query: {
|
||||
|
@ -54,7 +54,7 @@ export const getJourneySteps = async ({
|
|||
},
|
||||
size: 500,
|
||||
};
|
||||
const { body: result } = await uptimeEsClient.search({ body: params }, 'getJourneySteps');
|
||||
const { body: result } = await syntheticsEsClient.search({ body: params }, 'getJourneySteps');
|
||||
|
||||
const steps = result.hits.hits.map(
|
||||
({ _id, _source }) => Object.assign({ _id }, _source) as ResultType
|
|
@ -6,8 +6,8 @@
|
|||
*/
|
||||
|
||||
import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||
import { UptimeEsClient } from '../../../lib';
|
||||
import { Ping } from '../../../../common/runtime_types/ping';
|
||||
import { SyntheticsEsClient } from '../lib';
|
||||
import { Ping } from '../../common/runtime_types/ping';
|
||||
|
||||
export interface GetStepScreenshotParams {
|
||||
monitorId: string;
|
||||
|
@ -81,12 +81,12 @@ export const getLastSuccessfulStepParams = ({
|
|||
};
|
||||
|
||||
export const getLastSuccessfulCheck = async ({
|
||||
uptimeEsClient,
|
||||
syntheticsEsClient,
|
||||
monitorId,
|
||||
timestamp,
|
||||
location,
|
||||
}: GetStepScreenshotParams & {
|
||||
uptimeEsClient: UptimeEsClient;
|
||||
syntheticsEsClient: SyntheticsEsClient;
|
||||
}): Promise<Ping | null> => {
|
||||
const lastSuccessCheckParams = getLastSuccessfulStepParams({
|
||||
monitorId,
|
||||
|
@ -94,7 +94,7 @@ export const getLastSuccessfulCheck = async ({
|
|||
location,
|
||||
});
|
||||
|
||||
const { body: result } = await uptimeEsClient.search({ body: lastSuccessCheckParams });
|
||||
const { body: result } = await syntheticsEsClient.search({ body: lastSuccessCheckParams });
|
||||
|
||||
if (result.hits.total.value < 1) {
|
||||
return null;
|
|
@ -7,13 +7,13 @@
|
|||
|
||||
import { SavedObjectsClientContract } from '@kbn/core/server';
|
||||
import { EncryptedSavedObjectsClient } from '@kbn/encrypted-saved-objects-plugin/server';
|
||||
import { syntheticsMonitorType } from '../../../../common/types/saved_objects';
|
||||
import { syntheticsMonitorType } from '../../common/types/saved_objects';
|
||||
import {
|
||||
SyntheticsMonitorWithSecretsAttributes,
|
||||
EncryptedSyntheticsMonitorAttributes,
|
||||
SyntheticsMonitor,
|
||||
} from '../../../../common/runtime_types';
|
||||
import { normalizeSecrets } from '../../../synthetics_service/utils/secrets';
|
||||
} from '../../common/runtime_types';
|
||||
import { normalizeSecrets } from '../synthetics_service/utils/secrets';
|
||||
|
||||
export const getSyntheticsMonitor = async ({
|
||||
monitorId,
|
|
@ -169,7 +169,7 @@ describe('getNetworkEvents', () => {
|
|||
});
|
||||
|
||||
it('Uses the correct query', async () => {
|
||||
const { uptimeEsClient, esClient } = getUptimeESMockClient();
|
||||
const { syntheticsEsClient, esClient } = getUptimeESMockClient();
|
||||
|
||||
esClient.search.mockResponseOnce({
|
||||
hits: {
|
||||
|
@ -179,7 +179,7 @@ describe('getNetworkEvents', () => {
|
|||
} as any);
|
||||
|
||||
await getNetworkEvents({
|
||||
uptimeEsClient,
|
||||
syntheticsEsClient,
|
||||
checkGroup: 'my-fake-group',
|
||||
stepIndex: '1',
|
||||
});
|
||||
|
@ -224,7 +224,7 @@ describe('getNetworkEvents', () => {
|
|||
});
|
||||
|
||||
it('Returns the correct result', async () => {
|
||||
const { esClient, uptimeEsClient } = getUptimeESMockClient();
|
||||
const { esClient, syntheticsEsClient } = getUptimeESMockClient();
|
||||
|
||||
esClient.search.mockResponseOnce({
|
||||
hits: {
|
||||
|
@ -234,7 +234,7 @@ describe('getNetworkEvents', () => {
|
|||
} as any);
|
||||
|
||||
const result = await getNetworkEvents({
|
||||
uptimeEsClient,
|
||||
syntheticsEsClient,
|
||||
checkGroup: 'my-fake-group',
|
||||
stepIndex: '1',
|
||||
});
|
|
@ -6,8 +6,8 @@
|
|||
*/
|
||||
|
||||
import { QueryDslQueryContainer } from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||
import { UptimeEsClient } from '../../../lib';
|
||||
import { NetworkEvent } from '../../../../common/runtime_types';
|
||||
import { SyntheticsEsClient } from '../lib';
|
||||
import { NetworkEvent } from '../../common/runtime_types';
|
||||
|
||||
export interface GetNetworkEventsParams {
|
||||
checkGroup: string;
|
||||
|
@ -19,11 +19,11 @@ export const secondsToMillis = (seconds: number) =>
|
|||
seconds === -1 ? -1 : seconds * 1000;
|
||||
|
||||
export const getNetworkEvents = async ({
|
||||
uptimeEsClient,
|
||||
syntheticsEsClient,
|
||||
checkGroup,
|
||||
stepIndex,
|
||||
}: GetNetworkEventsParams & {
|
||||
uptimeEsClient: UptimeEsClient;
|
||||
syntheticsEsClient: SyntheticsEsClient;
|
||||
}): Promise<{
|
||||
events: NetworkEvent[];
|
||||
total: number;
|
||||
|
@ -47,7 +47,7 @@ export const getNetworkEvents = async ({
|
|||
size: 1000,
|
||||
};
|
||||
|
||||
const { body: result } = await uptimeEsClient.search({ body: params });
|
||||
const { body: result } = await syntheticsEsClient.search({ body: params });
|
||||
let isWaterfallSupported = false;
|
||||
let hasNavigationRequest = false;
|
||||
|
|
@ -5,10 +5,7 @@
|
|||
* 2.0.
|
||||
*/
|
||||
import { IKibanaResponse } from '@kbn/core-http-server';
|
||||
import {
|
||||
getJourneyScreenshot,
|
||||
ScreenshotReturnTypesUnion,
|
||||
} from '../legacy_uptime/lib/requests/get_journey_screenshot';
|
||||
import { getJourneyScreenshot, ScreenshotReturnTypesUnion } from './get_journey_screenshot';
|
||||
import { isRefResult, RefResult } from '../../common/runtime_types';
|
||||
import { RouteContext, UptimeRouteContext } from '../routes/types';
|
||||
|
||||
|
@ -27,12 +24,12 @@ function getSharedHeaders(stepName: string, totalSteps: number) {
|
|||
export const journeyScreenshotHandler = async ({
|
||||
response,
|
||||
request,
|
||||
uptimeEsClient,
|
||||
syntheticsEsClient,
|
||||
}: RouteContext | UptimeRouteContext): Promise<IKibanaResponse<ClientContract>> => {
|
||||
const { checkGroup, stepIndex } = request.params;
|
||||
|
||||
const result: ScreenshotReturnTypesUnion | null = await getJourneyScreenshot({
|
||||
uptimeEsClient,
|
||||
syntheticsEsClient,
|
||||
checkGroup,
|
||||
stepIndex,
|
||||
});
|
||||
|
|
|
@ -16,7 +16,7 @@ import {
|
|||
OverviewStatus,
|
||||
OverviewStatusMetaData,
|
||||
} from '../../common/runtime_types';
|
||||
import { createEsParams, UptimeEsClient } from '../lib';
|
||||
import { createEsParams, SyntheticsEsClient } from '../lib';
|
||||
|
||||
const DEFAULT_MAX_ES_BUCKET_SIZE = 10000;
|
||||
|
||||
|
@ -34,7 +34,7 @@ const fields = [
|
|||
];
|
||||
|
||||
export async function queryMonitorStatus(
|
||||
esClient: UptimeEsClient,
|
||||
esClient: SyntheticsEsClient,
|
||||
monitorLocationIds: string[],
|
||||
range: { from: string; to: string },
|
||||
monitorQueryIds: string[],
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
import { AggregationsAggregate } from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||
import type { ElasticsearchClientMock } from '@kbn/core-elasticsearch-client-server-mocks';
|
||||
import { elasticsearchServiceMock, savedObjectsClientMock } from '@kbn/core/server/mocks';
|
||||
import { UptimeEsClient } from '../../../lib';
|
||||
import { SyntheticsEsClient } from '../lib';
|
||||
|
||||
export interface MultiPageCriteria<K, T> {
|
||||
after_key?: K;
|
||||
|
@ -58,7 +58,7 @@ export const setupMockEsCompositeQuery = <K, C, I>(
|
|||
|
||||
interface UptimeEsMockClient {
|
||||
esClient: ElasticsearchClientMock;
|
||||
uptimeEsClient: UptimeEsClient;
|
||||
syntheticsEsClient: SyntheticsEsClient;
|
||||
}
|
||||
|
||||
export const getUptimeESMockClient = (
|
||||
|
@ -70,15 +70,15 @@ export const getUptimeESMockClient = (
|
|||
|
||||
return {
|
||||
esClient: esClientMock || esClient,
|
||||
uptimeEsClient: new UptimeEsClient(savedObjectsClient, esClientMock || esClient),
|
||||
syntheticsEsClient: new SyntheticsEsClient(savedObjectsClient, esClientMock || esClient),
|
||||
};
|
||||
};
|
||||
|
||||
export function mockSearchResult(
|
||||
data: unknown,
|
||||
aggregations: Record<string, AggregationsAggregate> = {}
|
||||
): UptimeEsClient {
|
||||
const { esClient: mockEsClient, uptimeEsClient } = getUptimeESMockClient();
|
||||
): SyntheticsEsClient {
|
||||
const { esClient: mockEsClient, syntheticsEsClient } = getUptimeESMockClient();
|
||||
|
||||
mockEsClient.search.mockResponse({
|
||||
took: 18,
|
||||
|
@ -100,5 +100,5 @@ export function mockSearchResult(
|
|||
aggregations,
|
||||
});
|
||||
|
||||
return uptimeEsClient;
|
||||
return syntheticsEsClient;
|
||||
}
|
|
@ -36,7 +36,7 @@ export const getSyntheticsCertsRoute: SyntheticsRestApiRouteFactory<
|
|||
},
|
||||
handler: async ({
|
||||
request,
|
||||
uptimeEsClient,
|
||||
syntheticsEsClient,
|
||||
savedObjectsClient,
|
||||
server,
|
||||
syntheticsMonitorClient,
|
||||
|
@ -66,7 +66,7 @@ export const getSyntheticsCertsRoute: SyntheticsRestApiRouteFactory<
|
|||
|
||||
const data = await getSyntheticsCerts({
|
||||
...queryParams,
|
||||
uptimeEsClient,
|
||||
syntheticsEsClient,
|
||||
monitorIds: enabledMonitorQueryIds,
|
||||
});
|
||||
return { data };
|
||||
|
|
|
@ -16,12 +16,12 @@ export const deletePackagePolicyRoute: SyntheticsRestApiRouteFactory = () => ({
|
|||
packagePolicyId: schema.string({ minLength: 1, maxLength: 1024 }),
|
||||
}),
|
||||
},
|
||||
handler: async ({ request, savedObjectsClient, server, uptimeEsClient }): Promise<any> => {
|
||||
handler: async ({ request, savedObjectsClient, server, syntheticsEsClient }): Promise<any> => {
|
||||
const { packagePolicyId } = request.params;
|
||||
|
||||
const response = await server.fleet.packagePolicyService.delete(
|
||||
savedObjectsClient,
|
||||
uptimeEsClient.baseESClient,
|
||||
syntheticsEsClient.baseESClient,
|
||||
[packagePolicyId],
|
||||
{
|
||||
force: true,
|
||||
|
|
|
@ -27,7 +27,7 @@ describe('syncEditedMonitor', () => {
|
|||
const logger = loggerMock.create();
|
||||
|
||||
const serverMock: SyntheticsServerSetup = {
|
||||
uptimeEsClient: { search: jest.fn() },
|
||||
syntheticsEsClient: { search: jest.fn() },
|
||||
stackVersion: null,
|
||||
authSavedObjectsClient: {
|
||||
bulkUpdate: jest.fn(),
|
||||
|
|
|
@ -19,7 +19,7 @@ import { SYNTHETICS_API_URLS } from '../../../common/constants';
|
|||
import { getMonitorNotFoundResponse } from '../synthetics_service/service_errors';
|
||||
import { getMonitorFilters, MonitorsQuery, QuerySchema, SEARCH_FIELDS } from '../common';
|
||||
import { mapSavedObjectToMonitor } from './helper';
|
||||
import { getSyntheticsMonitor } from '../../legacy_uptime/lib/requests/get_monitor';
|
||||
import { getSyntheticsMonitor } from '../../queries/get_monitor';
|
||||
|
||||
export const getSyntheticsMonitorRoute: SyntheticsRestApiRouteFactory = () => ({
|
||||
method: 'GET',
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
*/
|
||||
|
||||
import { schema } from '@kbn/config-schema';
|
||||
import { getNetworkEvents } from '../../legacy_uptime/lib/requests/get_network_events';
|
||||
import { getNetworkEvents } from '../../queries/get_network_events';
|
||||
import { SyntheticsRestApiRouteFactory } from '../types';
|
||||
import { SYNTHETICS_API_URLS } from '../../../common/constants';
|
||||
|
||||
|
@ -19,11 +19,11 @@ export const createNetworkEventsRoute: SyntheticsRestApiRouteFactory = () => ({
|
|||
stepIndex: schema.number(),
|
||||
}),
|
||||
},
|
||||
handler: async ({ uptimeEsClient, request }): Promise<any> => {
|
||||
handler: async ({ syntheticsEsClient, request }): Promise<any> => {
|
||||
const { checkGroup, stepIndex } = request.query;
|
||||
|
||||
return await getNetworkEvents({
|
||||
uptimeEsClient,
|
||||
syntheticsEsClient,
|
||||
checkGroup,
|
||||
stepIndex,
|
||||
});
|
||||
|
|
|
@ -13,7 +13,7 @@ import times from 'lodash/times';
|
|||
import * as monitorsFns from '../../saved_objects/synthetics_monitor/get_all_monitors';
|
||||
import { EncryptedSyntheticsMonitorAttributes } from '../../../common/runtime_types';
|
||||
import { RouteContext } from '../types';
|
||||
import { getUptimeESMockClient } from '../../legacy_uptime/lib/requests/test_helpers';
|
||||
import { getUptimeESMockClient } from '../../queries/test_helpers';
|
||||
|
||||
import * as commonLibs from '../common';
|
||||
import { SyntheticsServerSetup } from '../../types';
|
||||
|
@ -107,7 +107,7 @@ describe('current status route', () => {
|
|||
|
||||
describe('queryMonitorStatus', () => {
|
||||
it('parses expected agg fields', async () => {
|
||||
const { esClient, uptimeEsClient } = getUptimeESMockClient();
|
||||
const { esClient, syntheticsEsClient } = getUptimeESMockClient();
|
||||
esClient.search.mockResponseOnce(
|
||||
getEsResponse([
|
||||
{
|
||||
|
@ -212,7 +212,7 @@ describe('current status route', () => {
|
|||
);
|
||||
expect(
|
||||
await queryMonitorStatus(
|
||||
uptimeEsClient,
|
||||
syntheticsEsClient,
|
||||
['Europe - Germany', 'Asia/Pacific - Japan'],
|
||||
{ from: 'now-1d', to: 'now' },
|
||||
['id1', 'id2'],
|
||||
|
@ -260,7 +260,7 @@ describe('current status route', () => {
|
|||
});
|
||||
|
||||
it('handles limits with multiple requests', async () => {
|
||||
const { esClient, uptimeEsClient } = getUptimeESMockClient();
|
||||
const { esClient, syntheticsEsClient } = getUptimeESMockClient();
|
||||
esClient.search.mockResponseOnce(
|
||||
getEsResponse([
|
||||
{
|
||||
|
@ -377,7 +377,7 @@ describe('current status route', () => {
|
|||
];
|
||||
expect(
|
||||
await queryMonitorStatus(
|
||||
uptimeEsClient,
|
||||
syntheticsEsClient,
|
||||
[...concernedLocations, ...times(9997).map((n) => 'Europe - Germany' + n)],
|
||||
{ from: 'now-24h', to: 'now' },
|
||||
['id1', 'id2'],
|
||||
|
@ -435,7 +435,7 @@ describe('current status route', () => {
|
|||
});
|
||||
|
||||
it('handles pending configs', async () => {
|
||||
const { esClient, uptimeEsClient } = getUptimeESMockClient();
|
||||
const { esClient, syntheticsEsClient } = getUptimeESMockClient();
|
||||
esClient.search.mockResponseOnce(
|
||||
getEsResponse([
|
||||
{
|
||||
|
@ -540,7 +540,7 @@ describe('current status route', () => {
|
|||
);
|
||||
expect(
|
||||
await queryMonitorStatus(
|
||||
uptimeEsClient,
|
||||
syntheticsEsClient,
|
||||
['Europe - Germany', 'Asia/Pacific - Japan'],
|
||||
{ from: 'now-12h', to: 'now' },
|
||||
['id1', 'id2', 'project-monitor-id', 'id4'],
|
||||
|
@ -667,7 +667,7 @@ describe('current status route', () => {
|
|||
sort: ['a', 3013],
|
||||
} as unknown as SavedObjectsFindResult<EncryptedSyntheticsMonitorAttributes>,
|
||||
]);
|
||||
const { esClient, uptimeEsClient } = getUptimeESMockClient();
|
||||
const { esClient, syntheticsEsClient } = getUptimeESMockClient();
|
||||
esClient.search.mockResponseOnce(
|
||||
getEsResponse([
|
||||
{
|
||||
|
@ -772,7 +772,7 @@ describe('current status route', () => {
|
|||
);
|
||||
const result = await getStatus(
|
||||
{
|
||||
uptimeEsClient,
|
||||
syntheticsEsClient,
|
||||
savedObjectsClient: savedObjectsClientMock.create(),
|
||||
server: serverMock,
|
||||
} as unknown as RouteContext,
|
||||
|
@ -833,12 +833,12 @@ describe('current status route', () => {
|
|||
sort: ['a', 3013],
|
||||
} as unknown as SavedObjectsFindResult<EncryptedSyntheticsMonitorAttributes>,
|
||||
]);
|
||||
const { esClient, uptimeEsClient } = getUptimeESMockClient();
|
||||
const { esClient, syntheticsEsClient } = getUptimeESMockClient();
|
||||
esClient.search.mockResponseOnce(getEsResponse([]));
|
||||
expect(
|
||||
await getStatus(
|
||||
{
|
||||
uptimeEsClient,
|
||||
syntheticsEsClient,
|
||||
savedObjectsClient: savedObjectsClientMock.create(),
|
||||
} as unknown as RouteContext,
|
||||
{
|
||||
|
|
|
@ -36,7 +36,7 @@ export function periodToMs(schedule: { number: string; unit: Unit }) {
|
|||
* @returns The counts of up/down/disabled monitor by location, and a map of each monitor:location status.
|
||||
*/
|
||||
export async function getStatus(context: RouteContext, params: OverviewStatusQuery) {
|
||||
const { uptimeEsClient, syntheticsMonitorClient, savedObjectsClient, server } = context;
|
||||
const { syntheticsEsClient, syntheticsMonitorClient, savedObjectsClient, server } = context;
|
||||
|
||||
const { query, scopeStatusByLocation = true } = params;
|
||||
|
||||
|
@ -97,7 +97,7 @@ export async function getStatus(context: RouteContext, params: OverviewStatusQue
|
|||
};
|
||||
|
||||
const { up, down, pending, upConfigs, downConfigs, pendingConfigs } = await queryMonitorStatus(
|
||||
uptimeEsClient,
|
||||
syntheticsEsClient,
|
||||
listOfLocationAfterFilter,
|
||||
range,
|
||||
enabledMonitorQueryIds,
|
||||
|
|
|
@ -18,7 +18,7 @@ export const syntheticsGetPingStatusesRoute: SyntheticsRestApiRouteFactory = ()
|
|||
validate: {
|
||||
query: getPingsRouteQuerySchema,
|
||||
},
|
||||
handler: async ({ uptimeEsClient, request, response }): Promise<any> => {
|
||||
handler: async ({ syntheticsEsClient, request, response }): Promise<any> => {
|
||||
const {
|
||||
from,
|
||||
to,
|
||||
|
@ -33,7 +33,7 @@ export const syntheticsGetPingStatusesRoute: SyntheticsRestApiRouteFactory = ()
|
|||
} = request.query;
|
||||
|
||||
const result = await queryPings<PingStatus>({
|
||||
uptimeEsClient,
|
||||
syntheticsEsClient,
|
||||
dateRange: { from, to },
|
||||
index,
|
||||
monitorId,
|
||||
|
|
|
@ -31,7 +31,7 @@ export const syntheticsGetPingsRoute: SyntheticsRestApiRouteFactory = () => ({
|
|||
validate: {
|
||||
query: getPingsRouteQuerySchema,
|
||||
},
|
||||
handler: async ({ uptimeEsClient, request, response }): Promise<any> => {
|
||||
handler: async ({ syntheticsEsClient, request, response }): Promise<any> => {
|
||||
const {
|
||||
from,
|
||||
to,
|
||||
|
@ -46,7 +46,7 @@ export const syntheticsGetPingsRoute: SyntheticsRestApiRouteFactory = () => ({
|
|||
} = request.query as GetPingsRouteRequest;
|
||||
|
||||
return await queryPings({
|
||||
uptimeEsClient,
|
||||
syntheticsEsClient,
|
||||
dateRange: { from, to },
|
||||
index,
|
||||
monitorId,
|
||||
|
|
|
@ -9,7 +9,7 @@ import { schema } from '@kbn/config-schema';
|
|||
import { IKibanaResponse } from '@kbn/core-http-server';
|
||||
import { isRight } from 'fp-ts/Either';
|
||||
import * as t from 'io-ts';
|
||||
import { getJourneyScreenshotBlocks } from '../../legacy_uptime/lib/requests/get_journey_screenshot_blocks';
|
||||
import { getJourneyScreenshotBlocks } from '../../queries/get_journey_screenshot_blocks';
|
||||
import { ScreenshotBlockDoc } from '../../../common/runtime_types';
|
||||
import { SYNTHETICS_API_URLS } from '../../../common/constants';
|
||||
import { RouteContext, SyntheticsRestApiRouteFactory } from '../types';
|
||||
|
@ -31,7 +31,7 @@ export const createJourneyScreenshotBlocksRoute: SyntheticsRestApiRouteFactory =
|
|||
export const journeyScreenshotBlocksHandler = async ({
|
||||
response,
|
||||
request,
|
||||
uptimeEsClient,
|
||||
syntheticsEsClient,
|
||||
}: RouteContext): Promise<IKibanaResponse<ScreenshotBlockDoc[]>> => {
|
||||
const { hashes: blockIds } = request.body;
|
||||
|
||||
|
@ -39,7 +39,7 @@ export const journeyScreenshotBlocksHandler = async ({
|
|||
|
||||
const result = await getJourneyScreenshotBlocks({
|
||||
blockIds,
|
||||
uptimeEsClient,
|
||||
syntheticsEsClient,
|
||||
});
|
||||
|
||||
if (result.length === 0) {
|
||||
|
|
|
@ -7,11 +7,11 @@
|
|||
|
||||
import { schema } from '@kbn/config-schema';
|
||||
import { SyntheticsJourneyApiResponse } from '../../../common/runtime_types';
|
||||
import { getJourneyFailedSteps } from '../../legacy_uptime/lib/requests/get_journey_failed_steps';
|
||||
import { getJourneyFailedSteps } from '../../queries/get_journey_failed_steps';
|
||||
import { getJourneySteps } from '../../queries/get_journey_steps';
|
||||
import { getJourneyDetails } from '../../queries/get_journey_details';
|
||||
import { SyntheticsRestApiRouteFactory } from '../types';
|
||||
import { SYNTHETICS_API_URLS } from '../../../common/constants';
|
||||
import { getJourneyDetails } from '../../queries/get_journey_details';
|
||||
import { getJourneySteps } from '../../legacy_uptime/lib/requests/get_journey_steps';
|
||||
|
||||
export const createJourneyRoute: SyntheticsRestApiRouteFactory = () => ({
|
||||
method: 'GET',
|
||||
|
@ -21,16 +21,20 @@ export const createJourneyRoute: SyntheticsRestApiRouteFactory = () => ({
|
|||
checkGroup: schema.string(),
|
||||
}),
|
||||
},
|
||||
handler: async ({ uptimeEsClient, request, response }): Promise<SyntheticsJourneyApiResponse> => {
|
||||
handler: async ({
|
||||
syntheticsEsClient,
|
||||
request,
|
||||
response,
|
||||
}): Promise<SyntheticsJourneyApiResponse> => {
|
||||
const { checkGroup } = request.params;
|
||||
|
||||
const [steps, details] = await Promise.all([
|
||||
getJourneySteps({
|
||||
uptimeEsClient,
|
||||
syntheticsEsClient,
|
||||
checkGroup,
|
||||
}),
|
||||
getJourneyDetails({
|
||||
uptimeEsClient,
|
||||
syntheticsEsClient,
|
||||
checkGroup,
|
||||
}),
|
||||
]);
|
||||
|
@ -51,11 +55,11 @@ export const createJourneyFailedStepsRoute: SyntheticsRestApiRouteFactory = () =
|
|||
checkGroups: schema.arrayOf(schema.string()),
|
||||
}),
|
||||
},
|
||||
handler: async ({ uptimeEsClient, request, response }): Promise<any> => {
|
||||
handler: async ({ syntheticsEsClient, request, response }): Promise<any> => {
|
||||
const { checkGroups } = request.query;
|
||||
try {
|
||||
const result = await getJourneyFailedSteps({
|
||||
uptimeEsClient,
|
||||
syntheticsEsClient,
|
||||
checkGroups,
|
||||
});
|
||||
return {
|
||||
|
|
|
@ -6,9 +6,9 @@
|
|||
*/
|
||||
|
||||
import { schema } from '@kbn/config-schema';
|
||||
import { getJourneyScreenshot } from '../../legacy_uptime/lib/requests/get_journey_screenshot';
|
||||
import { getJourneyScreenshot } from '../../queries/get_journey_screenshot';
|
||||
import { getLastSuccessfulCheck } from '../../queries/get_last_successful_check';
|
||||
import { isFullScreenshot, isRefResult, Ping } from '../../../common/runtime_types';
|
||||
import { getLastSuccessfulCheck } from '../../legacy_uptime/lib/requests/get_last_successful_check';
|
||||
import { SYNTHETICS_API_URLS } from '../../../common/constants';
|
||||
import { RouteContext, SyntheticsRestApiRouteFactory } from '../types';
|
||||
|
||||
|
@ -31,12 +31,12 @@ export const createLastSuccessfulCheckRoute: SyntheticsRestApiRouteFactory = ()
|
|||
export const getLastSuccessfulCheckScreenshot = async ({
|
||||
response,
|
||||
request,
|
||||
uptimeEsClient,
|
||||
syntheticsEsClient,
|
||||
}: RouteContext) => {
|
||||
const { timestamp, monitorId, stepIndex, location } = request.query;
|
||||
|
||||
const check: Ping | null = await getLastSuccessfulCheck({
|
||||
uptimeEsClient,
|
||||
syntheticsEsClient,
|
||||
monitorId,
|
||||
timestamp,
|
||||
location,
|
||||
|
@ -51,7 +51,7 @@ export const getLastSuccessfulCheckScreenshot = async ({
|
|||
}
|
||||
|
||||
const screenshot = await getJourneyScreenshot({
|
||||
uptimeEsClient,
|
||||
syntheticsEsClient,
|
||||
checkGroup: check.monitor.check_group,
|
||||
stepIndex,
|
||||
});
|
||||
|
|
|
@ -14,8 +14,8 @@ export const getIndexSizesRoute: SyntheticsRestApiRouteFactory<{
|
|||
method: 'GET',
|
||||
path: SYNTHETICS_API_URLS.INDEX_SIZE,
|
||||
validate: {},
|
||||
handler: async ({ uptimeEsClient, server }) => {
|
||||
const data = await uptimeEsClient.baseESClient.cat.indices({
|
||||
handler: async ({ syntheticsEsClient, server }) => {
|
||||
const data = await syntheticsEsClient.baseESClient.cat.indices({
|
||||
index: 'synthetics-*',
|
||||
format: 'json',
|
||||
bytes: 'b',
|
||||
|
|
|
@ -21,7 +21,7 @@ import {
|
|||
HttpResponsePayload,
|
||||
ResponseError,
|
||||
} from '@kbn/core-http-server';
|
||||
import { UptimeEsClient } from '../lib';
|
||||
import { SyntheticsEsClient } from '../lib';
|
||||
import { SyntheticsServerSetup, UptimeRequestHandlerContext } from '../types';
|
||||
import { SyntheticsMonitorClient } from '../synthetics_service/synthetics_monitor/synthetics_monitor_client';
|
||||
export type SyntheticsRequest = KibanaRequest<
|
||||
|
@ -84,7 +84,7 @@ export type SyntheticsRouteWrapper = (
|
|||
) => UMKibanaRoute;
|
||||
|
||||
export interface UptimeRouteContext {
|
||||
uptimeEsClient: UptimeEsClient;
|
||||
syntheticsEsClient: SyntheticsEsClient;
|
||||
context: UptimeRequestHandlerContext;
|
||||
request: SyntheticsRequest;
|
||||
response: KibanaResponseFactory;
|
||||
|
@ -98,7 +98,7 @@ export interface RouteContext<
|
|||
Query = Record<string, any>,
|
||||
Body = any
|
||||
> {
|
||||
uptimeEsClient: UptimeEsClient;
|
||||
syntheticsEsClient: SyntheticsEsClient;
|
||||
context: UptimeRequestHandlerContext;
|
||||
request: KibanaRequest<Params, Query, Body>;
|
||||
response: KibanaResponseFactory;
|
||||
|
@ -115,7 +115,7 @@ export type SyntheticsRouteHandler<
|
|||
Query = Record<string, any>,
|
||||
Body = any
|
||||
> = ({
|
||||
uptimeEsClient,
|
||||
syntheticsEsClient,
|
||||
context,
|
||||
request,
|
||||
response,
|
||||
|
|
|
@ -23,7 +23,7 @@ describe('processMonitors', () => {
|
|||
|
||||
const serverMock: SyntheticsServerSetup = {
|
||||
logger,
|
||||
uptimeEsClient: mockEsClient,
|
||||
syntheticsEsClient: mockEsClient,
|
||||
authSavedObjectsClient: soClient,
|
||||
config: {
|
||||
service: {
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
import { KibanaResponse } from '@kbn/core-http-router-server-internal';
|
||||
import { DEFAULT_SPACE_ID } from '@kbn/spaces-plugin/common';
|
||||
import { isEmpty } from 'lodash';
|
||||
import { isTestUser, UptimeEsClient } from './lib';
|
||||
import { isTestUser, SyntheticsEsClient } from './lib';
|
||||
import { checkIndicesReadPrivileges } from './synthetics_service/authentication/check_has_privilege';
|
||||
import { SYNTHETICS_INDEX_PATTERN } from '../common/constants';
|
||||
import { syntheticsServiceApiKey } from './saved_objects/service_api_key';
|
||||
|
@ -34,20 +34,20 @@ export const syntheticsRouteWrapper: SyntheticsRouteWrapper = (
|
|||
// specifically needed for the synthetics service api key generation
|
||||
server.authSavedObjectsClient = savedObjectsClient;
|
||||
|
||||
const uptimeEsClient = new UptimeEsClient(savedObjectsClient, esClient.asCurrentUser, {
|
||||
const syntheticsEsClient = new SyntheticsEsClient(savedObjectsClient, esClient.asCurrentUser, {
|
||||
request,
|
||||
uiSettings,
|
||||
isDev: Boolean(server.isDev) && !isTestUser(server),
|
||||
heartbeatIndices: SYNTHETICS_INDEX_PATTERN,
|
||||
});
|
||||
|
||||
server.uptimeEsClient = uptimeEsClient;
|
||||
server.syntheticsEsClient = syntheticsEsClient;
|
||||
|
||||
const spaceId = server.spaces?.spacesService.getSpaceId(request) ?? DEFAULT_SPACE_ID;
|
||||
|
||||
try {
|
||||
const res = await uptimeRoute.handler({
|
||||
uptimeEsClient,
|
||||
syntheticsEsClient,
|
||||
savedObjectsClient,
|
||||
context,
|
||||
request,
|
||||
|
@ -60,7 +60,7 @@ export const syntheticsRouteWrapper: SyntheticsRouteWrapper = (
|
|||
return res;
|
||||
}
|
||||
|
||||
const inspectData = await uptimeEsClient.getInspectData(uptimeRoute.path);
|
||||
const inspectData = await syntheticsEsClient.getInspectData(uptimeRoute.path);
|
||||
|
||||
if (Array.isArray(res)) {
|
||||
if (isEmpty(inspectData)) {
|
||||
|
@ -80,12 +80,12 @@ export const syntheticsRouteWrapper: SyntheticsRouteWrapper = (
|
|||
return response.ok({
|
||||
body: {
|
||||
...res,
|
||||
...(await uptimeEsClient.getInspectData(uptimeRoute.path)),
|
||||
...(await syntheticsEsClient.getInspectData(uptimeRoute.path)),
|
||||
},
|
||||
});
|
||||
} catch (e) {
|
||||
if (e.statusCode === 403) {
|
||||
const privileges = await checkIndicesReadPrivileges(uptimeEsClient);
|
||||
const privileges = await checkIndicesReadPrivileges(syntheticsEsClient);
|
||||
if (!privileges.has_all_requested) {
|
||||
return response.forbidden({
|
||||
body: {
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
*/
|
||||
|
||||
import { SecurityIndexPrivilege } from '@elastic/elasticsearch/lib/api/types';
|
||||
import { UptimeEsClient } from '../../lib';
|
||||
import { SyntheticsEsClient } from '../../lib';
|
||||
import { SyntheticsServerSetup } from '../../types';
|
||||
import { getFakeKibanaRequest } from '../utils/fake_kibana_request';
|
||||
import { getServiceApiKeyPrivileges, syntheticsIndex } from '../get_api_key';
|
||||
|
@ -26,8 +26,8 @@ export const checkHasPrivileges = (
|
|||
});
|
||||
};
|
||||
|
||||
export const checkIndicesReadPrivileges = (uptimeEsClient: UptimeEsClient) => {
|
||||
return uptimeEsClient.baseESClient.security.hasPrivileges({
|
||||
export const checkIndicesReadPrivileges = (syntheticsEsClient: SyntheticsEsClient) => {
|
||||
return syntheticsEsClient.baseESClient.security.hasPrivileges({
|
||||
body: {
|
||||
index: [
|
||||
{
|
||||
|
|
|
@ -19,7 +19,7 @@ import { loggerMock } from '@kbn/logging-mocks';
|
|||
|
||||
import * as authUtils from './authentication/check_has_privilege';
|
||||
import { SyntheticsServerSetup } from '../types';
|
||||
import { getUptimeESMockClient } from '../legacy_uptime/lib/requests/test_helpers';
|
||||
import { getUptimeESMockClient } from '../queries/test_helpers';
|
||||
|
||||
describe('getAPIKeyTest', function () {
|
||||
const core = coreMock.createStart();
|
||||
|
@ -34,7 +34,7 @@ describe('getAPIKeyTest', function () {
|
|||
security,
|
||||
encryptedSavedObjects,
|
||||
savedObjectsClient: core.savedObjects.getScopedClient(request),
|
||||
uptimeEsClient: getUptimeESMockClient().uptimeEsClient,
|
||||
syntheticsEsClient: getUptimeESMockClient().syntheticsEsClient,
|
||||
} as unknown as SyntheticsServerSetup;
|
||||
|
||||
security.authc.apiKeys.areAPIKeysEnabled = jest.fn().mockReturnValue(true);
|
||||
|
|
|
@ -207,12 +207,12 @@ export const getSyntheticsEnablement = async ({ server }: { server: SyntheticsSe
|
|||
};
|
||||
|
||||
const hasEnablePermissions = async ({
|
||||
uptimeEsClient,
|
||||
syntheticsEsClient,
|
||||
isElasticsearchServerless,
|
||||
}: SyntheticsServerSetup) => {
|
||||
const { cluster: clusterPrivs, indices: index } =
|
||||
getServiceApiKeyPrivileges(isElasticsearchServerless);
|
||||
const hasPrivileges = await uptimeEsClient.baseESClient.security.hasPrivileges({
|
||||
const hasPrivileges = await syntheticsEsClient.baseESClient.security.hasPrivileges({
|
||||
body: {
|
||||
cluster: ['manage_security', 'manage_api_key', 'manage_own_api_key', ...clusterPrivs],
|
||||
index,
|
||||
|
|
|
@ -55,7 +55,7 @@ describe('SyntheticsPrivateLocation', () => {
|
|||
} as unknown as HeartbeatConfig;
|
||||
|
||||
const serverMock: SyntheticsServerSetup = {
|
||||
uptimeEsClient: { search: jest.fn() },
|
||||
syntheticsEsClient: { search: jest.fn() },
|
||||
logger: loggerMock.create(),
|
||||
config: {
|
||||
service: {
|
||||
|
|
|
@ -104,7 +104,7 @@ describe('ProjectMonitorFormatter', () => {
|
|||
|
||||
const serverMock: SyntheticsServerSetup = {
|
||||
logger,
|
||||
uptimeEsClient: mockEsClient,
|
||||
syntheticsEsClient: mockEsClient,
|
||||
authSavedObjectsClient: soClient,
|
||||
config: {
|
||||
service: {
|
||||
|
|
|
@ -52,7 +52,7 @@ describe('SyntheticsMonitorClient', () => {
|
|||
|
||||
const serverMock: SyntheticsServerSetup = {
|
||||
logger,
|
||||
uptimeEsClient: mockEsClient,
|
||||
syntheticsEsClient: mockEsClient,
|
||||
authSavedObjectsClient: {
|
||||
bulkUpdate: jest.fn(),
|
||||
get: jest.fn(),
|
||||
|
|
|
@ -72,7 +72,7 @@ describe('SyntheticsService', () => {
|
|||
|
||||
const serverMock: SyntheticsServerSetup = {
|
||||
logger,
|
||||
uptimeEsClient: mockEsClient,
|
||||
syntheticsEsClient: mockEsClient,
|
||||
authSavedObjectsClient: {
|
||||
bulkUpdate: jest.fn(),
|
||||
},
|
||||
|
|
|
@ -38,7 +38,7 @@ import {
|
|||
} from '@kbn/task-manager-plugin/server';
|
||||
import { TelemetryEventsSender } from './telemetry/sender';
|
||||
import { UptimeConfig } from '../common/config';
|
||||
import { UptimeEsClient } from './lib';
|
||||
import { SyntheticsEsClient } from './lib';
|
||||
|
||||
export interface SyntheticsServerSetup {
|
||||
router: UptimeRouter;
|
||||
|
@ -54,7 +54,7 @@ export interface SyntheticsServerSetup {
|
|||
stackVersion: string;
|
||||
logger: Logger;
|
||||
telemetry: TelemetryEventsSender;
|
||||
uptimeEsClient: UptimeEsClient;
|
||||
syntheticsEsClient: SyntheticsEsClient;
|
||||
basePath: IBasePath;
|
||||
isDev?: boolean;
|
||||
coreStart: CoreStart;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue