[8.8] [Synthetics] allow saving params for lightweight monitors (#157226) (#157297)

# Backport

This will backport the following commits from `main` to `8.8`:
- [[Synthetics] allow saving params for lightweight monitors
(#157226)](https://github.com/elastic/kibana/pull/157226)

<!--- Backport version: 8.9.7 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Dominique
Clarke","email":"dominique.clarke@elastic.co"},"sourceCommit":{"committedDate":"2023-05-10T15:58:32Z","message":"[Synthetics]
allow saving params for lightweight monitors (#157226)\n\n##
Summary\r\n\r\nRelates to
https://github.com/elastic/synthetics/issues/725\r\n\r\nAllows the
`params` value to be saved against lightweight monitors.\r\n\r\nThis
ensures that the formatters for both private and public location\r\ncan
access these params, and apply them as overwrites to global
params.\r\n\r\n### Testing\r\n\r\n1. Check out associated synthetics
agent PR \r\n2. Create a global parameter, for example
`GLOBAL_URL`\r\n3. Create lightweight monitor that uses that global
parameter in your\r\nproject file\r\n4. Push the monitor and navigate to
Synthetics. Ensure the monitor uses\r\nthe value of the `GLOBAL_URL`
parameter appropriately\r\n5. Navigate back to your project config. In
your `synthetics.config.ts`\r\nfile, add a param for `GLOBAL_URL`\r\n6.
Repush your monitor\r\n7. Confirm `GLOBAL_URL` is overwritten by the
pushed
params","sha":"1f99b80c5b876c68fd137972b49861fd7e590459","branchLabelMapping":{"^v8.9.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["bug","Team:uptime","release_note:skip","v8.8.0","v8.7.2","v8.9.0"],"number":157226,"url":"https://github.com/elastic/kibana/pull/157226","mergeCommit":{"message":"[Synthetics]
allow saving params for lightweight monitors (#157226)\n\n##
Summary\r\n\r\nRelates to
https://github.com/elastic/synthetics/issues/725\r\n\r\nAllows the
`params` value to be saved against lightweight monitors.\r\n\r\nThis
ensures that the formatters for both private and public location\r\ncan
access these params, and apply them as overwrites to global
params.\r\n\r\n### Testing\r\n\r\n1. Check out associated synthetics
agent PR \r\n2. Create a global parameter, for example
`GLOBAL_URL`\r\n3. Create lightweight monitor that uses that global
parameter in your\r\nproject file\r\n4. Push the monitor and navigate to
Synthetics. Ensure the monitor uses\r\nthe value of the `GLOBAL_URL`
parameter appropriately\r\n5. Navigate back to your project config. In
your `synthetics.config.ts`\r\nfile, add a param for `GLOBAL_URL`\r\n6.
Repush your monitor\r\n7. Confirm `GLOBAL_URL` is overwritten by the
pushed
params","sha":"1f99b80c5b876c68fd137972b49861fd7e590459"}},"sourceBranch":"main","suggestedTargetBranches":["8.8","8.7"],"targetPullRequestStates":[{"branch":"8.8","label":"v8.8.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.7","label":"v8.7.2","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.9.0","labelRegex":"^v8.9.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/157226","number":157226,"mergeCommit":{"message":"[Synthetics]
allow saving params for lightweight monitors (#157226)\n\n##
Summary\r\n\r\nRelates to
https://github.com/elastic/synthetics/issues/725\r\n\r\nAllows the
`params` value to be saved against lightweight monitors.\r\n\r\nThis
ensures that the formatters for both private and public location\r\ncan
access these params, and apply them as overwrites to global
params.\r\n\r\n### Testing\r\n\r\n1. Check out associated synthetics
agent PR \r\n2. Create a global parameter, for example
`GLOBAL_URL`\r\n3. Create lightweight monitor that uses that global
parameter in your\r\nproject file\r\n4. Push the monitor and navigate to
Synthetics. Ensure the monitor uses\r\nthe value of the `GLOBAL_URL`
parameter appropriately\r\n5. Navigate back to your project config. In
your `synthetics.config.ts`\r\nfile, add a param for `GLOBAL_URL`\r\n6.
Repush your monitor\r\n7. Confirm `GLOBAL_URL` is overwritten by the
pushed params","sha":"1f99b80c5b876c68fd137972b49861fd7e590459"}}]}]
BACKPORT-->

Co-authored-by: Dominique Clarke <dominique.clarke@elastic.co>
This commit is contained in:
Kibana Machine 2023-05-10 13:15:13 -04:00 committed by GitHub
parent 805a3222fe
commit e5a2779330
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 628 additions and 22 deletions

View file

@ -148,6 +148,7 @@ export const DEFAULT_COMMON_FIELDS: CommonFields = {
[ConfigKey.JOURNEY_ID]: '',
[ConfigKey.CONFIG_HASH]: '',
[ConfigKey.MONITOR_QUERY_ID]: '',
[ConfigKey.PARAMS]: '',
};
export const DEFAULT_BROWSER_ADVANCED_FIELDS: BrowserAdvancedFields = {
@ -170,7 +171,6 @@ export const DEFAULT_BROWSER_SIMPLE_FIELDS: BrowserSimpleFields = {
},
},
[ConfigKey.MONITOR_TYPE]: DataStream.BROWSER,
[ConfigKey.PARAMS]: '',
[ConfigKey.PORT]: null,
[ConfigKey.SCHEDULE]: {
unit: ScheduleUnit.MINUTES,

View file

@ -34,7 +34,6 @@ export const throttlingFormatter: Formatter = (fields) => {
export const browserFormatters: BrowserFormatMap = {
[ConfigKey.SOURCE_PROJECT_CONTENT]: null,
[ConfigKey.PARAMS]: null,
[ConfigKey.SCREENSHOTS]: null,
[ConfigKey.IGNORE_HTTPS_ERRORS]: null,
[ConfigKey.PLAYWRIGHT_OPTIONS]: null,

View file

@ -30,6 +30,7 @@ export const commonFormatters: CommonFormatMap = {
[ConfigKey.ORIGINAL_SPACE]: null,
[ConfigKey.CONFIG_HASH]: null,
[ConfigKey.MONITOR_QUERY_ID]: null,
[ConfigKey.PARAMS]: null,
[ConfigKey.SCHEDULE]: (fields) =>
JSON.stringify(
`@every ${fields[ConfigKey.SCHEDULE]?.number}${fields[ConfigKey.SCHEDULE]?.unit}`

View file

@ -75,6 +75,7 @@ export const CommonFieldsCodec = t.intersection([
[ConfigKey.ORIGINAL_SPACE]: t.string,
[ConfigKey.CUSTOM_HEARTBEAT_ID]: t.string,
[ConfigKey.ALERT_CONFIG]: AlertConfigsCodec,
[ConfigKey.PARAMS]: t.string,
}),
]);
@ -243,7 +244,6 @@ export const BrowserSensitiveSimpleFieldsCodec = t.intersection([
t.interface({
[ConfigKey.SOURCE_INLINE]: t.string,
[ConfigKey.SOURCE_PROJECT_CONTENT]: t.string,
[ConfigKey.PARAMS]: t.string,
[ConfigKey.URLS]: t.union([t.string, t.null]),
[ConfigKey.PORT]: t.union([t.number, t.null]),
}),

View file

@ -41,7 +41,6 @@ export const browserFormatters: BrowserFormatMap = {
[ConfigKey.JOURNEY_FILTERS_MATCH]: null,
[ConfigKey.SYNTHETICS_ARGS]: arrayFormatter,
[ConfigKey.JOURNEY_FILTERS_TAGS]: arrayFormatter,
[ConfigKey.PARAMS]: stringToObjectFormatter,
[ConfigKey.PLAYWRIGHT_OPTIONS]: stringToObjectFormatter,
...commonFormatters,
...tlsFormatters,

View file

@ -5,7 +5,7 @@
* 2.0.
*/
import { arrayFormatter } from './formatting_utils';
import { arrayFormatter, stringToObjectFormatter } from './formatting_utils';
import { commonFormatters as commonBasicFormatters } from '../../../common/formatters/common/formatters';
import { CommonFields, ConfigKey, MonitorFields } from '../../../common/runtime_types';
@ -26,6 +26,7 @@ export type Formatter =
export type CommonFormatMap = Record<keyof CommonFields, Formatter>;
export const commonFormatters: CommonFormatMap = {
...commonBasicFormatters,
[ConfigKey.PARAMS]: stringToObjectFormatter,
[ConfigKey.SCHEDULE]: (fields) =>
`@every ${fields[ConfigKey.SCHEDULE]?.number}${fields[ConfigKey.SCHEDULE]?.unit}`,
[ConfigKey.TAGS]: arrayFormatter,

View file

@ -61,9 +61,6 @@ export const getNormalizeBrowserFields = ({
[ConfigKey.PLAYWRIGHT_OPTIONS]: Object.keys(monitor.playwrightOptions || {}).length
? JSON.stringify(monitor.playwrightOptions)
: defaultFields[ConfigKey.PLAYWRIGHT_OPTIONS],
[ConfigKey.PARAMS]: Object.keys(monitor.params || {}).length
? JSON.stringify(monitor.params)
: defaultFields[ConfigKey.PARAMS],
[ConfigKey.JOURNEY_FILTERS_MATCH]:
monitor.filter?.match || defaultFields[ConfigKey.JOURNEY_FILTERS_MATCH],
[ConfigKey.TIMEOUT]: monitor.timeout

View file

@ -132,6 +132,7 @@ describe('getNormalizeCommonFields', () => {
},
tags: [],
timeout: '16',
params: '',
},
});
}
@ -192,6 +193,7 @@ describe('getNormalizeCommonFields', () => {
},
tags: [],
timeout: '16',
params: '',
},
});
});

View file

@ -84,6 +84,9 @@ export const getNormalizeCommonFields = ({
? getValueInSeconds(monitor.timeout)
: defaultFields[ConfigKey.TIMEOUT],
[ConfigKey.CONFIG_HASH]: monitor.hash || defaultFields[ConfigKey.CONFIG_HASH],
[ConfigKey.PARAMS]: Object.keys(monitor.params || {}).length
? JSON.stringify(monitor.params)
: defaultFields[ConfigKey.PARAMS],
// picking out keys specifically, so users can't add arbitrary fields
[ConfigKey.ALERT_CONFIG]: monitor.alert
? {

View file

@ -7,7 +7,7 @@
import { v4 as uuidv4 } from 'uuid';
import expect from '@kbn/expect';
import { ConfigKey, ProjectMonitorsRequest } from '@kbn/synthetics-plugin/common/runtime_types';
import { API_URLS } from '@kbn/synthetics-plugin/common/constants';
import { API_URLS, SYNTHETICS_API_URLS } from '@kbn/synthetics-plugin/common/constants';
import { formatKibanaNamespace } from '@kbn/synthetics-plugin/common/formatters';
import { syntheticsMonitorType } from '@kbn/synthetics-plugin/server/legacy_uptime/lib/saved_objects/synthetics_monitor';
import { REQUEST_TOO_LARGE } from '@kbn/synthetics-plugin/server/routes/monitor_cruds/add_monitor_project';
@ -20,7 +20,10 @@ import { FtrProviderContext } from '../../ftr_provider_context';
import { getFixtureJson } from '../uptime/rest/helper/get_fixture_json';
import { PrivateLocationTestService } from './services/private_location_test_service';
import { comparePolicies } from './sample_data/test_policy';
import { getTestProjectSyntheticsPolicy } from './sample_data/test_project_monitor_policy';
import {
getTestProjectSyntheticsPolicy,
getTestProjectSyntheticsPolicyLightweight,
} from './sample_data/test_project_monitor_policy';
export default function ({ getService }: FtrProviderContext) {
describe('AddProjectMonitors', function () {
@ -86,6 +89,16 @@ export default function ({ getService }: FtrProviderContext) {
const apiResponse = await testPrivateLocations.addFleetPolicy(testPolicyName);
testPolicyId = apiResponse.body.item.id;
await testPrivateLocations.setTestLocations([testPolicyId]);
await supertest
.post(SYNTHETICS_API_URLS.PARAMS)
.set('kbn-xsrf', 'true')
.send({ key: 'testGlobalParam', value: 'testGlobalParamValue' })
.expect(200);
await supertest
.post(SYNTHETICS_API_URLS.PARAMS)
.set('kbn-xsrf', 'true')
.send({ key: 'testGlobalParam2', value: 'testGlobalParamValue2' })
.expect(200);
});
beforeEach(() => {
@ -320,15 +333,18 @@ export default function ({ getService }: FtrProviderContext) {
config_id: decryptedCreatedMonitor.body.id,
custom_heartbeat_id: `${journeyId}-${project}-default`,
'check.response.body.negative': [],
'check.response.body.positive': ['Saved', 'saved'],
'check.response.body.positive': ['${testLocal1}', 'saved'],
'check.response.json': [
{ description: 'check status', expression: 'foo.bar == "myValue"' },
],
'check.response.headers': {},
proxy_url: '${testGlobalParam2}',
'check.request.body': {
type: 'text',
value: '',
},
params:
'{"testLocal1":"testLocalParamsValue","testGlobalParam2":"testGlobalParamOverwrite"}',
'check.request.headers': {
'Content-Type': 'application/x-www-form-urlencoded',
},
@ -359,7 +375,6 @@ export default function ({ getService }: FtrProviderContext) {
project_id: project,
username: '',
password: '',
proxy_url: '',
proxy_headers: {},
'response.include_body': 'always',
'response.include_headers': false,
@ -497,6 +512,7 @@ export default function ({ getService }: FtrProviderContext) {
mode: 'any',
ipv6: true,
ipv4: true,
params: '',
});
}
} finally {
@ -604,6 +620,7 @@ export default function ({ getService }: FtrProviderContext) {
mode: 'any',
ipv4: true,
ipv6: true,
params: '',
});
}
} finally {
@ -1442,6 +1459,73 @@ export default function ({ getService }: FtrProviderContext) {
}
});
it('creates integration policies for project monitors with private locations - lightweight', async () => {
const project = `test-project-${uuidv4()}`;
try {
await supertest
.put(API_URLS.SYNTHETICS_MONITORS_PROJECT_UPDATE.replace('{projectName}', project))
.set('kbn-xsrf', 'true')
.send({
...httpProjectMonitors,
monitors: [
{
...httpProjectMonitors.monitors[1],
'check.request.body': '${testGlobalParam}',
privateLocations: ['Test private location 0'],
},
],
})
.expect(200);
const monitorsResponse = await supertest
.get(API_URLS.SYNTHETICS_MONITORS)
.query({
filter: `${syntheticsMonitorType}.attributes.journey_id: ${httpProjectMonitors.monitors[1].id}`,
})
.set('kbn-xsrf', 'true')
.expect(200);
const apiResponsePolicy = await supertest.get(
'/api/fleet/package_policies?page=1&perPage=2000&kuery=ingest-package-policies.package.name%3A%20synthetics'
);
const packagePolicy = apiResponsePolicy.body.items.find(
(pkgPolicy: PackagePolicy) =>
pkgPolicy.id ===
`${
monitorsResponse.body.monitors[0].attributes[ConfigKey.CUSTOM_HEARTBEAT_ID]
}-${testPolicyId}`
);
expect(packagePolicy.name).eql(
`${httpProjectMonitors.monitors[1].id}-${project}-default-Test private location 0`
);
expect(packagePolicy.policy_id).eql(testPolicyId);
const configId = monitorsResponse.body.monitors[0].id;
const id = monitorsResponse.body.monitors[0].attributes[ConfigKey.CUSTOM_HEARTBEAT_ID];
comparePolicies(
packagePolicy,
getTestProjectSyntheticsPolicyLightweight({
inputs: {},
name: 'My Monitor 3',
id,
configId,
projectId: project,
locationName: 'Test private location 0',
})
);
} finally {
await deleteMonitor(httpProjectMonitors.monitors[1].id, project);
const packagesResponse = await supertest.get(
'/api/fleet/package_policies?page=1&perPage=2000&kuery=ingest-package-policies.package.name%3A%20synthetics'
);
expect(packagesResponse.body.items.length).eql(0);
}
});
it('deletes integration policies for project monitors when private location is removed from the monitor - lightweight', async () => {
const project = `test-project-${uuidv4()}`;
@ -1795,7 +1879,7 @@ export default function ({ getService }: FtrProviderContext) {
},
'check.response': {
body: {
positive: ['Saved', 'saved'],
positive: ['${testLocal1}', 'saved'],
},
status: [200],
json: [{ description: 'check status', expression: 'foo.bar == "myValue"' }],
@ -1816,6 +1900,11 @@ export default function ({ getService }: FtrProviderContext) {
tags: 'tag2,tag2',
urls: ['http://localhost:9200'],
'ssl.verification_mode': 'strict',
params: {
testGlobalParam2: 'testGlobalParamOverwrite',
testLocal1: 'testLocalParamsValue',
},
proxy_url: '${testGlobalParam2}',
},
reason: 'Cannot update monitor to different type.',
},
@ -1898,7 +1987,7 @@ export default function ({ getService }: FtrProviderContext) {
},
'check.response': {
body: {
positive: ['Saved', 'saved'],
positive: ['${testLocal1}', 'saved'],
},
status: [200],
json: [
@ -1924,6 +2013,11 @@ export default function ({ getService }: FtrProviderContext) {
timeout: '80s',
type: 'http',
urls: ['http://localhost:9200'],
params: {
testGlobalParam2: 'testGlobalParamOverwrite',
testLocal1: 'testLocalParamsValue',
},
proxy_url: '${testGlobalParam2}',
},
reason: "Couldn't save or update monitor because of an invalid configuration.",
},
@ -1966,7 +2060,7 @@ export default function ({ getService }: FtrProviderContext) {
},
'check.response': {
body: {
positive: ['Saved', 'saved'],
positive: ['${testLocal1}', 'saved'],
},
status: [200],
json: [
@ -1993,6 +2087,11 @@ export default function ({ getService }: FtrProviderContext) {
type: 'http',
urls: ['http://localhost:9200'],
locations: ['localhost'],
params: {
testGlobalParam2: 'testGlobalParamOverwrite',
testLocal1: 'testLocalParamsValue',
},
proxy_url: '${testGlobalParam2}',
},
reason: "Couldn't save or update monitor because of an invalid configuration.",
},
@ -2035,7 +2134,7 @@ export default function ({ getService }: FtrProviderContext) {
},
'check.response': {
body: {
positive: ['Saved', 'saved'],
positive: ['${testLocal1}', 'saved'],
},
status: [200],
json: [
@ -2062,6 +2161,11 @@ export default function ({ getService }: FtrProviderContext) {
type: 'http',
urls: ['http://localhost:9200'],
locations: [],
params: {
testGlobalParam2: 'testGlobalParamOverwrite',
testLocal1: 'testLocalParamsValue',
},
proxy_url: '${testGlobalParam2}',
},
reason: "Couldn't save or update monitor because of an invalid configuration.",
},

View file

@ -7,6 +7,490 @@
import { PackagePolicy } from '@kbn/fleet-plugin/common';
export const getTestProjectSyntheticsPolicyLightweight = (
{
name,
inputs = {},
configId,
id,
projectId = 'test-suite',
locationName = 'Fleet Managed',
}: {
name?: string;
inputs: Record<string, { value: string | boolean; type: string }>;
configId: string;
id: string;
projectId?: string;
locationName?: string;
} = {
name: 'My Monitor 3',
inputs: {},
configId: '',
id: '',
locationName: 'Fleet Managed',
}
): PackagePolicy => ({
id: `4b6abc6c-118b-4d93-a489-1135500d09f1-${projectId}-default-d70a46e0-22ea-11ed-8c6b-09a2d21dfbc3`,
version: 'WzEzMDksMV0=',
name: `4b6abc6c-118b-4d93-a489-1135500d09f1-${projectId}-default-Test private location 0`,
namespace: 'default',
package: { name: 'synthetics', title: 'Elastic Synthetics', version: '0.12.0' },
enabled: true,
policy_id: '46034710-0ba6-11ed-ba04-5f123b9faa8b',
inputs: [
{
type: 'synthetics/http',
policy_template: 'synthetics',
enabled: true,
streams: [
{
enabled: true,
data_stream: {
type: 'synthetics',
dataset: 'http',
elasticsearch: {
privileges: {
indices: ['auto_configure', 'create_doc', 'read'],
},
},
},
vars: {
__ui: {
type: 'yaml',
value: '{"is_tls_enabled":true}',
},
'check.request.body': {
type: 'yaml',
value: '"testGlobalParamValue"',
},
'check.request.headers': {
type: 'yaml',
value: '{"Content-Type":"application/x-www-form-urlencoded"}',
},
'check.request.method': {
type: 'text',
value: 'POST',
},
'check.response.body.negative': {
type: 'yaml',
value: null,
},
'check.response.body.positive': {
type: 'yaml',
value: '["testLocalParamsValue","saved"]',
},
'check.response.headers': {
type: 'yaml',
value: null,
},
'check.response.json': {
type: 'yaml',
value: '[{"description":"check status","expression":"foo.bar == \\"myValue\\""}]',
},
'check.response.status': {
type: 'yaml',
value: '["200"]',
},
config_id: {
type: 'text',
value: configId,
},
enabled: {
type: 'bool',
value: false,
},
id: {
type: 'text',
value: id,
},
ipv4: {
type: 'bool',
value: true,
},
ipv6: {
type: 'bool',
value: true,
},
location_name: {
type: 'text',
value: 'Test private location 0',
},
max_redirects: {
type: 'integer',
value: '0',
},
mode: {
type: 'text',
value: 'any',
},
'monitor.project.id': {
type: 'text',
value: projectId,
},
'monitor.project.name': {
type: 'text',
value: projectId,
},
name: {
type: 'text',
value: name,
},
origin: {
type: 'text',
value: 'project',
},
password: {
type: 'password',
value: '',
},
proxy_headers: {
type: 'yaml',
value: null,
},
proxy_url: {
type: 'text',
value: 'testGlobalParamOverwrite',
},
'response.include_body': {
type: 'text',
value: 'always',
},
'response.include_body_max_bytes': {
type: 'text',
value: '900',
},
'response.include_headers': {
type: 'bool',
value: false,
},
run_once: {
type: 'bool',
value: false,
},
schedule: {
type: 'text',
value: '"@every 60m"',
},
'service.name': {
type: 'text',
value: '',
},
'ssl.certificate': {
type: 'yaml',
value: null,
},
'ssl.certificate_authorities': {
type: 'yaml',
value: null,
},
'ssl.key': {
type: 'yaml',
value: null,
},
'ssl.key_passphrase': {
type: 'text',
value: null,
},
'ssl.supported_protocols': {
type: 'yaml',
value: '["TLSv1.1","TLSv1.2","TLSv1.3"]',
},
'ssl.verification_mode': {
type: 'text',
value: 'strict',
},
tags: {
type: 'yaml',
value: '["tag2","tag2"]',
},
timeout: {
type: 'text',
value: '80s',
},
type: {
type: 'text',
value: 'http',
},
urls: {
type: 'text',
value: 'http://localhost:9200',
},
username: {
type: 'text',
value: '',
},
},
compiled_stream: {
__ui: {
is_tls_enabled: true,
},
type: 'http',
name,
id,
origin: 'project',
enabled: false,
urls: 'http://localhost:9200',
schedule: '@every 60m',
timeout: '80s',
max_redirects: 0,
tags: ['tag2', 'tag2'],
proxy_url: 'testGlobalParamOverwrite',
'run_from.geo.name': locationName ?? 'Test private location 0',
'run_from.id': locationName ?? 'Test private location 0',
'response.include_headers': false,
'response.include_body': 'always',
'ssl.supported_protocols': ['TLSv1.1', 'TLSv1.2', 'TLSv1.3'],
'ssl.verification_mode': 'strict',
'check.request.method': 'POST',
'check.request.headers': { 'Content-Type': 'application/x-www-form-urlencoded' },
'check.response.body.positive': ['testLocalParamsValue', 'saved'],
'check.response.json': [
{
description: 'check status',
expression: 'foo.bar == "myValue"',
},
],
'check.response.status': ['200'],
'check.request.body': 'testGlobalParamValue',
ipv4: true,
ipv6: true,
mode: 'any',
processors: [
{
add_fields: {
target: '',
fields: {
'monitor.fleet_managed': true,
config_id: configId,
'monitor.project.name': projectId,
'monitor.project.id': projectId,
},
},
},
],
},
id: `synthetics/http-http-4b6abc6c-118b-4d93-a489-1135500d09f1-${projectId}-default-d70a46e0-22ea-11ed-8c6b-09a2d21dfbc3`,
},
],
},
{
type: 'synthetics/tcp',
policy_template: 'synthetics',
enabled: false,
streams: [
{
enabled: false,
data_stream: {
type: 'synthetics',
dataset: 'tcp',
},
vars: {
__ui: { type: 'yaml' },
enabled: { value: true, type: 'bool' },
type: { value: 'tcp', type: 'text' },
name: { type: 'text' },
schedule: { value: '"@every 3m"', type: 'text' },
hosts: { type: 'text' },
'service.name': { type: 'text' },
timeout: { type: 'text' },
proxy_url: { type: 'text' },
proxy_use_local_resolver: { value: false, type: 'bool' },
tags: { type: 'yaml' },
'check.send': { type: 'text' },
'check.receive': { type: 'text' },
'ssl.certificate_authorities': { type: 'yaml' },
'ssl.certificate': { type: 'yaml' },
'ssl.key': { type: 'yaml' },
'ssl.key_passphrase': { type: 'text' },
'ssl.verification_mode': { type: 'text' },
'ssl.supported_protocols': { type: 'yaml' },
location_name: { value: 'Fleet managed', type: 'text' },
id: { type: 'text' },
config_id: { type: 'text' },
run_once: { value: false, type: 'bool' },
origin: { type: 'text' },
'monitor.project.id': { type: 'text' },
'monitor.project.name': { type: 'text' },
ipv4: { type: 'bool', value: true },
ipv6: { type: 'bool', value: true },
mode: { type: 'text' },
},
id: `synthetics/tcp-tcp-4b6abc6c-118b-4d93-a489-1135500d09f1-${projectId}-default-d70a46e0-22ea-11ed-8c6b-09a2d21dfbc3`,
},
],
},
{
type: 'synthetics/icmp',
policy_template: 'synthetics',
enabled: false,
streams: [
{
enabled: false,
data_stream: {
type: 'synthetics',
dataset: 'icmp',
},
vars: {
__ui: { type: 'yaml' },
enabled: { value: true, type: 'bool' },
type: { value: 'icmp', type: 'text' },
name: { type: 'text' },
schedule: { value: '"@every 3m"', type: 'text' },
wait: { value: '1s', type: 'text' },
hosts: { type: 'text' },
'service.name': { type: 'text' },
timeout: { type: 'text' },
tags: { type: 'yaml' },
location_name: { value: 'Fleet managed', type: 'text' },
id: { type: 'text' },
config_id: { type: 'text' },
run_once: { value: false, type: 'bool' },
origin: { type: 'text' },
'monitor.project.id': { type: 'text' },
'monitor.project.name': { type: 'text' },
ipv4: { type: 'bool', value: true },
ipv6: { type: 'bool', value: true },
mode: { type: 'text' },
},
id: `synthetics/icmp-icmp-4b6abc6c-118b-4d93-a489-1135500d09f1-${projectId}-default-d70a46e0-22ea-11ed-8c6b-09a2d21dfbc3`,
},
],
},
{
type: 'synthetics/browser',
policy_template: 'synthetics',
enabled: false,
streams: [
{
enabled: true,
data_stream: {
type: 'synthetics',
dataset: 'browser',
elasticsearch: {
privileges: {
indices: ['auto_configure', 'create_doc', 'read'],
},
},
},
vars: {
__ui: {
type: 'yaml',
},
enabled: { value: true, type: 'bool' },
type: { value: 'browser', type: 'text' },
name: { type: 'text' },
schedule: { value: JSON.stringify('@every 3m'), type: 'text' },
'service.name': { type: 'text' },
timeout: { type: 'text' },
tags: { type: 'yaml' },
'source.zip_url.url': { type: 'text' },
'source.zip_url.username': { type: 'text' },
'source.zip_url.folder': { type: 'text' },
'source.zip_url.password': { type: 'password' },
'source.inline.script': { type: 'yaml' },
'source.project.content': {
type: 'text',
},
params: {
type: 'yaml',
},
playwright_options: {
type: 'yaml',
},
screenshots: { type: 'text' },
synthetics_args: { type: 'text' },
ignore_https_errors: { type: 'bool' },
'throttling.config': {
type: 'text',
},
'filter_journeys.tags': { type: 'yaml' },
'filter_journeys.match': { type: 'text' },
'source.zip_url.ssl.certificate_authorities': { type: 'yaml' },
'source.zip_url.ssl.certificate': { type: 'yaml' },
'source.zip_url.ssl.key': { type: 'yaml' },
'source.zip_url.ssl.key_passphrase': { type: 'text' },
'source.zip_url.ssl.verification_mode': { type: 'text' },
'source.zip_url.ssl.supported_protocols': { type: 'yaml' },
'source.zip_url.proxy_url': { type: 'text' },
location_name: { value: 'Fleet managed', type: 'text' },
id: { type: 'text' },
config_id: { type: 'text' },
run_once: { value: false, type: 'bool' },
origin: { type: 'text' },
'monitor.project.id': { type: 'text' },
'monitor.project.name': { type: 'text' },
...inputs,
},
id: `synthetics/browser-browser-4b6abc6c-118b-4d93-a489-1135500d09f1-${projectId}-default-d70a46e0-22ea-11ed-8c6b-09a2d21dfbc3`,
compiled_stream: {
__ui: null,
type: 'browser',
name: null,
enabled: true,
schedule: '@every 3m',
timeout: null,
throttling: null,
processors: [
{
add_fields: {
target: '',
fields: {
'monitor.fleet_managed': true,
},
},
},
],
'run_from.geo.name': 'Fleet managed',
'run_from.id': 'Fleet managed',
...Object.keys(inputs).reduce((acc: Record<string, unknown>, key) => {
acc[key] = inputs[key].value;
return acc;
}, {}),
},
},
{
enabled: true,
data_stream: {
type: 'synthetics',
dataset: 'browser.network',
elasticsearch: {
privileges: {
indices: ['auto_configure', 'create_doc', 'read'],
},
},
},
id: `synthetics/browser-browser.network-4b6abc6c-118b-4d93-a489-1135500d09f1-${projectId}-default-d70a46e0-22ea-11ed-8c6b-09a2d21dfbc3`,
compiled_stream: {
processors: [{ add_fields: { target: '', fields: { 'monitor.fleet_managed': true } } }],
},
},
{
enabled: true,
data_stream: {
type: 'synthetics',
dataset: 'browser.screenshot',
elasticsearch: {
privileges: {
indices: ['auto_configure', 'create_doc', 'read'],
},
},
},
id: `synthetics/browser-browser.screenshot-4b6abc6c-118b-4d93-a489-1135500d09f1-${projectId}-default-d70a46e0-22ea-11ed-8c6b-09a2d21dfbc3`,
compiled_stream: {
processors: [{ add_fields: { target: '', fields: { 'monitor.fleet_managed': true } } }],
},
},
],
},
],
is_managed: true,
revision: 1,
created_at: '2022-08-23T13:52:42.531Z',
created_by: 'system',
updated_at: '2022-08-23T13:52:42.531Z',
updated_by: 'system',
});
export const getTestProjectSyntheticsPolicy = (
{
name,
@ -217,7 +701,11 @@ export const getTestProjectSyntheticsPolicy = (
'UEsDBBQACAAIAON5qVQAAAAAAAAAAAAAAAAfAAAAZXhhbXBsZXMvdG9kb3MvYmFzaWMuam91cm5leS50c22Q0WrDMAxF3/sVF7MHB0LMXlc6RvcN+wDPVWNviW0sdUsp/fe5SSiD7UFCWFfHujIGlpnkybwxFTZfoY/E3hsaLEtwhs9RPNWKDU12zAOxkXRIbN4tB9d9pFOJdO6EN2HMqQguWN9asFBuQVMmJ7jiWNII9fIXrbabdUYr58l9IhwhQQZCYORCTFFUC31Btj21NRc7Mq4Nds+4bDD/pNVgT9F52Jyr2Fa+g75LAPttg8yErk+S9ELpTmVotlVwnfNCuh2lepl3+JflUmSBJ3uggt1v9INW/lHNLKze9dJe1J3QJK8pSvWkm6aTtCet5puq+x63+AFQSwcIAPQ3VfcAAACcAQAAUEsBAi0DFAAIAAgA43mpVAD0N1X3AAAAnAEAAB8AAAAAAAAAAAAgAKSBAAAAAGV4YW1wbGVzL3RvZG9zL2Jhc2ljLmpvdXJuZXkudHNQSwUGAAAAAAEAAQBNAAAARAEAAAAA',
type: 'text',
},
params: { value: '', type: 'yaml' },
params: {
value:
'{"testGlobalParam2":"testGlobalParamValue2","testGlobalParam":"testGlobalParamValue"}',
type: 'yaml',
},
playwright_options: {
value: '{"headless":true,"chromiumSandbox":false}',
type: 'yaml',
@ -267,6 +755,10 @@ export const getTestProjectSyntheticsPolicy = (
playwright_options: { headless: true, chromiumSandbox: false },
screenshots: 'on',
'filter_journeys.match': 'check if title is present',
params: {
testGlobalParam: 'testGlobalParamValue',
testGlobalParam2: 'testGlobalParamValue2',
},
processors: [
{
add_fields: {

View file

@ -87,5 +87,6 @@
"hash": "",
"mode": "any",
"ipv4": true,
"ipv6": true
"ipv6": true,
"params": ""
}

View file

@ -29,5 +29,6 @@
"hash": "",
"mode": "any",
"ipv4": true,
"ipv6": true
"ipv6": true,
"params": ""
}

View file

@ -44,6 +44,7 @@
"enabled": false,
"id": "my-monitor-3",
"name": "My Monitor 3",
"proxy_url": "${testGlobalParam2}",
"urls": [
"http://localhost:9200"
],
@ -67,14 +68,18 @@
],
"body":{
"positive": [
"Saved",
"${testLocal1}",
"saved"
]
},
"json": [{"description":"check status","expression":"foo.bar == \"myValue\""}]
},
"hash": "ekrjelkjrelkjre",
"ssl.verification_mode": "strict"
"ssl.verification_mode": "strict",
"params": {
"testLocal1": "testLocalParamsValue",
"testGlobalParam2": "testGlobalParamOverwrite"
}
}
]
}

View file

@ -37,5 +37,6 @@
"hash": "",
"mode": "any",
"ipv4": true,
"ipv6": true
"ipv6": true,
"params": ""
}