[Uptime] [User Experience] Prefix internal apis with /internal (#117852) (#118380)

* [Uptime] prefix internal APIs with /internal [relates to #116334]

* [Uptime] move hard-coded URL paths to rest_api constants [relates to #116334]

* [Uptime] use API_URLS from constants in API integration tests [relates to #116334]

* [Uptime] Remove unnecessary filters route test

* [Uptime] prefix internal RUM routes with /internal and /ux [relates to #116334]

* [User Experience] update API docs for prefixed internal UX APIs
This commit is contained in:
Lucas F. da Costa 2021-11-11 17:25:19 +00:00 committed by GitHub
parent 178fff209e
commit 1b1e803753
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
41 changed files with 748 additions and 261 deletions

File diff suppressed because one or more lines are too long

View file

@ -55,7 +55,7 @@ export function Metrics() {
(callApmApi) => {
if (uxQuery) {
return callApmApi({
endpoint: 'GET /api/apm/rum/client-metrics',
endpoint: 'GET /internal/apm/ux/client-metrics',
params: {
query: {
...uxQuery,

View file

@ -41,7 +41,7 @@ export function JSErrors() {
(callApmApi) => {
if (start && end && serviceName) {
return callApmApi({
endpoint: 'GET /api/apm/rum-client/js-errors',
endpoint: 'GET /internal/apm/ux/js-errors',
params: {
query: {
start,

View file

@ -51,7 +51,7 @@ export function PageLoadDistribution() {
(callApmApi) => {
if (start && end && serviceName) {
return callApmApi({
endpoint: 'GET /api/apm/rum-client/page-load-distribution',
endpoint: 'GET /internal/apm/ux/page-load-distribution',
params: {
query: {
start,

View file

@ -24,7 +24,7 @@ export const useBreakdowns = ({ percentileRange, field, value }: Props) => {
(callApmApi) => {
if (start && end && field && value) {
return callApmApi({
endpoint: 'GET /api/apm/rum-client/page-load-distribution/breakdown',
endpoint: 'GET /internal/apm/ux/page-load-distribution/breakdown',
params: {
query: {
start,

View file

@ -39,7 +39,7 @@ export function PageViewsTrend() {
(callApmApi) => {
if (start && end && serviceName) {
return callApmApi({
endpoint: 'GET /api/apm/rum-client/page-view-trends',
endpoint: 'GET /internal/apm/ux/page-view-trends',
params: {
query: {
start,

View file

@ -20,7 +20,7 @@ export function WebApplicationSelect() {
(callApmApi) => {
if (start && end) {
return callApmApi({
endpoint: 'GET /api/apm/rum-client/services',
endpoint: 'GET /internal/apm/ux/services',
params: {
query: {
start,

View file

@ -38,7 +38,7 @@ export const useUrlSearch = ({ popoverIsOpen, query }: Props) => {
(callApmApi) => {
if (uxQuery && popoverIsOpen) {
return callApmApi({
endpoint: 'GET /api/apm/rum-client/url-search',
endpoint: 'GET /internal/apm/ux/url-search',
params: {
query: {
...uxQuery,

View file

@ -56,7 +56,7 @@ export function KeyUXMetrics({ data, loading }: Props) {
(callApmApi) => {
if (uxQuery) {
return callApmApi({
endpoint: 'GET /api/apm/rum-client/long-task-metrics',
endpoint: 'GET /internal/apm/ux/long-task-metrics',
params: {
query: {
...uxQuery,

View file

@ -34,7 +34,7 @@ export function UXMetrics() {
(callApmApi) => {
if (uxQuery) {
return callApmApi({
endpoint: 'GET /api/apm/rum-client/web-core-vitals',
endpoint: 'GET /internal/apm/ux/web-core-vitals',
params: {
query: uxQuery,
},

View file

@ -23,7 +23,7 @@ export function VisitorBreakdown() {
if (start && end && serviceName) {
return callApmApi({
endpoint: 'GET /api/apm/rum-client/visitor-breakdown',
endpoint: 'GET /internal/apm/ux/visitor-breakdown',
params: {
query: {
start,

View file

@ -21,7 +21,7 @@ export const fetchUxOverviewDate = async ({
serviceName,
}: FetchDataParams): Promise<UxFetchDataResponse> => {
const data = await callApmApi({
endpoint: 'GET /api/apm/rum-client/web-core-vitals',
endpoint: 'GET /internal/apm/ux/web-core-vitals',
signal: null,
params: {
query: {

View file

@ -65,7 +65,7 @@ const uxQueryRt = t.intersection([
]);
const rumClientMetricsRoute = createApmServerRoute({
endpoint: 'GET /api/apm/rum/client-metrics',
endpoint: 'GET /internal/apm/ux/client-metrics',
params: t.type({
query: uxQueryRt,
}),
@ -88,7 +88,7 @@ const rumClientMetricsRoute = createApmServerRoute({
});
const rumPageLoadDistributionRoute = createApmServerRoute({
endpoint: 'GET /api/apm/rum-client/page-load-distribution',
endpoint: 'GET /internal/apm/ux/page-load-distribution',
params: t.type({
query: t.intersection([uxQueryRt, percentileRangeRt]),
}),
@ -114,7 +114,7 @@ const rumPageLoadDistributionRoute = createApmServerRoute({
});
const rumPageLoadDistBreakdownRoute = createApmServerRoute({
endpoint: 'GET /api/apm/rum-client/page-load-distribution/breakdown',
endpoint: 'GET /internal/apm/ux/page-load-distribution/breakdown',
params: t.type({
query: t.intersection([
uxQueryRt,
@ -145,7 +145,7 @@ const rumPageLoadDistBreakdownRoute = createApmServerRoute({
});
const rumPageViewsTrendRoute = createApmServerRoute({
endpoint: 'GET /api/apm/rum-client/page-view-trends',
endpoint: 'GET /internal/apm/ux/page-view-trends',
params: t.type({
query: t.intersection([uxQueryRt, t.partial({ breakdowns: t.string })]),
}),
@ -168,7 +168,7 @@ const rumPageViewsTrendRoute = createApmServerRoute({
});
const rumServicesRoute = createApmServerRoute({
endpoint: 'GET /api/apm/rum-client/services',
endpoint: 'GET /internal/apm/ux/services',
params: t.type({
query: t.intersection([uiFiltersRt, rangeRt]),
}),
@ -184,7 +184,7 @@ const rumServicesRoute = createApmServerRoute({
});
const rumVisitorsBreakdownRoute = createApmServerRoute({
endpoint: 'GET /api/apm/rum-client/visitor-breakdown',
endpoint: 'GET /internal/apm/ux/visitor-breakdown',
params: t.type({
query: uxQueryRt,
}),
@ -206,7 +206,7 @@ const rumVisitorsBreakdownRoute = createApmServerRoute({
});
const rumWebCoreVitals = createApmServerRoute({
endpoint: 'GET /api/apm/rum-client/web-core-vitals',
endpoint: 'GET /internal/apm/ux/web-core-vitals',
params: t.type({
query: uxQueryRt,
}),
@ -229,7 +229,7 @@ const rumWebCoreVitals = createApmServerRoute({
});
const rumLongTaskMetrics = createApmServerRoute({
endpoint: 'GET /api/apm/rum-client/long-task-metrics',
endpoint: 'GET /internal/apm/ux/long-task-metrics',
params: t.type({
query: uxQueryRt,
}),
@ -252,7 +252,7 @@ const rumLongTaskMetrics = createApmServerRoute({
});
const rumUrlSearch = createApmServerRoute({
endpoint: 'GET /api/apm/rum-client/url-search',
endpoint: 'GET /internal/apm/ux/url-search',
params: t.type({
query: uxQueryRt,
}),
@ -275,7 +275,7 @@ const rumUrlSearch = createApmServerRoute({
});
const rumJSErrors = createApmServerRoute({
endpoint: 'GET /api/apm/rum-client/js-errors',
endpoint: 'GET /internal/apm/ux/js-errors',
params: t.type({
query: t.intersection([
uiFiltersRt,

View file

@ -6,16 +6,23 @@
*/
export enum API_URLS {
INDEX_STATUS = '/api/uptime/index_status',
MONITOR_LIST = `/api/uptime/monitor/list`,
MONITOR_LOCATIONS = `/api/uptime/monitor/locations`,
MONITOR_DURATION = `/api/uptime/monitor/duration`,
MONITOR_DETAILS = `/api/uptime/monitor/details`,
MONITOR_STATUS = `/api/uptime/monitor/status`,
PINGS = '/api/uptime/pings',
PING_HISTOGRAM = `/api/uptime/ping/histogram`,
SNAPSHOT_COUNT = `/api/uptime/snapshot/count`,
LOG_PAGE_VIEW = `/api/uptime/log_page_view`,
DYNAMIC_SETTINGS = `/internal/uptime/dynamic_settings`,
INDEX_STATUS = '/internal/uptime/index_status',
MONITOR_LIST = `/internal/uptime/monitor/list`,
MONITOR_LOCATIONS = `/internal/uptime/monitor/locations`,
MONITOR_DURATION = `/internal/uptime/monitor/duration`,
MONITOR_DETAILS = `/internal/uptime/monitor/details`,
MONITOR_STATUS = `/internal/uptime/monitor/status`,
NETWORK_EVENTS = `/internal/uptime/network_events`,
PINGS = '/internal/uptime/pings',
PING_HISTOGRAM = `/internal/uptime/ping/histogram`,
SNAPSHOT_COUNT = `/internal/uptime/snapshot/count`,
SYNTHETICS_SUCCESSFUL_STEP = `/internal/uptime/synthetics/step/success`,
JOURNEY_CREATE = `/internal/uptime/journey/{checkGroup}`,
JOURNEY_FAILED_STEPS = `/internal/uptime/journeys/failed_steps`,
JOURNEY_SCREENSHOT = `/internal/uptime/journey/screenshot/{checkGroup}/{stepIndex}`,
JOURNEY_SCREENSHOT_BLOCKS = `/internal/uptime/journey/screenshot/block`,
LOG_PAGE_VIEW = `/internal/uptime/log_page_view`,
ML_MODULE_JOBS = `/api/ml/modules/jobs_exist/`,
ML_SETUP_MODULE = '/api/ml/modules/setup/',

View file

@ -48,7 +48,7 @@ export const PingTimestamp = ({ label, checkGroup, initialStepNo = 1 }: Props) =
const { basePath } = useContext(UptimeSettingsContext);
const imgPath = `${basePath}/api/uptime/journey/screenshot/${checkGroup}/${stepNumber}`;
const imgPath = `${basePath}/internal/uptime/journey/screenshot/${checkGroup}/${stepNumber}`;
const intersection = useIntersection(intersectionRef, {
root: null,

View file

@ -123,7 +123,7 @@ export const StepScreenshotDisplay: FC<StepScreenshotDisplayProps> = ({
}
}, [hasIntersected, isIntersecting, setHasIntersected]);
const imgSrc = basePath + `/api/uptime/journey/screenshot/${checkGroup}/${stepIndex}`;
const imgSrc = basePath + `/internal/uptime/journey/screenshot/${checkGroup}/${stepIndex}`;
// When loading a legacy screenshot, set `url` to full-size screenshot path.
// Otherwise, we first need to composite the image.

View file

@ -12,8 +12,9 @@ import {
DynamicSettingsSaveType,
} from '../../../common/runtime_types';
import { apiService } from './utils';
import { API_URLS } from '../../../common/constants';
const apiPath = '/api/uptime/dynamic_settings';
const apiPath = API_URLS.DYNAMIC_SETTINGS;
interface SaveApiRequest {
settings: DynamicSettings;

View file

@ -18,16 +18,17 @@ import {
SyntheticsJourneyApiResponse,
SyntheticsJourneyApiResponseType,
} from '../../../common/runtime_types/ping/synthetics';
import { API_URLS } from '../../../common/constants';
export async function fetchScreenshotBlockSet(params: string[]): Promise<ScreenshotBlockDoc[]> {
return apiService.post('/api/uptime/journey/screenshot/block', { hashes: params });
return apiService.post(API_URLS.JOURNEY_SCREENSHOT_BLOCKS, { hashes: params });
}
export async function fetchJourneySteps(
params: FetchJourneyStepsParams
): Promise<SyntheticsJourneyApiResponse> {
return apiService.get(
`/api/uptime/journey/${params.checkGroup}`,
`/internal/uptime/journey/${params.checkGroup}`,
{ syntheticEventTypes: params.syntheticEventTypes },
SyntheticsJourneyApiResponseType
);
@ -38,11 +39,7 @@ export async function fetchJourneysFailedSteps({
}: {
checkGroups: string[];
}): Promise<FailedStepsApiResponse> {
return apiService.get(
`/api/uptime/journeys/failed_steps`,
{ checkGroups },
FailedStepsApiResponseType
);
return apiService.get(API_URLS.JOURNEY_FAILED_STEPS, { checkGroups }, FailedStepsApiResponseType);
}
export async function fetchLastSuccessfulStep({
@ -57,7 +54,7 @@ export async function fetchLastSuccessfulStep({
location?: string;
}): Promise<JourneyStep> {
return await apiService.get(
`/api/uptime/synthetics/step/success/`,
API_URLS.SYNTHETICS_SUCCESSFUL_STEP,
{
monitorId,
timestamp,

View file

@ -11,12 +11,13 @@ import {
SyntheticsNetworkEventsApiResponse,
SyntheticsNetworkEventsApiResponseType,
} from '../../../common/runtime_types';
import { API_URLS } from '../../../common/constants';
export async function fetchNetworkEvents(
params: FetchNetworkEventsParams
): Promise<SyntheticsNetworkEventsApiResponse> {
return (await apiService.get(
`/api/uptime/network_events`,
API_URLS.NETWORK_EVENTS,
{
checkGroup: params.checkGroup,
stepIndex: params.stepIndex,

View file

@ -8,6 +8,7 @@
import { HttpFetchError } from 'src/core/public';
import { fetchSnapshotCount } from './snapshot';
import { apiService } from './utils';
import { API_URLS } from '../../../common/constants';
describe('snapshot API', () => {
let fetchMock: jest.SpyInstance<Partial<unknown>>;
@ -36,7 +37,7 @@ describe('snapshot API', () => {
});
expect(fetchMock).toHaveBeenCalledWith({
asResponse: false,
path: '/api/uptime/snapshot/count',
path: API_URLS.SNAPSHOT_COUNT,
query: {
dateRangeEnd: 'now',
dateRangeStart: 'now-15m',

View file

@ -16,10 +16,11 @@ import {
VALUE_MUST_BE_GREATER_THAN_ZERO,
VALUE_MUST_BE_AN_INTEGER,
} from '../../common/translations';
import { API_URLS } from '../../common/constants';
export const createGetDynamicSettingsRoute: UMRestApiRouteFactory = (libs: UMServerLibs) => ({
method: 'GET',
path: '/api/uptime/dynamic_settings',
path: API_URLS.DYNAMIC_SETTINGS,
validate: false,
handler: async ({ savedObjectsClient }): Promise<any> => {
return savedObjectsAdapter.getUptimeDynamicSettings(savedObjectsClient);
@ -47,7 +48,7 @@ export const validateCertsValues = (
export const createPostDynamicSettingsRoute: UMRestApiRouteFactory = (libs: UMServerLibs) => ({
method: 'POST',
path: '/api/uptime/dynamic_settings',
path: API_URLS.DYNAMIC_SETTINGS,
validate: {
body: schema.object({
heartbeatIndices: schema.string(),

View file

@ -8,10 +8,11 @@
import { schema } from '@kbn/config-schema';
import { UMServerLibs } from '../../lib/lib';
import { UMRestApiRouteFactory } from '../types';
import { API_URLS } from '../../../common/constants';
export const createNetworkEventsRoute: UMRestApiRouteFactory = (libs: UMServerLibs) => ({
method: 'GET',
path: '/api/uptime/network_events',
path: API_URLS.NETWORK_EVENTS,
validate: {
query: schema.object({
checkGroup: schema.string(),

View file

@ -10,6 +10,7 @@ import { isRight } from 'fp-ts/lib/Either';
import { schema } from '@kbn/config-schema';
import { UMServerLibs } from '../../lib/lib';
import { UMRestApiRouteFactory } from '../types';
import { API_URLS } from '../../../common/constants';
function isStringArray(data: unknown): data is string[] {
return isRight(t.array(t.string).decode(data));
@ -17,7 +18,7 @@ function isStringArray(data: unknown): data is string[] {
export const createJourneyScreenshotBlocksRoute: UMRestApiRouteFactory = (libs: UMServerLibs) => ({
method: 'POST',
path: '/api/uptime/journey/screenshot/block',
path: API_URLS.JOURNEY_SCREENSHOT_BLOCKS,
validate: {
body: schema.object({
hashes: schema.arrayOf(schema.string()),

View file

@ -10,6 +10,7 @@ import { isRefResult, isFullScreenshot } from '../../../common/runtime_types/pin
import { UMServerLibs } from '../../lib/lib';
import { ScreenshotReturnTypesUnion } from '../../lib/requests/get_journey_screenshot';
import { UMRestApiRouteFactory } from '../types';
import { API_URLS } from '../../../common/constants';
function getSharedHeaders(stepName: string, totalSteps: number) {
return {
@ -21,7 +22,7 @@ function getSharedHeaders(stepName: string, totalSteps: number) {
export const createJourneyScreenshotRoute: UMRestApiRouteFactory = (libs: UMServerLibs) => ({
method: 'GET',
path: '/api/uptime/journey/screenshot/{checkGroup}/{stepIndex}',
path: API_URLS.JOURNEY_SCREENSHOT,
validate: {
params: schema.object({
checkGroup: schema.string(),

View file

@ -8,10 +8,11 @@
import { schema } from '@kbn/config-schema';
import { UMServerLibs } from '../../lib/lib';
import { UMRestApiRouteFactory } from '../types';
import { API_URLS } from '../../../common/constants';
export const createJourneyRoute: UMRestApiRouteFactory = (libs: UMServerLibs) => ({
method: 'GET',
path: '/api/uptime/journey/{checkGroup}',
path: API_URLS.JOURNEY_CREATE,
validate: {
params: schema.object({
checkGroup: schema.string(),
@ -54,7 +55,7 @@ export const createJourneyRoute: UMRestApiRouteFactory = (libs: UMServerLibs) =>
export const createJourneyFailedStepsRoute: UMRestApiRouteFactory = (libs: UMServerLibs) => ({
method: 'GET',
path: '/api/uptime/journeys/failed_steps',
path: API_URLS.JOURNEY_FAILED_STEPS,
validate: {
query: schema.object({
checkGroups: schema.arrayOf(schema.string()),

View file

@ -13,10 +13,11 @@ import {
} from '../../../common/runtime_types/ping/synthetics';
import { UMServerLibs } from '../../lib/lib';
import { UMRestApiRouteFactory } from '../types';
import { API_URLS } from '../../../common/constants';
export const createLastSuccessfulStepRoute: UMRestApiRouteFactory = (libs: UMServerLibs) => ({
method: 'GET',
path: '/api/uptime/synthetics/step/success/',
path: API_URLS.SYNTHETICS_SUCCESSFUL_STEP,
validate: {
query: schema.object({
monitorId: schema.string(),

View file

@ -9,6 +9,7 @@ import moment from 'moment';
import expect from '@kbn/expect';
import { PINGS_DATE_RANGE_START, PINGS_DATE_RANGE_END } from './constants';
import { FtrProviderContext } from '../../ftr_provider_context';
import { API_URLS } from '../../../../plugins/uptime/common/constants';
export default function ({ getService }: FtrProviderContext) {
const supertest = getService('supertest');
@ -22,9 +23,12 @@ export default function ({ getService }: FtrProviderContext) {
it('should get all pings stored in index', async () => {
const { body: apiResponse } = await supertest
.get(
`/api/uptime/pings?sort=desc&from=${PINGS_DATE_RANGE_START}&to=${PINGS_DATE_RANGE_END}`
)
.get(API_URLS.PINGS)
.query({
sort: 'desc',
from: PINGS_DATE_RANGE_START,
to: PINGS_DATE_RANGE_END,
})
.expect(200);
expect(apiResponse.total).to.be(2);
@ -34,7 +38,12 @@ export default function ({ getService }: FtrProviderContext) {
it('should sort pings according to timestamp', async () => {
const { body: apiResponse } = await supertest
.get(`/api/uptime/pings?sort=asc&from=${PINGS_DATE_RANGE_START}&to=${PINGS_DATE_RANGE_END}`)
.get(API_URLS.PINGS)
.query({
sort: 'asc',
from: PINGS_DATE_RANGE_START,
to: PINGS_DATE_RANGE_END,
})
.expect(200);
expect(apiResponse.total).to.be(2);
@ -45,9 +54,13 @@ export default function ({ getService }: FtrProviderContext) {
it('should return results of n length', async () => {
const { body: apiResponse } = await supertest
.get(
`/api/uptime/pings?sort=desc&size=1&from=${PINGS_DATE_RANGE_START}&to=${PINGS_DATE_RANGE_END}`
)
.get(API_URLS.PINGS)
.query({
sort: 'desc',
size: 1,
from: PINGS_DATE_RANGE_START,
to: PINGS_DATE_RANGE_END,
})
.expect(200);
expect(apiResponse.total).to.be(2);
@ -59,7 +72,8 @@ export default function ({ getService }: FtrProviderContext) {
const from = moment('2002-01-01').valueOf();
const to = moment('2002-01-02').valueOf();
const { body: apiResponse } = await supertest
.get(`/api/uptime/pings?from=${from}&to=${to}`)
.get(API_URLS.PINGS)
.query({ from, to })
.expect(200);
expect(apiResponse.total).to.be(0);

View file

@ -12,13 +12,16 @@ import {
DynamicSettingsType,
DynamicSettings,
} from '../../../../../plugins/uptime/common/runtime_types';
import { DYNAMIC_SETTINGS_DEFAULTS } from '../../../../../plugins/uptime/common/constants';
import {
DYNAMIC_SETTINGS_DEFAULTS,
API_URLS,
} from '../../../../../plugins/uptime/common/constants';
export default function ({ getService }: FtrProviderContext) {
const supertest = getService('supertest');
describe('dynamic settings', () => {
it('returns the defaults when no user settings have been saved', async () => {
const apiResponse = await supertest.get(`/api/uptime/dynamic_settings`);
const apiResponse = await supertest.get(API_URLS.DYNAMIC_SETTINGS);
expect(apiResponse.body).to.eql(DYNAMIC_SETTINGS_DEFAULTS);
expect(isRight(DynamicSettingsType.decode(apiResponse.body))).to.be.ok();
});
@ -31,14 +34,14 @@ export default function ({ getService }: FtrProviderContext) {
defaultConnectors: [],
};
const postResponse = await supertest
.post(`/api/uptime/dynamic_settings`)
.post(API_URLS.DYNAMIC_SETTINGS)
.set('kbn-xsrf', 'true')
.send(newSettings);
expect(postResponse.body).to.eql({ success: true });
expect(postResponse.status).to.eql(200);
const getResponse = await supertest.get(`/api/uptime/dynamic_settings`);
const getResponse = await supertest.get(API_URLS.DYNAMIC_SETTINGS);
expect(getResponse.body).to.eql(newSettings);
expect(isRight(DynamicSettingsType.decode(getResponse.body))).to.be.ok();
});

View file

@ -1,28 +0,0 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import { expectFixtureEql } from './helper/expect_fixture_eql';
import { FtrProviderContext } from '../../../ftr_provider_context';
const getApiPath = (dateRangeStart: string, dateRangeEnd: string, filters?: string) =>
`/api/uptime/filters?dateRangeStart=${dateRangeStart}&dateRangeEnd=${dateRangeEnd}${
filters ? `&filters=${filters}` : ''
}`;
export default function ({ getService }: FtrProviderContext) {
const supertest = getService('supertest');
describe('filter group endpoint', () => {
const dateRangeStart = '2019-01-28T17:40:08.078Z';
const dateRangeEnd = '2025-01-28T19:00:16.078Z';
it('returns expected filters', async () => {
const resp = await supertest.get(getApiPath(dateRangeStart, dateRangeEnd));
expectFixtureEql(resp.body, 'filters');
});
});
}

View file

@ -7,6 +7,7 @@
import { expectFixtureEql } from './helper/expect_fixture_eql';
import { FtrProviderContext } from '../../../ftr_provider_context';
import { API_URLS } from '../../../../../plugins/uptime/common/constants';
export default function ({ getService }: FtrProviderContext) {
describe('monitor duration query', () => {
@ -18,9 +19,11 @@ export default function ({ getService }: FtrProviderContext) {
const monitorId = '0002-up';
const apiResponse = await supertest.get(
`/api/uptime/monitor/duration?monitorId=${monitorId}&dateStart=${dateStart}&dateEnd=${dateEnd}`
);
const apiResponse = await supertest.get(API_URLS.MONITOR_DURATION).query({
monitorId,
dateStart,
dateEnd,
});
const data = apiResponse.body;
expectFixtureEql(data, 'monitor_charts');
});
@ -31,9 +34,11 @@ export default function ({ getService }: FtrProviderContext) {
const monitorId = '0002-up';
const apiResponse = await supertest.get(
`/api/uptime/monitor/duration?monitorId=${monitorId}&dateStart=${dateStart}&dateEnd=${dateEnd}`
);
const apiResponse = await supertest.get(API_URLS.MONITOR_DURATION).query({
monitorId,
dateStart,
dateEnd,
});
const data = apiResponse.body;
expectFixtureEql(data, 'monitor_charts_empty_sets');

View file

@ -7,6 +7,7 @@
import { expectFixtureEql } from './helper/expect_fixture_eql';
import { FtrProviderContext } from '../../../ftr_provider_context';
import { API_URLS } from '../../../../../plugins/uptime/common/constants';
export default function ({ getService }: FtrProviderContext) {
describe('get monitor latest status API', () => {
@ -17,9 +18,11 @@ export default function ({ getService }: FtrProviderContext) {
const supertest = getService('supertest');
it('returns the status for only the given monitor', async () => {
const apiResponse = await supertest.get(
`/api/uptime/monitor/status?monitorId=${monitorId}&dateStart=${dateStart}&dateEnd=${dateEnd}`
);
const apiResponse = await supertest.get(API_URLS.MONITOR_STATUS).query({
monitorId,
dateStart,
dateEnd,
});
expectFixtureEql(apiResponse.body, 'monitor_latest_status');
});
});

View file

@ -7,6 +7,7 @@
import { expectFixtureEql } from './helper/expect_fixture_eql';
import { FtrProviderContext } from '../../../ftr_provider_context';
import { API_URLS } from '../../../../../plugins/uptime/common/constants';
export default function ({ getService }: FtrProviderContext) {
describe('pingHistogram', () => {
@ -16,9 +17,10 @@ export default function ({ getService }: FtrProviderContext) {
const dateStart = '2019-09-11T03:31:04.380Z';
const dateEnd = '2019-09-11T03:40:34.410Z';
const apiResponse = await supertest.get(
`/api/uptime/ping/histogram?dateStart=${dateStart}&dateEnd=${dateEnd}`
);
const apiResponse = await supertest.get(API_URLS.PING_HISTOGRAM).query({
dateStart,
dateEnd,
});
const data = apiResponse.body;
expectFixtureEql(data, 'ping_histogram');
@ -29,9 +31,11 @@ export default function ({ getService }: FtrProviderContext) {
const dateEnd = '2019-09-11T03:40:34.410Z';
const monitorId = '0002-up';
const apiResponse = await supertest.get(
`/api/uptime/ping/histogram?monitorId=${monitorId}&dateStart=${dateStart}&dateEnd=${dateEnd}`
);
const apiResponse = await supertest.get(API_URLS.PING_HISTOGRAM).query({
monitorId,
dateStart,
dateEnd,
});
const data = apiResponse.body;
expectFixtureEql(data, 'ping_histogram_by_id');
@ -43,9 +47,11 @@ export default function ({ getService }: FtrProviderContext) {
const filters =
'{"bool":{"must":[{"match":{"monitor.status":{"query":"up","operator":"and"}}}]}}';
const apiResponse = await supertest.get(
`/api/uptime/ping/histogram?dateStart=${dateStart}&dateEnd=${dateEnd}&filters=${filters}`
);
const apiResponse = await supertest.get(API_URLS.PING_HISTOGRAM).query({
dateStart,
dateEnd,
filters,
});
const data = apiResponse.body;
expectFixtureEql(data, 'ping_histogram_by_filter');

View file

@ -10,6 +10,7 @@ import { isLeft } from 'fp-ts/lib/Either';
import { PathReporter } from 'io-ts/lib/PathReporter';
import { PingsResponseType } from '../../../../../plugins/uptime/common/runtime_types';
import { FtrProviderContext } from '../../../ftr_provider_context';
import { API_URLS } from '../../../../../plugins/uptime/common/constants';
function decodePingsResponseData(response: any) {
const decoded = PingsResponseType.decode(response);
@ -33,7 +34,11 @@ export default function ({ getService }: FtrProviderContext) {
const from = '2019-01-28T17:40:08.078Z';
const to = '2025-01-28T19:00:16.078Z';
const apiResponse = await supertest.get(`/api/uptime/pings?from=${from}&to=${to}&size=10`);
const apiResponse = await supertest.get(API_URLS.PINGS).query({
from,
to,
size: 10,
});
const { total, pings } = decodePingsResponseData(apiResponse.body);
@ -58,9 +63,11 @@ export default function ({ getService }: FtrProviderContext) {
const to = '2025-01-28T19:00:16.078Z';
const size = 50;
const apiResponse = await supertest.get(
`/api/uptime/pings?from=${from}&to=${to}&size=${size}`
);
const apiResponse = await supertest.get(API_URLS.PINGS).query({
from,
to,
size,
});
const { total, pings } = decodePingsResponseData(apiResponse.body);
@ -126,9 +133,12 @@ export default function ({ getService }: FtrProviderContext) {
const monitorId = '0001-up';
const size = 15;
const apiResponse = await supertest.get(
`/api/uptime/pings?from=${from}&to=${to}&monitorId=${monitorId}&size=${size}`
);
const apiResponse = await supertest.get(API_URLS.PINGS).query({
from,
to,
monitorId,
size,
});
const { total, pings } = decodePingsResponseData(apiResponse.body);
@ -160,9 +170,13 @@ export default function ({ getService }: FtrProviderContext) {
const size = 5;
const sort = 'asc';
const apiResponse = await supertest.get(
`/api/uptime/pings?from=${from}&to=${to}&monitorId=${monitorId}&size=${size}&sort=${sort}`
);
const apiResponse = await supertest.get(API_URLS.PINGS).query({
from,
to,
monitorId,
size,
sort,
});
const { total, pings } = decodePingsResponseData(apiResponse.body);

View file

@ -8,6 +8,7 @@
import { expectFixtureEql } from './helper/expect_fixture_eql';
import { FtrProviderContext } from '../../../ftr_provider_context';
import { makeChecksWithStatus, getChecksDateRange } from './helper/make_checks';
import { API_URLS } from '../../../../../plugins/uptime/common/constants';
export default function ({ getService }: FtrProviderContext) {
const supertest = getService('supertest');
@ -18,9 +19,10 @@ export default function ({ getService }: FtrProviderContext) {
describe('when no data is present', async () => {
it('returns a null snapshot', async () => {
const apiResponse = await supertest.get(
`/api/uptime/snapshot/count?dateRangeStart=${dateRangeStart}&dateRangeEnd=${dateRangeEnd}`
);
const apiResponse = await supertest.get(API_URLS.SNAPSHOT_COUNT).query({
dateRangeStart,
dateRangeEnd,
});
expectFixtureEql(apiResponse.body, 'snapshot_empty');
});
@ -75,9 +77,10 @@ export default function ({ getService }: FtrProviderContext) {
});
it('will count all statuses correctly', async () => {
const apiResponse = await supertest.get(
`/api/uptime/snapshot/count?dateRangeStart=${dateRange.start}&dateRangeEnd=${dateRange.end}`
);
const apiResponse = await supertest.get(API_URLS.SNAPSHOT_COUNT).query({
dateRangeStart: dateRange.start,
dateRangeEnd: dateRange.end,
});
expectFixtureEql(apiResponse.body, 'snapshot');
});

View file

@ -14,9 +14,11 @@ export default function rumServicesApiTests({ getService }: FtrProviderContext)
registry.when('CSM Services without data', { config: 'trial', archives: [] }, () => {
it('returns empty list', async () => {
const response = await supertest.get(
'/api/apm/rum-client/services?start=2020-06-28T10%3A24%3A46.055Z&end=2020-07-29T10%3A24%3A46.055Z&uiFilters=%7B%22agentName%22%3A%5B%22js-base%22%2C%22rum-js%22%5D%7D'
);
const response = await supertest.get('/internal/apm/ux/services').query({
start: '2020-06-28T10:24:46.055Z',
end: '2020-07-29T10:24:46.055Z',
uiFilters: '{"agentName":["js-base","rum-js"]}',
});
expect(response.status).to.be(200);
expect(response.body.rumServices).to.eql([]);
@ -28,9 +30,11 @@ export default function rumServicesApiTests({ getService }: FtrProviderContext)
{ config: 'trial', archives: ['8.0.0', 'rum_8.0.0'] },
() => {
it('returns rum services list', async () => {
const response = await supertest.get(
'/api/apm/rum-client/services?start=2020-06-28T10%3A24%3A46.055Z&end=2020-07-29T10%3A24%3A46.055Z&uiFilters=%7B%22agentName%22%3A%5B%22js-base%22%2C%22rum-js%22%5D%7D'
);
const response = await supertest.get('/internal/apm/ux/services').query({
start: '2020-06-28T10:24:46.055Z',
end: '2020-07-29T10:24:46.055Z',
uiFilters: '{"agentName":["js-base","rum-js"]}',
});
expect(response.status).to.be(200);

View file

@ -14,9 +14,13 @@ export default function rumJsErrorsApiTests({ getService }: FtrProviderContext)
registry.when('CSM JS errors with data', { config: 'trial', archives: [] }, () => {
it('returns no js errors', async () => {
const response = await supertest.get(
'/api/apm/rum-client/js-errors?pageSize=5&pageIndex=0&start=2020-09-07T20%3A35%3A54.654Z&end=2020-09-14T20%3A35%3A54.654Z&uiFilters=%7B%22serviceName%22%3A%5B%22elastic-co-rum-test%22%5D%7D'
);
const response = await supertest.get('/internal/apm/ux/js-errors').query({
pageSize: 5,
pageIndex: 0,
start: '2020-09-07T20:35:54.654Z',
end: '2020-09-14T20:35:54.654Z',
uiFilters: '{"serviceName":["elastic-co-rum-test"]}',
});
expect(response.status).to.be(200);
expectSnapshot(response.body).toMatchInline(`
@ -34,9 +38,13 @@ export default function rumJsErrorsApiTests({ getService }: FtrProviderContext)
{ config: 'trial', archives: ['8.0.0', 'rum_test_data'] },
() => {
it('returns js errors', async () => {
const response = await supertest.get(
'/api/apm/rum-client/js-errors?start=2021-01-18T12%3A20%3A17.202Z&end=2021-01-18T12%3A25%3A17.203Z&uiFilters=%7B%22environment%22%3A%22ENVIRONMENT_ALL%22%2C%22serviceName%22%3A%5B%22elastic-co-frontend%22%5D%7D&pageSize=5&pageIndex=0'
);
const response = await supertest.get('/internal/apm/ux/js-errors').query({
start: '2021-01-18T12:20:17.202Z',
end: '2021-01-18T12:25:17.203Z',
uiFilters: '{"environment":"ENVIRONMENT_ALL","serviceName":["elastic-co-frontend"]}',
pageSize: 5,
pageIndex: 0,
});
expect(response.status).to.be(200);

View file

@ -14,9 +14,11 @@ export default function rumServicesApiTests({ getService }: FtrProviderContext)
registry.when('CSM long task metrics without data', { config: 'trial', archives: [] }, () => {
it('returns empty list', async () => {
const response = await supertest.get(
'/api/apm/rum-client/long-task-metrics?start=2020-09-07T20%3A35%3A54.654Z&end=2020-09-14T20%3A35%3A54.654Z&uiFilters=%7B%22serviceName%22%3A%5B%22elastic-co-rum-test%22%5D%7D'
);
const response = await supertest.get('/internal/apm/ux/long-task-metrics').query({
start: '2020-09-07T20:35:54.654Z',
end: '2020-09-14T20:35:54.654Z',
uiFilters: '{"serviceName":["elastic-co-rum-test"]}',
});
expect(response.status).to.be(200);
expect(response.body).to.eql({
@ -32,9 +34,11 @@ export default function rumServicesApiTests({ getService }: FtrProviderContext)
{ config: 'trial', archives: ['8.0.0', 'rum_8.0.0'] },
() => {
it('returns web core vitals values', async () => {
const response = await supertest.get(
'/api/apm/rum-client/long-task-metrics?start=2020-09-07T20%3A35%3A54.654Z&end=2020-09-16T20%3A35%3A54.654Z&uiFilters=%7B%22serviceName%22%3A%5B%22kibana-frontend-8_0_0%22%5D%7D'
);
const response = await supertest.get('/internal/apm/ux/long-task-metrics').query({
start: '2020-09-07T20:35:54.654Z',
end: '2020-09-16T20:35:54.654Z',
uiFilters: '{"serviceName":["kibana-frontend-8_0_0"]}',
});
expect(response.status).to.be(200);

View file

@ -14,18 +14,25 @@ export default function rumServicesApiTests({ getService }: FtrProviderContext)
registry.when('UX page load dist without data', { config: 'trial', archives: [] }, () => {
it('returns empty list', async () => {
const response = await supertest.get(
'/api/apm/rum-client/page-load-distribution?start=2020-09-07T20%3A35%3A54.654Z&end=2020-09-14T20%3A35%3A54.654Z&uiFilters=%7B%22serviceName%22%3A%5B%22elastic-co-rum-test%22%5D%7D'
);
const response = await supertest.get('/internal/apm/ux/page-load-distribution').query({
start: '2020-09-07T20:35:54.654Z',
end: '2020-09-14T20:35:54.654Z',
uiFilters: '{"serviceName":["elastic-co-rum-test"]}',
});
expect(response.status).to.be(200);
expectSnapshot(response.body).toMatch();
});
it('returns empty list with breakdowns', async () => {
const response = await supertest.get(
'/api/apm/rum-client/page-load-distribution/breakdown?start=2020-09-07T20%3A35%3A54.654Z&end=2020-09-14T20%3A35%3A54.654Z&uiFilters=%7B%22serviceName%22%3A%5B%22elastic-co-rum-test%22%5D%7D&breakdown=Browser'
);
const response = await supertest
.get('/internal/apm/ux/page-load-distribution/breakdown')
.query({
start: '2020-09-07T20:35:54.654Z',
end: '2020-09-14T20:35:54.654Z',
uiFilters: '{"serviceName":["elastic-co-rum-test"]}',
breakdown: 'Browser',
});
expect(response.status).to.be(200);
expectSnapshot(response.body).toMatch();
@ -37,18 +44,25 @@ export default function rumServicesApiTests({ getService }: FtrProviderContext)
{ config: 'trial', archives: ['8.0.0', 'rum_8.0.0'] },
() => {
it('returns page load distribution', async () => {
const response = await supertest.get(
'/api/apm/rum-client/page-load-distribution?start=2020-09-07T20%3A35%3A54.654Z&end=2020-09-16T20%3A35%3A54.654Z&uiFilters=%7B%22serviceName%22%3A%5B%22kibana-frontend-8_0_0%22%5D%7D'
);
const response = await supertest.get('/internal/apm/ux/page-load-distribution').query({
start: '2020-09-07T20:35:54.654Z',
end: '2020-09-16T20:35:54.654Z',
uiFilters: '{"serviceName":["kibana-frontend-8_0_0"]}',
});
expect(response.status).to.be(200);
expectSnapshot(response.body).toMatch();
});
it('returns page load distribution with breakdown', async () => {
const response = await supertest.get(
'/api/apm/rum-client/page-load-distribution/breakdown?start=2020-09-07T20%3A35%3A54.654Z&end=2020-09-16T20%3A35%3A54.654Z&uiFilters=%7B%22serviceName%22%3A%5B%22kibana-frontend-8_0_0%22%5D%7D&breakdown=Browser'
);
const response = await supertest
.get('/internal/apm/ux/page-load-distribution/breakdown')
.query({
start: '2020-09-07T20:35:54.654Z',
end: '2020-09-16T20:35:54.654Z',
uiFilters: '{"serviceName":["kibana-frontend-8_0_0"]}',
breakdown: 'Browser',
});
expect(response.status).to.be(200);

View file

@ -14,18 +14,23 @@ export default function rumServicesApiTests({ getService }: FtrProviderContext)
registry.when('CSM page views without data', { config: 'trial', archives: [] }, () => {
it('returns empty list', async () => {
const response = await supertest.get(
'/api/apm/rum-client/page-view-trends?start=2020-09-07T20%3A35%3A54.654Z&end=2020-09-14T20%3A35%3A54.654Z&uiFilters=%7B%22serviceName%22%3A%5B%22elastic-co-rum-test%22%5D%7D'
);
const response = await supertest.get('/internal/apm/ux/page-view-trends').query({
start: '2020-09-07T20:35:54.654Z',
end: '2020-09-14T20:35:54.654Z',
uiFilters: '{"serviceName":["elastic-co-rum-test"]}',
});
expect(response.status).to.be(200);
expectSnapshot(response.body).toMatch();
});
it('returns empty list with breakdowns', async () => {
const response = await supertest.get(
'/api/apm/rum-client/page-view-trends?start=2020-09-07T20%3A35%3A54.654Z&end=2020-09-14T20%3A35%3A54.654Z&uiFilters=%7B%22serviceName%22%3A%5B%22elastic-co-rum-test%22%5D%7D&breakdowns=%7B%22name%22%3A%22Browser%22%2C%22fieldName%22%3A%22user_agent.name%22%2C%22type%22%3A%22category%22%7D'
);
const response = await supertest.get('/internal/apm/ux/page-view-trends').query({
start: '2020-09-07T20:35:54.654Z',
end: '2020-09-14T20:35:54.654Z',
uiFilters: '{"serviceName":["elastic-co-rum-test"]}',
breakdowns: '{"name":"Browser","fieldName":"user_agent.name","type":"category"}',
});
expect(response.status).to.be(200);
expectSnapshot(response.body).toMatch();
@ -37,18 +42,23 @@ export default function rumServicesApiTests({ getService }: FtrProviderContext)
{ config: 'trial', archives: ['8.0.0', 'rum_8.0.0'] },
() => {
it('returns page views', async () => {
const response = await supertest.get(
'/api/apm/rum-client/page-view-trends?start=2020-09-07T20%3A35%3A54.654Z&end=2020-09-16T20%3A35%3A54.654Z&uiFilters=%7B%22serviceName%22%3A%5B%22kibana-frontend-8_0_0%22%5D%7D'
);
const response = await supertest.get('/internal/apm/ux/page-view-trends').query({
start: '2020-09-07T20:35:54.654Z',
end: '2020-09-16T20:35:54.654Z',
uiFilters: '{"serviceName":["kibana-frontend-8_0_0"]}',
});
expect(response.status).to.be(200);
expectSnapshot(response.body).toMatch();
});
it('returns page views with breakdown', async () => {
const response = await supertest.get(
'/api/apm/rum-client/page-view-trends?start=2020-09-07T20%3A35%3A54.654Z&end=2020-09-16T20%3A35%3A54.654Z&uiFilters=%7B%22serviceName%22%3A%5B%22kibana-frontend-8_0_0%22%5D%7D&breakdowns=%7B%22name%22%3A%22Browser%22%2C%22fieldName%22%3A%22user_agent.name%22%2C%22type%22%3A%22category%22%7D'
);
const response = await supertest.get('/internal/apm/ux/page-view-trends').query({
start: '2020-09-07T20:35:54.654Z',
end: '2020-09-16T20:35:54.654Z',
uiFilters: '{"serviceName":["kibana-frontend-8_0_0"]}',
breakdowns: '{"name":"Browser","fieldName":"user_agent.name","type":"category"}',
});
expect(response.status).to.be(200);

View file

@ -14,9 +14,12 @@ export default function rumServicesApiTests({ getService }: FtrProviderContext)
registry.when('CSM url search api without data', { config: 'trial', archives: [] }, () => {
it('returns empty list', async () => {
const response = await supertest.get(
'/api/apm/rum-client/url-search?start=2020-09-07T20%3A35%3A54.654Z&end=2020-09-14T20%3A35%3A54.654Z&uiFilters=%7B%22serviceName%22%3A%5B%22elastic-co-rum-test%22%5D%7D&percentile=50'
);
const response = await supertest.get('/internal/apm/ux/url-search').query({
start: '2020-09-07T20:35:54.654Z',
end: '2020-09-14T20:35:54.654Z',
uiFilters: '{"serviceName":["elastic-co-rum-test"]}',
percentile: 50,
});
expect(response.status).to.be(200);
expectSnapshot(response.body).toMatchInline(`
@ -33,9 +36,12 @@ export default function rumServicesApiTests({ getService }: FtrProviderContext)
{ config: 'trial', archives: ['8.0.0', 'rum_8.0.0'] },
() => {
it('returns top urls when no query', async () => {
const response = await supertest.get(
'/api/apm/rum-client/url-search?start=2020-09-07T20%3A35%3A54.654Z&end=2020-09-16T20%3A35%3A54.654Z&uiFilters=%7B%22serviceName%22%3A%5B%22kibana-frontend-8_0_0%22%5D%7D&percentile=50'
);
const response = await supertest.get('/internal/apm/ux/url-search').query({
start: '2020-09-07T20:35:54.654Z',
end: '2020-09-16T20:35:54.654Z',
uiFilters: '{"serviceName":["kibana-frontend-8_0_0"]}',
percentile: 50,
});
expect(response.status).to.be(200);
@ -59,9 +65,13 @@ export default function rumServicesApiTests({ getService }: FtrProviderContext)
});
it('returns specific results against query', async () => {
const response = await supertest.get(
'/api/apm/rum-client/url-search?start=2020-09-07T20%3A35%3A54.654Z&end=2020-09-16T20%3A35%3A54.654Z&uiFilters=%7B%22serviceName%22%3A%5B%22kibana-frontend-8_0_0%22%5D%7D&urlQuery=csm&percentile=50'
);
const response = await supertest.get('/internal/apm/ux/url-search').query({
start: '2020-09-07T20:35:54.654Z',
end: '2020-09-16T20:35:54.654Z',
uiFilters: '{"serviceName":["kibana-frontend-8_0_0"]}',
urlQuery: 'csm',
percentile: 50,
});
expect(response.status).to.be(200);

View file

@ -14,9 +14,12 @@ export default function rumServicesApiTests({ getService }: FtrProviderContext)
registry.when('CSM web core vitals without data', { config: 'trial', archives: [] }, () => {
it('returns empty list', async () => {
const response = await supertest.get(
'/api/apm/rum-client/web-core-vitals?start=2020-09-07T20%3A35%3A54.654Z&end=2020-09-14T20%3A35%3A54.654Z&uiFilters=%7B%22serviceName%22%3A%5B%22elastic-co-rum-test%22%5D%7D&percentile=50'
);
const response = await supertest.get('/internal/apm/ux/web-core-vitals').query({
start: '2020-09-07T20:35:54.654Z',
end: '2020-09-14T20:35:54.654Z',
uiFilters: '{"serviceName":["elastic-co-rum-test"]}',
percentile: 50,
});
expect(response.status).to.be(200);
expect(response.body).to.eql({
@ -35,9 +38,12 @@ export default function rumServicesApiTests({ getService }: FtrProviderContext)
{ config: 'trial', archives: ['8.0.0', 'rum_8.0.0'] },
() => {
it('returns web core vitals values', async () => {
const response = await supertest.get(
'/api/apm/rum-client/web-core-vitals?start=2020-09-07T20%3A35%3A54.654Z&end=2020-09-16T20%3A35%3A54.654Z&uiFilters=%7B%22serviceName%22%3A%5B%22kibana-frontend-8_0_0%22%5D%7D&percentile=50'
);
const response = await supertest.get('/internal/apm/ux/web-core-vitals').query({
start: '2020-09-07T20:35:54.654Z',
end: '2020-09-16T20:35:54.654Z',
uiFilters: '{"serviceName":["kibana-frontend-8_0_0"]}',
percentile: 50,
});
expect(response.status).to.be(200);