Skip to content

Commit

Permalink
Merge branch '8.8' into backport/8.8/pr-156832
Browse files Browse the repository at this point in the history
  • Loading branch information
kibanamachine authored May 9, 2023
2 parents 1fd4c9b + 5a5fb99 commit 41c1b9f
Show file tree
Hide file tree
Showing 76 changed files with 1,209 additions and 638 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
---
id: kibDevTutorialRunningPerformanceJourneyInCloud
slug: /kibana-dev-docs/tutorial/performance/running_performance_journey_in_cloud
title: Running Performance Journey In Cloud
summary: Learn how to run performance journey against Cloud cluster
date: 2023-05-04
tags: ['kibana', 'onboarding', 'setup', 'performance', 'development', 'telemetry']
---

## Overview
As a way to better understand user experience with Kibana in cloud, we support running performance journeys against
Cloud deployments.
The process takes a few steps:
- Create a cloud deployment
- Re-configure deployment with APM enabled and reporting metrics to the monitoring cluster
- Create a user with `superuser` role to run tests with
- Checkout the branch that matches your cloud deployment version
- Run the performance journey

### Re-configure deployment for Kibana and Elasticsearch
We use [kibana-ops-e2e-perf](https://kibana-ops-e2e-perf.kb.us-central1.gcp.cloud.es.io/) cluster to monitor performance testing.

If you would like to report APM metrics to this cluster, copy `SECRET_TOKEN` and `SERVER_URL` values from [packages/kbn-journeys/journey/journey_apm_config.ts](https://github.com/elastic/kibana/blob/60c82765779419d356a131e212682b69b035804b/packages/kbn-journeys/journey/journey_apm_config.ts#L10-L11)

#### Change Elasticsearch configuration
In the ESS Admin Console, find your deployment and navigate to `Security` page. Click `Add Settings` under `Elasticsearch keystore` and add new entry:

```
Setting name: tracing.apm.secret_token
Secret: <SECRET_TOKEN>
```

Navigate to `Advanced Edit` page and change `Deployment Configuration` by adding the following JSON object to `resources.elasticsearch.plan.elasticsearch`:

```
"user_settings_override_json": {
"tracing.apm.enabled": "true",
"tracing.apm.environment": "development",
"tracing.apm.agent.service_name": "elasticsearch",
"tracing.apm.agent.server_url": "<SERVER_URL>",
"tracing.apm.agent.metrics_interval": "120s",
"tracing.apm.agent.transaction_sample_rate": "1"
}
```

Save changes and make sure cluster is restarted successfully.

#### Change Kibana configuration
Navigate to `Advanced Edit` page and change `Deployment Configuration` by adding the following JSON object to `resources.kibana.plan.kibana`:

```
"user_settings_override_json": {
"elastic.apm.active": true,
"elastic.apm.breakdownMetrics": false,
"elastic.apm.captureBody": "all",
"elastic.apm.captureRequestHeaders": "true",
"elastic.apm.captureSpanStackTraces": false,
"elastic.apm.centralConfig": false,
"elastic.apm.contextPropagationOnly": "false",
"elastic.apm.environment": "development",
"elastic.apm.globalLabels.deploymentId": "<DEPLOYMENT_ID>",
"elastic.apm.globalLabels.journeyName": "<YOUR_JOURNEY_NAME>",
"elastic.apm.longFieldMaxLength": "300000",
"elastic.apm.metricsInterval": "120s",
"elastic.apm.propagateTracestate": true,
"elastic.apm.sanitizeFieldNames": "password,passwd,pwd,secret,*key,*token*,*session*,*credit*,*card*,*auth*,set-cookie,pw,pass,connect.sid",
"elastic.apm.secretToken": "<SECRET_TOKEN>",
"elastic.apm.serverUrl": "<SERVER_URL>",
"elastic.apm.transactionSampleRate": 1
}
```

Note: DEPLOYMENT_ID and YOUR_JOURNEY_NAME values are optional labels to find the APM traces for your run.

Save changes and make sure cluster is restarted successfully.

### Run the journey
Make sure you have created user with `superuser` role and the Kibana repo branch is matching your deployment version.
Set env variables to run FTR against your cloud deployment:

```
export TEST_KIBANA_URL=https://<username>:<password>@<kibana_url>
export TEST_ES_URL=https://<username>:<password>@<elasticsearch_url>:<port>
export TEST_CLOUD=1
```

Run your journey with the command:

```
node scripts/functional_test_runner.js --config x-pack/performance/journeys/$YOUR_JOURNEY_NAME.ts`
```


71 changes: 69 additions & 2 deletions docs/api-generated/connectors/connector-apis-passthru.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Any modifications made to this file will be overwritten.
<h4><a href="#Connectors">Connectors</a></h4>
<ul>
<li><a href="#createConnector"><code><span class="http-method">post</span> /s/{spaceId}/api/actions/connector</code></a></li>
<li><a href="#createConnectorId"><code><span class="http-method">post</span> /s/{spaceId}/api/actions/connector/{connectorId}</code></a></li>
<li><a href="#deleteConnector"><code><span class="http-method">delete</span> /s/{spaceId}/api/actions/connector/{connectorId}</code></a></li>
<li><a href="#getConnector"><code><span class="http-method">get</span> /s/{spaceId}/api/actions/connector/{connectorId}</code></a></li>
<li><a href="#getConnectorTypes"><code><span class="http-method">get</span> /s/{spaceId}/api/actions/connector_types</code></a></li>
Expand Down Expand Up @@ -46,9 +47,75 @@ Any modifications made to this file will be overwritten.
<div class="field-items">
<div class="param">spaceId (required)</div>
<div class="param-desc"><span class="param-type">Path Parameter</span> &mdash; An identifier for the space. If <code>/s/</code> and the identifier are omitted from the path, the default space is used. default: null </div><div class="param">id (required)</div>
<div class="param-desc"><span class="param-type">Path Parameter</span> &mdash; An identifier for the space. If <code>/s/</code> and the identifier are omitted from the path, the default space is used. default: null </div>
</div> <!-- field-items -->
<h3 class="field-label">Consumes</h3>
This API call consumes the following media types via the <span class="header">Content-Type</span> request header:
<ul>
<li><code>application/json</code></li>
</ul>
<h3 class="field-label">Request body</h3>
<div class="field-items">
<div class="param">Create_connector_request_body_properties <a href="#Create_connector_request_body_properties">Create_connector_request_body_properties</a> (required)</div>
<div class="param-desc"><span class="param-type">Body Parameter</span> &mdash; </div>
</div> <!-- field-items -->
<h3 class="field-label">Request headers</h3>
<div class="field-items">
<div class="param">kbn-xsrf (required)</div>
<div class="param-desc"><span class="param-type">Header Parameter</span> &mdash; Cross-site request forgery protection default: null </div>
</div> <!-- field-items -->
<h3 class="field-label">Return type</h3>
<div class="return-type">
<a href="#connector_response_properties">connector_response_properties</a>
</div>
<!--Todo: process Response Object and its headers, schema, examples -->
<h3 class="field-label">Example data</h3>
<div class="example-data-content-type">Content-Type: application/json</div>
<pre class="example"><code>null</code></pre>
<h3 class="field-label">Produces</h3>
This API call produces the following media types according to the <span class="header">Accept</span> request header;
the media type will be conveyed by the <span class="header">Content-Type</span> response header.
<ul>
<li><code>application/json</code></li>
</ul>
<h3 class="field-label">Responses</h3>
<h4 class="field-label">200</h4>
Indicates a successful call.
<a href="#connector_response_properties">connector_response_properties</a>
<h4 class="field-label">401</h4>
Authorization information is missing or invalid.
<a href="#Unauthorized_response">Unauthorized_response</a>
</div> <!-- method -->
<hr/>
<div class="method"><a name="createConnectorId"/>
<div class="method-path">
<a class="up" href="#__Methods">Up</a>
<pre class="post"><code class="huge"><span class="http-method">post</span> /s/{spaceId}/api/actions/connector/{connectorId}</code></pre></div>
<div class="method-summary">Creates a connector. (<span class="nickname">createConnectorId</span>)</div>
<div class="method-notes">You must have <code>all</code> privileges for the <strong>Actions and Connectors</strong> feature in the <strong>Management</strong> section of the Kibana feature privileges.</div>
<h3 class="field-label">Path parameters</h3>
<div class="field-items">
<div class="param">spaceId (required)</div>
<div class="param-desc"><span class="param-type">Path Parameter</span> &mdash; An identifier for the space. If <code>/s/</code> and the identifier are omitted from the path, the default space is used. default: null </div><div class="param">connectorId (required)</div>
<div class="param-desc"><span class="param-type">Path Parameter</span> &mdash; An UUID v1 or v4 identifier for the connector. If you omit this parameter, an identifier is randomly generated. default: null </div>
<div class="param-desc"><span class="param-type">Path Parameter</span> &mdash; A UUID v1 or v4 identifier for the connector. If you omit this parameter, an identifier is randomly generated. default: null </div>
</div> <!-- field-items -->
<h3 class="field-label">Consumes</h3>
Expand Down
3 changes: 2 additions & 1 deletion packages/kbn-doc-links/src/get_doc_links.ts
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,8 @@ export const getDocLinks = ({ kibanaBranch }: GetDocLinkOptions): DocLinks => {
serviceNowAction: `${KIBANA_DOCS}servicenow-action-type.html#configuring-servicenow`,
serviceNowSIRAction: `${KIBANA_DOCS}servicenow-sir-action-type.html`,
setupPrerequisites: `${KIBANA_DOCS}alerting-setup.html#alerting-prerequisites`,
slackAction: `${KIBANA_DOCS}slack-action-type.html#configuring-slack`,
slackAction: `${KIBANA_DOCS}slack-action-type.html#configuring-slack-webhook`,
slackApiAction: `${KIBANA_DOCS}slack-action-type.html#configuring-slack-web-api`,
teamsAction: `${KIBANA_DOCS}teams-action-type.html#configuring-teams`,
connectors: `${KIBANA_DOCS}action-types.html`,
},
Expand Down
1 change: 1 addition & 0 deletions packages/kbn-doc-links/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,7 @@ export interface DocLinks {
serviceNowSIRAction: string;
setupPrerequisites: string;
slackAction: string;
slackApiAction: string;
teamsAction: string;
connectors: string;
}>;
Expand Down
1 change: 1 addition & 0 deletions packages/kbn-journeys/journey/journey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export interface BaseStepCtx {
kibanaServer: KibanaServer;
es: Es;
retry: RetryService;
auth: Auth;
}

export type AnyStep = Step<{}>;
Expand Down
6 changes: 4 additions & 2 deletions packages/kbn-journeys/journey/journey_ftr_harness.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,11 @@ export class JourneyFtrHarness {

private async setupBrowserAndPage() {
const browser = await this.getBrowserInstance();
this.context = await browser.newContext({ bypassCSP: true });
const browserContextArgs = this.auth.isCloud() ? {} : { bypassCSP: true };
this.context = await browser.newContext(browserContextArgs);

if (this.journeyConfig.shouldAutoLogin()) {
const cookie = await this.auth.login({ username: 'elastic', password: 'changeme' });
const cookie = await this.auth.login();
await this.context.addCookies([cookie]);
}

Expand Down Expand Up @@ -373,6 +374,7 @@ export class JourneyFtrHarness {
kibanaServer: this.kibanaServer,
es: this.es,
retry: this.retry,
auth: this.auth,
});

return this.#_ctx;
Expand Down
29 changes: 24 additions & 5 deletions packages/kbn-journeys/services/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,18 @@ export class Auth {
private readonly kibanaServer: KibanaServer
) {}

public async login({ username, password }: Credentials) {
public async login(credentials?: Credentials) {
const baseUrl = new URL(
Url.format({
protocol: this.config.get('servers.kibana.protocol'),
hostname: this.config.get('servers.kibana.hostname'),
port: this.config.get('servers.kibana.port'),
})
);

const loginUrl = new URL('/internal/security/login', baseUrl);
const provider = baseUrl.hostname === 'localhost' ? 'basic' : 'cloud-basic';
const provider = this.isCloud() ? 'cloud-basic' : 'basic';

const version = await this.kibanaServer.version.get();

this.log.info('fetching auth cookie from', loginUrl.href);
const authResponse = await axios.request({
Expand All @@ -49,18 +50,24 @@ export class Auth {
providerType: 'basic',
providerName: provider,
currentURL: new URL('/login?next=%2F', baseUrl).href,
params: { username, password },
params: credentials ?? { username: this.getUsername(), password: this.getPassword() },
},
headers: {
'content-type': 'application/json',
'kbn-version': await this.kibanaServer.version.get(),
'kbn-version': version,
'sec-fetch-mode': 'cors',
'sec-fetch-site': 'same-origin',
},
validateStatus: () => true,
maxRedirects: 0,
});

if (authResponse.status !== 200) {
throw new Error(
`Kibana auth failed: code: ${authResponse.status}, message: ${authResponse.statusText}`
);
}

const cookie = extractCookieValue(authResponse);
if (cookie) {
this.log.info('captured auth cookie');
Expand All @@ -82,4 +89,16 @@ export class Auth {
url: baseUrl.href,
};
}

public getUsername() {
return this.config.get('servers.kibana.username');
}

public getPassword() {
return this.config.get('servers.kibana.password');
}

public isCloud() {
return this.config.get('servers.kibana.hostname') !== 'localhost';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,10 @@ export const stackManagementSchema: MakeSchemaFrom<UsageStats> = {
type: 'text',
_meta: { description: 'Non-default value of setting.' },
},
'observability:syntheticsThrottlingEnabled': {
type: 'boolean',
_meta: { description: 'Non-default value of setting.' },
},
'observability:enableInspectEsQueries': {
type: 'boolean',
_meta: { description: 'Non-default value of setting.' },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ export interface UsageStats {
hideAnnouncements: boolean;
isDefaultIndexMigrated: boolean;
'metrics:allowCheckingForFailedShards': boolean;
'observability:syntheticsThrottlingEnabled': boolean;
'observability:apmLabsButton': boolean;
'observability:enableAwsLambdaMetrics': boolean;
'observability:apmProgressiveLoading': string;
Expand Down
6 changes: 6 additions & 0 deletions src/plugins/telemetry/schema/oss_plugins.json
Original file line number Diff line number Diff line change
Expand Up @@ -9148,6 +9148,12 @@
"description": "Non-default value of setting."
}
},
"observability:syntheticsThrottlingEnabled": {
"type": "boolean",
"_meta": {
"description": "Non-default value of setting."
}
},
"observability:maxSuggestions": {
"type": "integer",
"_meta": {
Expand Down
9 changes: 6 additions & 3 deletions x-pack/performance/journeys/login.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,14 @@ export const journey = new Journey({
],
maxDuration: '10m',
},
}).step('Login', async ({ page, kbnUrl, inputDelays }) => {
}).step('Login', async ({ page, kbnUrl, inputDelays, auth }) => {
await page.goto(kbnUrl.get());
if (auth.isCloud()) {
await page.click(subj('loginCard-basic/cloud-basic'), { delay: inputDelays.MOUSE_CLICK });
}

await page.type(subj('loginUsername'), 'elastic', { delay: inputDelays.TYPING });
await page.type(subj('loginPassword'), 'changeme', { delay: inputDelays.TYPING });
await page.type(subj('loginUsername'), auth.getUsername(), { delay: inputDelays.TYPING });
await page.type(subj('loginPassword'), auth.getPassword(), { delay: inputDelays.TYPING });
await page.click(subj('loginSubmit'), { delay: inputDelays.MOUSE_CLICK });

await waitForChrome(page);
Expand Down
Loading

0 comments on commit 41c1b9f

Please sign in to comment.