Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Synthetics] Adds additional heartbeat configuration options to the Synthetics app #154390

Merged
Show file tree
Hide file tree
Changes from 35 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
98e7748
add mode to http monitors
dominiqueclarke Apr 4, 2023
58b4817
adjust tests
dominiqueclarke Apr 4, 2023
229076e
add mode to icmp and tcp monitors
dominiqueclarke Apr 4, 2023
cb41e21
add response.include_body_max_bytes to http monitors
dominiqueclarke Apr 4, 2023
54789cc
adjust types
dominiqueclarke Apr 4, 2023
871995f
adjust tests
dominiqueclarke Apr 4, 2023
44dd5e2
add ipv4 and ipv6 configs
dominiqueclarke Apr 5, 2023
9144a91
adjust tests
dominiqueclarke Apr 5, 2023
6e72e22
Merge branch 'main' of github.com:elastic/kibana into feat/synthetics…
dominiqueclarke Apr 5, 2023
431a4c2
add monitor proxy headers
dominiqueclarke Apr 5, 2023
4f41b0c
handle converting response_body_max_bytes to a string
dominiqueclarke Apr 5, 2023
cecf870
Merge branch 'main' into feat/synthetics-add-extra-heartbeat-configs
dominiqueclarke Apr 5, 2023
57aac3c
Merge branch 'main' of github.com:elastic/kibana into feat/synthetics…
dominiqueclarke Apr 5, 2023
0f77230
Merge branch 'main' of github.com:elastic/kibana into feat/synthetics…
dominiqueclarke Apr 5, 2023
6d2c734
add response check json to http monitor
dominiqueclarke Apr 5, 2023
4ce77ce
Merge branch 'feat/synthetics-add-extra-heartbeat-configs' of https:/…
dominiqueclarke Apr 5, 2023
3e165ad
adjust tests
dominiqueclarke Apr 5, 2023
26a53ed
add test
dominiqueclarke Apr 5, 2023
39cce02
adjust test for private locations
dominiqueclarke Apr 6, 2023
99c5d45
adjust tests to account for private locations
dominiqueclarke Apr 6, 2023
c049e1d
adjust field config
dominiqueclarke Apr 6, 2023
e9b11fc
Merge branch 'main' into feat/synthetics-add-extra-heartbeat-configs
dominiqueclarke Apr 11, 2023
c3a9cf1
Merge branch 'main' into feat/synthetics-add-extra-heartbeat-configs
kibanamachine Apr 11, 2023
510dbf0
merge upstream
dominiqueclarke Apr 11, 2023
74d9c66
Merge branch 'feat/synthetics-add-extra-heartbeat-configs' of https:/…
dominiqueclarke Apr 11, 2023
26e38d4
Merge branch 'main' into feat/synthetics-add-extra-heartbeat-configs
dominiqueclarke Apr 11, 2023
b185cb7
Update x-pack/plugins/synthetics/public/apps/synthetics/components/mo…
dominiqueclarke Apr 12, 2023
60a8544
Update x-pack/plugins/synthetics/public/apps/synthetics/components/mo…
dominiqueclarke Apr 12, 2023
4d68099
Update x-pack/plugins/synthetics/public/apps/synthetics/components/mo…
dominiqueclarke Apr 12, 2023
8f9b1c9
Update x-pack/plugins/synthetics/public/apps/synthetics/components/mo…
dominiqueclarke Apr 12, 2023
d47a045
linting
dominiqueclarke Apr 12, 2023
00681b8
adjust content
dominiqueclarke Apr 12, 2023
0abea88
Update x-pack/plugins/synthetics/public/apps/synthetics/components/mo…
shahzad31 Apr 17, 2023
cb3fd7d
Merge branch 'main' into feat/synthetics-add-extra-heartbeat-configs
shahzad31 Apr 17, 2023
85496a9
Merge branch 'main' into feat/synthetics-add-extra-heartbeat-configs
shahzad31 Apr 18, 2023
1d3b7f7
merge upstream
dominiqueclarke Apr 25, 2023
41fb842
adjust content
dominiqueclarke Apr 25, 2023
5407fcf
Merge branch 'feat/synthetics-add-extra-heartbeat-configs' of https:/…
dominiqueclarke Apr 25, 2023
2846868
Update x-pack/plugins/synthetics/public/apps/synthetics/components/mo…
dominiqueclarke Apr 25, 2023
23fb494
Update x-pack/plugins/synthetics/public/apps/synthetics/components/mo…
dominiqueclarke Apr 25, 2023
a793568
adjust tests
dominiqueclarke Apr 25, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion x-pack/plugins/synthetics/common/constants/monitor_defaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* 2.0.
*/
import {
CodeEditorMode,
BrowserAdvancedFields,
BrowserSimpleFields,
CommonFields,
Expand Down Expand Up @@ -118,19 +119,25 @@ export const DEFAULT_HTTP_SIMPLE_FIELDS: HTTPSimpleFields = {
export const DEFAULT_HTTP_ADVANCED_FIELDS: HTTPAdvancedFields = {
[ConfigKey.PASSWORD]: '',
[ConfigKey.PROXY_URL]: '',
[ConfigKey.PROXY_HEADERS]: {},
[ConfigKey.RESPONSE_BODY_CHECK_NEGATIVE]: [],
[ConfigKey.RESPONSE_BODY_CHECK_POSITIVE]: [],
[ConfigKey.RESPONSE_JSON_CHECK]: [],
[ConfigKey.RESPONSE_BODY_INDEX]: ResponseBodyIndexPolicy.ON_ERROR,
[ConfigKey.RESPONSE_HEADERS_CHECK]: {},
[ConfigKey.RESPONSE_HEADERS_INDEX]: true,
[ConfigKey.RESPONSE_STATUS_CHECK]: [],
[ConfigKey.REQUEST_BODY_CHECK]: {
value: '',
type: Mode.PLAINTEXT,
type: CodeEditorMode.PLAINTEXT,
},
[ConfigKey.REQUEST_HEADERS_CHECK]: {},
[ConfigKey.REQUEST_METHOD_CHECK]: HTTPMethod.GET,
[ConfigKey.USERNAME]: '',
[ConfigKey.MODE]: Mode.ANY,
[ConfigKey.RESPONSE_BODY_MAX_BYTES]: '1024',
[ConfigKey.IPV4]: true,
[ConfigKey.IPV6]: true,
};

export const DEFAULT_ICMP_SIMPLE_FIELDS: ICMPSimpleFields = {
Expand Down Expand Up @@ -158,6 +165,15 @@ export const DEFAULT_TCP_ADVANCED_FIELDS: TCPAdvancedFields = {
[ConfigKey.PROXY_USE_LOCAL_RESOLVER]: false,
[ConfigKey.RESPONSE_RECEIVE_CHECK]: '',
[ConfigKey.REQUEST_SEND_CHECK]: '',
[ConfigKey.MODE]: Mode.ANY,
[ConfigKey.IPV4]: true,
[ConfigKey.IPV6]: true,
};

export const DEFAULT_ICMP_ADVANCED_FIELDS = {
[ConfigKey.MODE]: Mode.ANY,
[ConfigKey.IPV4]: true,
[ConfigKey.IPV6]: true,
};

export const DEFAULT_TLS_FIELDS: TLSFields = {
Expand All @@ -182,6 +198,7 @@ export const DEFAULT_FIELDS: MonitorDefaults = {
},
[DataStream.ICMP]: {
...DEFAULT_ICMP_SIMPLE_FIELDS,
...DEFAULT_ICMP_ADVANCED_FIELDS,
},
[DataStream.BROWSER]: {
...DEFAULT_BROWSER_SIMPLE_FIELDS,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export enum ConfigKey {
JOURNEY_ID = 'journey_id',
MAX_REDIRECTS = 'max_redirects',
METADATA = '__ui',
MODE = 'mode',
MONITOR_TYPE = 'type',
NAME = 'name',
NAMESPACE = 'namespace',
Expand All @@ -37,12 +38,15 @@ export enum ConfigKey {
ORIGINAL_SPACE = 'original_space', // the original space the montior was saved in. Used by push monitors to ensure uniqueness of monitor id sent to heartbeat and prevent data collisions
PORT = 'url.port',
PROXY_URL = 'proxy_url',
PROXY_HEADERS = 'proxy_headers',
PROXY_USE_LOCAL_RESOLVER = 'proxy_use_local_resolver',
RESPONSE_BODY_CHECK_NEGATIVE = 'check.response.body.negative',
RESPONSE_BODY_CHECK_POSITIVE = 'check.response.body.positive',
RESPONSE_JSON_CHECK = 'check.response.json',
RESPONSE_BODY_INDEX = 'response.include_body',
RESPONSE_HEADERS_CHECK = 'check.response.headers',
RESPONSE_HEADERS_INDEX = 'response.include_headers',
RESPONSE_BODY_MAX_BYTES = 'response.include_body_max_bytes',
RESPONSE_RECEIVE_CHECK = 'check.receive',
RESPONSE_STATUS_CHECK = 'check.response.status',
REQUEST_BODY_CHECK = 'check.request.body',
Expand All @@ -67,6 +71,8 @@ export enum ConfigKey {
TIMEOUT = 'timeout',
THROTTLING_CONFIG = 'throttling.config',
IS_THROTTLING_ENABLED = 'throttling.is_enabled',
IPV4 = 'ipv4',
IPV6 = 'ipv6',
DOWNLOAD_SPEED = 'throttling.download_speed',
UPLOAD_SPEED = 'throttling.upload_speed',
LATENCY = 'throttling.latency',
Expand All @@ -77,13 +83,15 @@ export enum ConfigKey {
}

export const secretKeys = [
ConfigKey.PROXY_HEADERS,
ConfigKey.PARAMS,
ConfigKey.PASSWORD,
ConfigKey.REQUEST_BODY_CHECK,
ConfigKey.REQUEST_HEADERS_CHECK,
ConfigKey.REQUEST_SEND_CHECK,
ConfigKey.RESPONSE_BODY_CHECK_NEGATIVE,
ConfigKey.RESPONSE_BODY_CHECK_POSITIVE,
ConfigKey.RESPONSE_JSON_CHECK,
ConfigKey.RESPONSE_HEADERS_CHECK,
ConfigKey.RESPONSE_RECEIVE_CHECK,
ConfigKey.SOURCE_INLINE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,22 @@ export const httpFormatters: HTTPFormatMap = {
[ConfigKey.USERNAME]: null,
[ConfigKey.PASSWORD]: null,
[ConfigKey.PROXY_URL]: null,
[ConfigKey.PROXY_HEADERS]: objectToJsonFormatter,
[ConfigKey.PORT]: null,
[ConfigKey.RESPONSE_BODY_CHECK_NEGATIVE]: arrayToJsonFormatter,
[ConfigKey.RESPONSE_BODY_CHECK_POSITIVE]: arrayToJsonFormatter,
[ConfigKey.RESPONSE_JSON_CHECK]: arrayToJsonFormatter,
[ConfigKey.RESPONSE_HEADERS_CHECK]: objectToJsonFormatter,
[ConfigKey.RESPONSE_STATUS_CHECK]: arrayToJsonFormatter,
[ConfigKey.REQUEST_HEADERS_CHECK]: objectToJsonFormatter,
[ConfigKey.REQUEST_BODY_CHECK]: (fields) =>
fields[ConfigKey.REQUEST_BODY_CHECK]?.value
? JSON.stringify(fields[ConfigKey.REQUEST_BODY_CHECK]?.value)
: null,
[ConfigKey.RESPONSE_BODY_MAX_BYTES]: null,
[ConfigKey.MODE]: null,
[ConfigKey.IPV4]: null,
[ConfigKey.IPV6]: null,
...tlsFormatters,
...commonFormatters,
};
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,8 @@ export type ICMPFormatMap = Record<keyof ICMPFields, Formatter>;
export const icmpFormatters: ICMPFormatMap = {
[ConfigKey.HOSTS]: null,
[ConfigKey.WAIT]: secondsToCronFormatter,
[ConfigKey.MODE]: null,
[ConfigKey.IPV4]: null,
[ConfigKey.IPV6]: null,
...commonFormatters,
};
3 changes: 3 additions & 0 deletions x-pack/plugins/synthetics/common/formatters/tcp/formatters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ export const tcpFormatters: TCPFormatMap = {
[ConfigKey.PROXY_URL]: null,
[ConfigKey.PORT]: null,
[ConfigKey.URLS]: null,
[ConfigKey.MODE]: null,
[ConfigKey.IPV4]: null,
[ConfigKey.IPV6]: null,
...tlsFormatters,
...commonFormatters,
};
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,15 @@ export const MonacoEditorLangIdCodec = tEnum<MonacoEditorLangId>(
);
export type MonacoEditorLangIdType = t.TypeOf<typeof MonacoEditorLangIdCodec>;

export enum Mode {
export enum CodeEditorMode {
FORM = 'form',
JSON = 'json',
PLAINTEXT = 'text',
XML = 'xml',
}

export const ModeCodec = tEnum<Mode>('Mode', Mode);
export type ModeType = t.TypeOf<typeof ModeCodec>;
export const CodeEditorModeCodec = tEnum<CodeEditorMode>('CodeEditorMode', CodeEditorMode);
export type CodeEditorModeType = t.TypeOf<typeof CodeEditorModeCodec>;

export enum ContentType {
JSON = 'application/json',
Expand Down Expand Up @@ -136,3 +136,16 @@ export enum FormMonitorType {
}

export const FormMonitorTypeCodec = tEnum<FormMonitorType>('FormMonitorType', FormMonitorType);

export enum Mode {
ANY = 'any',
ALL = 'all',
}
export const ModeCodec = tEnum<Mode>('Mode', Mode);
export type ModeType = t.TypeOf<typeof ModeCodec>;

export const ResponseCheckJSONCodec = t.interface({
description: t.string,
expression: t.string,
});
export type ResponseCheckJSON = t.TypeOf<typeof ResponseCheckJSONCodec>;
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@ import { secretKeys } from '../../constants/monitor_management';
import { ConfigKey } from './config_key';
import { MonitorServiceLocationCodec, ServiceLocationErrors } from './locations';
import {
CodeEditorModeCodec,
DataStream,
DataStreamCodec,
FormMonitorTypeCodec,
ModeCodec,
ResponseBodyIndexPolicyCodec,
ResponseCheckJSONCodec,
ScheduleUnitCodec,
SourceTypeCodec,
TLSVersionCodec,
Expand Down Expand Up @@ -94,10 +96,17 @@ export const TCPSimpleFieldsCodec = t.intersection([
export type TCPSimpleFields = t.TypeOf<typeof TCPSimpleFieldsCodec>;

// TCPAdvancedFields
export const TCPAdvancedFieldsCodec = t.interface({
[ConfigKey.PROXY_URL]: t.string,
[ConfigKey.PROXY_USE_LOCAL_RESOLVER]: t.boolean,
});
export const TCPAdvancedFieldsCodec = t.intersection([
t.interface({
[ConfigKey.PROXY_URL]: t.string,
[ConfigKey.PROXY_USE_LOCAL_RESOLVER]: t.boolean,
}),
t.partial({
[ConfigKey.MODE]: ModeCodec,
[ConfigKey.IPV4]: t.boolean,
[ConfigKey.IPV6]: t.boolean,
}),
]);

export const TCPSensitiveAdvancedFieldsCodec = t.interface({
[ConfigKey.RESPONSE_RECEIVE_CHECK]: t.string,
Expand Down Expand Up @@ -136,7 +145,18 @@ export const ICMPSimpleFieldsCodec = t.intersection([
]);

export type ICMPSimpleFields = t.TypeOf<typeof ICMPSimpleFieldsCodec>;
export type ICMPFields = t.TypeOf<typeof ICMPSimpleFieldsCodec>;

// ICMPAdvancedFields
export const ICMPAdvancedFieldsCodec = t.partial({
[ConfigKey.MODE]: ModeCodec,
[ConfigKey.IPV4]: t.boolean,
[ConfigKey.IPV6]: t.boolean,
});

// ICMPFields
export const ICMPFieldsCodec = t.intersection([ICMPSimpleFieldsCodec, ICMPAdvancedFieldsCodec]);

export type ICMPFields = t.TypeOf<typeof ICMPFieldsCodec>;

// HTTPSimpleFields
export const HTTPSimpleFieldsCodec = t.intersection([
Expand All @@ -152,23 +172,37 @@ export const HTTPSimpleFieldsCodec = t.intersection([
export type HTTPSimpleFields = t.TypeOf<typeof HTTPSimpleFieldsCodec>;

// HTTPAdvancedFields
export const HTTPAdvancedFieldsCodec = t.interface({
[ConfigKey.PROXY_URL]: t.string,
[ConfigKey.RESPONSE_BODY_INDEX]: ResponseBodyIndexPolicyCodec,
[ConfigKey.RESPONSE_HEADERS_INDEX]: t.boolean,
[ConfigKey.RESPONSE_STATUS_CHECK]: t.array(t.string),
[ConfigKey.REQUEST_METHOD_CHECK]: t.string,
});
export const HTTPAdvancedFieldsCodec = t.intersection([
t.interface({
[ConfigKey.PROXY_URL]: t.string,
[ConfigKey.RESPONSE_BODY_INDEX]: ResponseBodyIndexPolicyCodec,
[ConfigKey.RESPONSE_HEADERS_INDEX]: t.boolean,
[ConfigKey.RESPONSE_STATUS_CHECK]: t.array(t.string),
[ConfigKey.REQUEST_METHOD_CHECK]: t.string,
}),
t.partial({
[ConfigKey.MODE]: ModeCodec,
[ConfigKey.RESPONSE_BODY_MAX_BYTES]: t.string,
[ConfigKey.IPV4]: t.boolean,
[ConfigKey.IPV6]: t.boolean,
}),
]);

export const HTTPSensitiveAdvancedFieldsCodec = t.interface({
[ConfigKey.PASSWORD]: t.string,
[ConfigKey.RESPONSE_BODY_CHECK_NEGATIVE]: t.array(t.string),
[ConfigKey.RESPONSE_BODY_CHECK_POSITIVE]: t.array(t.string),
[ConfigKey.RESPONSE_HEADERS_CHECK]: t.record(t.string, t.string),
[ConfigKey.REQUEST_BODY_CHECK]: t.interface({ value: t.string, type: ModeCodec }),
[ConfigKey.REQUEST_HEADERS_CHECK]: t.record(t.string, t.string),
[ConfigKey.USERNAME]: t.string,
});
export const HTTPSensitiveAdvancedFieldsCodec = t.intersection([
t.interface({
[ConfigKey.PASSWORD]: t.string,
[ConfigKey.RESPONSE_BODY_CHECK_NEGATIVE]: t.array(t.string),
[ConfigKey.RESPONSE_BODY_CHECK_POSITIVE]: t.array(t.string),
[ConfigKey.RESPONSE_HEADERS_CHECK]: t.record(t.string, t.string),
[ConfigKey.REQUEST_BODY_CHECK]: t.interface({ value: t.string, type: CodeEditorModeCodec }),
[ConfigKey.REQUEST_HEADERS_CHECK]: t.record(t.string, t.string),
[ConfigKey.USERNAME]: t.string,
}),
t.partial({
[ConfigKey.PROXY_HEADERS]: t.record(t.string, t.string),
[ConfigKey.RESPONSE_JSON_CHECK]: t.array(ResponseCheckJSONCodec),
}),
]);

export const HTTPAdvancedCodec = t.intersection([
HTTPAdvancedFieldsCodec,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import React from 'react';
import { fireEvent, waitFor } from '@testing-library/react';
import { render } from '../../../utils/testing/rtl_helpers';
import { HeaderField, contentTypes } from './header_field';
import { Mode } from '../types';
import { CodeEditorMode } from '../types';

describe('<HeaderField />', () => {
const onChange = jest.fn();
Expand Down Expand Up @@ -95,14 +95,14 @@ describe('<HeaderField />', () => {
});

it('handles content mode', async () => {
const contentMode: Mode = Mode.PLAINTEXT;
const contentMode: CodeEditorMode = CodeEditorMode.PLAINTEXT;
render(
<HeaderField defaultValue={defaultValue} onChange={onChange} contentMode={contentMode} />
);

await waitFor(() => {
expect(onChange).toBeCalledWith({
'Content-Type': contentTypes[Mode.PLAINTEXT],
'Content-Type': contentTypes[CodeEditorMode.PLAINTEXT],
});
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@

import React, { useEffect, useState } from 'react';
import { FormattedMessage } from '@kbn/i18n-react';
import { ContentType, Mode } from '../types';
import { ContentType, CodeEditorMode } from '../types';

import { KeyValuePairsField, Pair } from './key_value_field';

export interface HeaderFieldProps {
contentMode?: Mode;
contentMode?: CodeEditorMode;
defaultValue: Record<string, string>;
onChange: (value: Record<string, string>) => void;
onBlur?: () => void;
Expand Down Expand Up @@ -72,9 +72,9 @@ export const HeaderField = ({
);
};

export const contentTypes: Record<Mode, ContentType> = {
[Mode.JSON]: ContentType.JSON,
[Mode.PLAINTEXT]: ContentType.TEXT,
[Mode.XML]: ContentType.XML,
[Mode.FORM]: ContentType.FORM,
export const contentTypes: Record<CodeEditorMode, ContentType> = {
[CodeEditorMode.JSON]: ContentType.JSON,
[CodeEditorMode.PLAINTEXT]: ContentType.TEXT,
[CodeEditorMode.XML]: ContentType.XML,
[CodeEditorMode.FORM]: ContentType.FORM,
};
Loading