-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into drilldown_theme
- Loading branch information
Showing
105 changed files
with
5,677 additions
and
4,694 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -164,7 +164,6 @@ | |
"@jest/console", | ||
"@jest/reporters", | ||
"@jest/types", | ||
"@types/jest", | ||
"babel-jest", | ||
"expect", | ||
"jest", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/* | ||
* 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 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
require('../src/setup_node_env'); | ||
require('../src/dev/performance/run_scalability_cli'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
/* | ||
* 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 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import { createFlagError } from '@kbn/dev-cli-errors'; | ||
import { run } from '@kbn/dev-cli-runner'; | ||
import { REPO_ROOT } from '@kbn/utils'; | ||
import fs from 'fs'; | ||
import path from 'path'; | ||
|
||
run( | ||
async ({ log, flagsReader, procRunner }) => { | ||
const kibanaInstallDir = flagsReader.path('kibana-install-dir'); | ||
const journeyConfigPath = flagsReader.requiredPath('journey-config-path'); | ||
|
||
if (kibanaInstallDir && !fs.existsSync(kibanaInstallDir)) { | ||
throw createFlagError('--kibana-install-dir must be an existing directory'); | ||
} | ||
if ( | ||
!fs.existsSync(journeyConfigPath) || | ||
(!fs.statSync(journeyConfigPath).isDirectory() && path.extname(journeyConfigPath) !== '.json') | ||
) { | ||
throw createFlagError( | ||
'--journey-config-path must be an existing directory or scalability json path' | ||
); | ||
} | ||
|
||
const journeys = fs.statSync(journeyConfigPath).isDirectory() | ||
? fs | ||
.readdirSync(journeyConfigPath) | ||
.filter((fileName) => path.extname(fileName) === '.json') | ||
.map((fileName) => path.resolve(journeyConfigPath, fileName)) | ||
: [journeyConfigPath]; | ||
|
||
log.info(`Found ${journeys.length} journeys to run:\n${JSON.stringify(journeys)}`); | ||
|
||
const failedJourneys = []; | ||
|
||
for (const journey of journeys) { | ||
try { | ||
process.stdout.write(`--- Running scalability journey: ${journey}\n`); | ||
await runScalabilityJourney(journey, kibanaInstallDir); | ||
} catch (e) { | ||
log.error(e); | ||
failedJourneys.push(journey); | ||
} | ||
} | ||
|
||
if (failedJourneys.length > 0) { | ||
throw new Error(`${failedJourneys.length} journeys failed: ${failedJourneys.join(',')}`); | ||
} | ||
|
||
async function runScalabilityJourney(filePath: string, kibanaDir?: string) { | ||
// Pass in a clean APM environment, so that FTR can later | ||
// set it's own values. | ||
const cleanApmEnv = { | ||
ELASTIC_APM_ACTIVE: undefined, | ||
ELASTIC_APM_BREAKDOWN_METRICS: undefined, | ||
ELASTIC_APM_CONTEXT_PROPAGATION_ONLY: undefined, | ||
ELASTIC_APM_CAPTURE_SPAN_STACK_TRACES: undefined, | ||
ELASTIC_APM_ENVIRONMENT: undefined, | ||
ELASTIC_APM_GLOBAL_LABELS: undefined, | ||
ELASTIC_APM_MAX_QUEUE_SIZE: undefined, | ||
ELASTIC_APM_METRICS_INTERVAL: undefined, | ||
ELASTIC_APM_SERVER_URL: undefined, | ||
ELASTIC_APM_SECRET_TOKEN: undefined, | ||
ELASTIC_APM_TRANSACTION_SAMPLE_RATE: undefined, | ||
}; | ||
|
||
await procRunner.run('scalability-tests', { | ||
cmd: 'node', | ||
args: [ | ||
'scripts/functional_tests', | ||
['--config', 'x-pack/test/scalability/config.ts'], | ||
kibanaDir ? ['--kibana-install-dir', kibanaDir] : [], | ||
'--debug', | ||
'--logToFile', | ||
'--bail', | ||
].flat(), | ||
cwd: REPO_ROOT, | ||
wait: true, | ||
env: { | ||
...cleanApmEnv, | ||
SCALABILITY_JOURNEY_PATH: filePath, // journey json file for Gatling test runner | ||
KIBANA_DIR: REPO_ROOT, // Gatling test runner use it to find kbn/es archives | ||
}, | ||
}); | ||
} | ||
}, | ||
{ | ||
flags: { | ||
string: ['kibana-install-dir', 'journey-config-path'], | ||
help: ` | ||
--kibana-install-dir Run Kibana from existing install directory instead of from source | ||
--journey-config-path Define a scalability journey config or directory with multiple | ||
configs that should be executed | ||
`, | ||
}, | ||
} | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
x-pack/plugins/alerting/server/rules_client/common/api_key_as_alert_attributes.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* 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 { RawRule } from '../../types'; | ||
import { CreateAPIKeyResult } from '../types'; | ||
|
||
export function apiKeyAsAlertAttributes( | ||
apiKey: CreateAPIKeyResult | null, | ||
username: string | null | ||
): Pick<RawRule, 'apiKey' | 'apiKeyOwner'> { | ||
return apiKey && apiKey.apiKeysEnabled | ||
? { | ||
apiKeyOwner: username, | ||
apiKey: Buffer.from(`${apiKey.result.id}:${apiKey.result.api_key}`).toString('base64'), | ||
} | ||
: { | ||
apiKeyOwner: null, | ||
apiKey: null, | ||
}; | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
17 changes: 17 additions & 0 deletions
17
x-pack/plugins/alerting/server/rules_client/common/calculate_is_snoozed_until.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/* | ||
* 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 { RuleSnooze } from '../../types'; | ||
import { getRuleSnoozeEndTime } from '../../lib'; | ||
|
||
export function calculateIsSnoozedUntil(rule: { | ||
muteAll: boolean; | ||
snoozeSchedule?: RuleSnooze; | ||
}): string | null { | ||
const isSnoozedUntil = getRuleSnoozeEndTime(rule); | ||
return isSnoozedUntil ? isSnoozedUntil.toISOString() : null; | ||
} |
26 changes: 26 additions & 0 deletions
26
x-pack/plugins/alerting/server/rules_client/common/constants.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* 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 { | ||
AlertingAuthorizationFilterType, | ||
AlertingAuthorizationFilterOpts, | ||
} from '../../authorization'; | ||
|
||
// NOTE: Changing this prefix will require a migration to update the prefix in all existing `rule` saved objects | ||
export const extractedSavedObjectParamReferenceNamePrefix = 'param:'; | ||
|
||
// NOTE: Changing this prefix will require a migration to update the prefix in all existing `rule` saved objects | ||
export const preconfiguredConnectorActionRefPrefix = 'preconfigured:'; | ||
|
||
export const alertingAuthorizationFilterOpts: AlertingAuthorizationFilterOpts = { | ||
type: AlertingAuthorizationFilterType.KQL, | ||
fieldNames: { ruleTypeId: 'alert.attributes.alertTypeId', consumer: 'alert.attributes.consumer' }, | ||
}; | ||
|
||
export const MAX_RULES_NUMBER_FOR_BULK_OPERATION = 10000; | ||
export const API_KEY_GENERATE_CONCURRENCY = 50; | ||
export const RULE_TYPE_CHECKS_CONCURRENCY = 50; |
12 changes: 12 additions & 0 deletions
12
x-pack/plugins/alerting/server/rules_client/common/generate_api_key_name.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/* | ||
* 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 { truncate, trim } from 'lodash'; | ||
|
||
export function generateAPIKeyName(alertTypeId: string, alertName: string) { | ||
return truncate(`Alerting: ${alertTypeId}/${trim(alertName)}`, { length: 256 }); | ||
} |
31 changes: 31 additions & 0 deletions
31
x-pack/plugins/alerting/server/rules_client/common/get_and_validate_common_bulk_options.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* 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 Boom from '@hapi/boom'; | ||
import { BulkOptions, BulkOptionsFilter, BulkOptionsIds } from '../types'; | ||
|
||
export const getAndValidateCommonBulkOptions = (options: BulkOptions) => { | ||
const filter = (options as BulkOptionsFilter).filter; | ||
const ids = (options as BulkOptionsIds).ids; | ||
|
||
if (!ids && !filter) { | ||
throw Boom.badRequest( | ||
"Either 'ids' or 'filter' property in method's arguments should be provided" | ||
); | ||
} | ||
|
||
if (ids?.length === 0) { | ||
throw Boom.badRequest("'ids' property should not be an empty array"); | ||
} | ||
|
||
if (ids && filter) { | ||
throw Boom.badRequest( | ||
"Both 'filter' and 'ids' are supplied. Define either 'ids' or 'filter' properties in method's arguments" | ||
); | ||
} | ||
return { ids, filter }; | ||
}; |
12 changes: 12 additions & 0 deletions
12
...plugins/alerting/server/rules_client/common/include_fields_required_for_authentication.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/* | ||
* 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 { uniq } from 'lodash'; | ||
|
||
export function includeFieldsRequiredForAuthentication(fields: string[]): string[] { | ||
return uniq([...fields, 'alertTypeId', 'consumer']); | ||
} |
Oops, something went wrong.