Skip to content

Commit

Permalink
Merge branch '7.8' of github.com:elastic/kibana into 7.8
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasneirynck committed Jun 8, 2020
2 parents 3b71eb2 + 3e76914 commit f5a294a
Show file tree
Hide file tree
Showing 20 changed files with 3,087 additions and 56 deletions.
1 change: 1 addition & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ kibanaPipeline(timeoutMinutes: 135, checkPrChanges: true) {
'xpack-ciGroup9': kibanaPipeline.xpackCiGroupProcess(9),
'xpack-ciGroup10': kibanaPipeline.xpackCiGroupProcess(10),
'xpack-accessibility': kibanaPipeline.functionalTestProcess('xpack-accessibility', './test/scripts/jenkins_xpack_accessibility.sh'),
'xpack-pageLoadMetrics': kibanaPipeline.functionalTestProcess('xpack-pageLoadMetrics', './test/scripts/jenkins_xpack_page_load_metrics.sh'),
'xpack-siemCypress': { processNumber ->
whenChanged(['x-pack/plugins/siem/', 'x-pack/test/siem_cypress/']) {
kibanaPipeline.functionalTestProcess('xpack-siemCypress', './test/scripts/jenkins_siem_cypress.sh')(processNumber)
Expand Down
2 changes: 1 addition & 1 deletion docs/apm/advanced-queries.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ or, to only show transactions that are slower than a specified time threshold.
==== Example APM app queries

* Exclude response times slower than 2000 ms: `transaction.duration.us > 2000000`
* Filter by response status code: `context.response.status_code >= 400`
* Filter by response status code: `context.response.status_code 400`
* Filter by single user ID: `context.user.id : 12`

When querying in the APM app, you're merely searching and selecting data from fields in Elasticsearch documents.
Expand Down
18 changes: 9 additions & 9 deletions docs/apm/service-maps.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ Machine learning jobs can be created to calculate anomaly scores on APM transact
When these jobs are active, service maps will display a color-coded anomaly indicator based on the detected anomaly score:

[horizontal]
image:apm/images/green-service.png[APM green service]:: Max anomaly score **<=25**. Service is healthy.
image:apm/images/green-service.png[APM green service]:: Max anomaly score **25**. Service is healthy.
image:apm/images/yellow-service.png[APM yellow service]:: Max anomaly score **26-74**. Anomalous activity detected. Service may be degraded.
image:apm/images/red-service.png[APM red service]:: Max anomaly score **>=75**. Anomalous activity detected. Service is unhealthy.
image:apm/images/red-service.png[APM red service]:: Max anomaly score **75**. Anomalous activity detected. Service is unhealthy.

[role="screenshot"]
image::apm/images/apm-service-map-anomaly.png[Example view of anomaly scores on service maps in the APM app]
Expand Down Expand Up @@ -92,10 +92,10 @@ Type and subtype are based on `span.type`, and `span.subtype`.
Service maps are supported for the following Agent versions:

[horizontal]
Go Agent:: >= v1.7.0
Java Agent:: >= v1.13.0
.NET Agent:: >= v1.3.0
Node.js Agent:: >= v3.6.0
Python Agent:: >= v5.5.0
Ruby Agent:: >= v3.6.0
Real User Monitoring (RUM) Agent:: >= v4.7.0
Go Agent:: v1.7.0
Java Agent:: v1.13.0
.NET Agent:: v1.3.0
Node.js Agent:: v3.6.0
Python Agent:: v5.5.0
Ruby Agent:: v3.6.0
Real User Monitoring (RUM) Agent:: v4.7.0
2 changes: 2 additions & 0 deletions packages/kbn-test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"@kbn/babel-preset": "1.0.0",
"@kbn/dev-utils": "1.0.0",
"@types/parse-link-header": "^1.0.0",
"@types/puppeteer": "^3.0.0",
"@types/strip-ansi": "^5.2.1",
"@types/xml2js": "^0.4.5",
"diff": "^4.0.1"
Expand All @@ -25,6 +26,7 @@
"getopts": "^2.2.4",
"glob": "^7.1.2",
"parse-link-header": "^1.0.1",
"puppeteer": "^3.3.0",
"strip-ansi": "^5.2.0",
"rxjs": "^6.5.3",
"tar-fs": "^1.16.3",
Expand Down
2 changes: 2 additions & 0 deletions packages/kbn-test/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,5 @@ export { runFailedTestsReporterCli } from './failed_tests_reporter';
export { makeJunitReportPath } from './junit_report_path';

export { CI_PARALLEL_PROCESS_PREFIX } from './ci_parallel_process_prefix';

export * from './page_load_metrics';
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import { ToolingLog } from '@kbn/dev-utils';
import { NavigationOptions, createUrl, navigateToApps } from './navigation';

export async function capturePageLoadMetrics(log: ToolingLog, options: NavigationOptions) {
const responsesByPageView = await navigateToApps(log, options);

const assetSizeMeasurements = new Map<string, number[]>();

const numberOfPagesVisited = responsesByPageView.size;

for (const [, frameResponses] of responsesByPageView) {
for (const [, { url, dataLength }] of frameResponses) {
if (url.length === 0) {
throw new Error('navigateToApps(); failed to identify the url of the request');
}
if (assetSizeMeasurements.has(url)) {
assetSizeMeasurements.set(url, [dataLength].concat(assetSizeMeasurements.get(url) || []));
} else {
assetSizeMeasurements.set(url, [dataLength]);
}
}
}

return Array.from(assetSizeMeasurements.entries())
.map(([url, measurements]) => {
const baseUrl = createUrl('/', options.appConfig.url);
const relativeUrl = url
// remove the baseUrl (expect the trailing slash) to make url relative
.replace(baseUrl.slice(0, -1), '')
// strip the build number from asset urls
.replace(/^\/\d+\//, '/');
return [relativeUrl, measurements] as const;
})
.filter(([url, measurements]) => {
if (measurements.length !== numberOfPagesVisited) {
// ignore urls seen only on some pages
return false;
}

if (url.startsWith('data:')) {
// ignore data urls since they are already counted by other assets
return false;
}

if (url.startsWith('/api/') || url.startsWith('/internal/')) {
// ignore api requests since they don't have deterministic sizes
return false;
}

const allMetricsAreEqual = measurements.every((x, i) =>
i === 0 ? true : x === measurements[i - 1]
);
if (!allMetricsAreEqual) {
throw new Error(`measurements for url [${url}] are not equal [${measurements.join(',')}]`);
}

return true;
})
.map(([url, measurements]) => {
return { group: 'page load asset size', id: url, value: measurements[0] };
});
}
90 changes: 90 additions & 0 deletions packages/kbn-test/src/page_load_metrics/cli.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import Url from 'url';

import { run, createFlagError } from '@kbn/dev-utils';
import { resolve, basename } from 'path';
import { capturePageLoadMetrics } from './capture_page_load_metrics';

const defaultScreenshotsDir = resolve(__dirname, 'screenshots');

export function runPageLoadMetricsCli() {
run(
async ({ flags, log }) => {
const kibanaUrl = flags['kibana-url'];
if (!kibanaUrl || typeof kibanaUrl !== 'string') {
throw createFlagError('Expect --kibana-url to be a string');
}

const parsedUrl = Url.parse(kibanaUrl);

const [username, password] = parsedUrl.auth
? parsedUrl.auth.split(':')
: [flags.username, flags.password];

if (typeof username !== 'string' || typeof password !== 'string') {
throw createFlagError(
'Mising username and/or password, either specify in --kibana-url or pass --username and --password'
);
}

const headless = !flags.head;

const screenshotsDir = flags.screenshotsDir || defaultScreenshotsDir;

if (typeof screenshotsDir !== 'string' || screenshotsDir === basename(screenshotsDir)) {
throw createFlagError('Expect screenshotsDir to be valid path string');
}

const metrics = await capturePageLoadMetrics(log, {
headless,
appConfig: {
url: kibanaUrl,
username,
password,
},
screenshotsDir,
});
for (const metric of metrics) {
log.info(`${metric.id}: ${metric.value}`);
}
},
{
description: `Loads several pages with Puppeteer to capture the size of assets`,
flags: {
string: ['kibana-url', 'username', 'password', 'screenshotsDir'],
boolean: ['head'],
default: {
username: 'elastic',
password: 'changeme',
debug: true,
screenshotsDir: defaultScreenshotsDir,
},
help: `
--kibana-url Url for Kibana we should connect to, can include login info
--head Run puppeteer with graphical user interface
--username Set username, defaults to 'elastic'
--password Set password, defaults to 'changeme'
--screenshotsDir Set screenshots directory, defaults to '${defaultScreenshotsDir}'
`,
},
}
);
}
34 changes: 34 additions & 0 deletions packages/kbn-test/src/page_load_metrics/event.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

export interface ResponseReceivedEvent {
frameId: string;
loaderId: string;
requestId: string;
response: Record<string, any>;
timestamp: number;
type: string;
}

export interface DataReceivedEvent {
encodedDataLength: number;
dataLength: number;
requestId: string;
timestamp: number;
}
21 changes: 21 additions & 0 deletions packages/kbn-test/src/page_load_metrics/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

export * from './cli';
export { capturePageLoadMetrics } from './capture_page_load_metrics';
Loading

0 comments on commit f5a294a

Please sign in to comment.