Skip to content

Commit

Permalink
Merge branch 'apm-fleet-apm-integration-e2e' of github.com:cauemarcon…
Browse files Browse the repository at this point in the history
…des/kibana into apm-fleet-apm-integration-e2e
  • Loading branch information
cauemarcondes committed Feb 15, 2022
2 parents 5b44678 + 118b995 commit a0698a5
Show file tree
Hide file tree
Showing 305 changed files with 12,874 additions and 2,798 deletions.
11 changes: 11 additions & 0 deletions .buildkite/pipelines/docker_context.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
steps:
- command: .buildkite/scripts/steps/docker_context/build.sh
label: 'Docker Build Context'
agents:
queue: n2-4
timeout_in_minutes: 30
key: build-docker-context
retry:
automatic:
- exit_status: '*'
limit: 1
19 changes: 12 additions & 7 deletions .buildkite/scripts/steps/cloud/build_and_deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,16 @@ node scripts/build \
CLOUD_IMAGE=$(docker images --format "{{.Repository}}:{{.Tag}}" docker.elastic.co/kibana-ci/kibana-cloud)
CLOUD_DEPLOYMENT_NAME="kibana-pr-$BUILDKITE_PULL_REQUEST"

jq '
.resources.kibana[0].plan.kibana.docker_image = "'$CLOUD_IMAGE'" |
.name = "'$CLOUD_DEPLOYMENT_NAME'" |
.resources.kibana[0].plan.kibana.version = "'$VERSION'" |
.resources.elasticsearch[0].plan.elasticsearch.version = "'$VERSION'"
' .buildkite/scripts/steps/cloud/deploy.json > /tmp/deploy.json

CLOUD_DEPLOYMENT_ID=$(ecctl deployment list --output json | jq -r '.deployments[] | select(.name == "'$CLOUD_DEPLOYMENT_NAME'") | .id')
JSON_FILE=$(mktemp --suffix ".json")
if [ -z "${CLOUD_DEPLOYMENT_ID}" ]; then
jq '
.resources.kibana[0].plan.kibana.docker_image = "'$CLOUD_IMAGE'" |
.name = "'$CLOUD_DEPLOYMENT_NAME'" |
.resources.kibana[0].plan.kibana.version = "'$VERSION'" |
.resources.elasticsearch[0].plan.elasticsearch.version = "'$VERSION'"
' .buildkite/scripts/steps/cloud/deploy.json > /tmp/deploy.json

ecctl deployment create --track --output json --file /tmp/deploy.json &> "$JSON_FILE"
CLOUD_DEPLOYMENT_USERNAME=$(jq --slurp '.[]|select(.resources).resources[] | select(.credentials).credentials.username' "$JSON_FILE")
CLOUD_DEPLOYMENT_PASSWORD=$(jq --slurp '.[]|select(.resources).resources[] | select(.credentials).credentials.password' "$JSON_FILE")
Expand All @@ -59,6 +59,11 @@ if [ -z "${CLOUD_DEPLOYMENT_ID}" ]; then

retry 5 5 vault write "secret/kibana-issues/dev/cloud-deploy/$CLOUD_DEPLOYMENT_NAME" username="$CLOUD_DEPLOYMENT_USERNAME" password="$CLOUD_DEPLOYMENT_PASSWORD"
else
ecctl deployment show "$CLOUD_DEPLOYMENT_ID" --generate-update-payload | jq '
.resources.kibana[0].plan.kibana.docker_image = "'$CLOUD_IMAGE'" |
.resources.kibana[0].plan.kibana.version = "'$VERSION'" |
.resources.elasticsearch[0].plan.elasticsearch.version = "'$VERSION'"
' > /tmp/deploy.json
ecctl deployment update "$CLOUD_DEPLOYMENT_ID" --track --output json --file /tmp/deploy.json &> "$JSON_FILE"
fi

Expand Down
16 changes: 16 additions & 0 deletions .buildkite/scripts/steps/docker_context/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

set -euo pipefail

.buildkite/scripts/bootstrap.sh

echo "--- Create Kibana Docker contexts"
mkdir -p target
node scripts/build --skip-initialize --skip-generic-folders --skip-platform-folders --skip-archives

echo "--- Build default context"
DOCKER_BUILD_FOLDER=$(mktemp -d)

tar -xf target/kibana-[0-9]*-docker-build-context.tar.gz -C "$DOCKER_BUILD_FOLDER"
cd $DOCKER_BUILD_FOLDER
docker build .
3 changes: 1 addition & 2 deletions .buildkite/scripts/steps/storybooks/build_and_upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ const STORYBOOKS = [
'canvas',
'ci_composite',
'cloud',
'codeeditor',
'custom_integrations',
'dashboard_enhanced',
'dashboard',
Expand All @@ -31,13 +30,13 @@ const STORYBOOKS = [
'expression_tagcloud',
'fleet',
'infra',
'kibana_react',
'lists',
'observability',
'presentation',
'security_solution',
'shared_ux',
'ui_actions_enhanced',
'url_template_editor',
];

const GITHUB_CONTEXT = 'Build and Publish Storybooks';
Expand Down
12 changes: 12 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -886,6 +886,18 @@ module.exports = {
],
},
},
{
// require explicit return types in route handlers for performance reasons
files: ['x-pack/plugins/apm/server/**/route.ts'],
rules: {
'@typescript-eslint/explicit-function-return-type': [
'error',
{
allowTypedFunctionExpressions: false,
},
],
},
},

/**
* Fleet overrides
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ export declare type KibanaExecutionContext = {
readonly type: string;
readonly name: string;
readonly id: string;
readonly description: string;
readonly description?: string;
readonly url?: string;
parent?: KibanaExecutionContext;
child?: KibanaExecutionContext;
};
```
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ export declare type KibanaExecutionContext = {
readonly type: string;
readonly name: string;
readonly id: string;
readonly description: string;
readonly description?: string;
readonly url?: string;
parent?: KibanaExecutionContext;
child?: KibanaExecutionContext;
};
```
2 changes: 1 addition & 1 deletion docs/osquery/osquery.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ or <<osquery-map-fields,map ECS fields>>. When you add a saved query to a pack,
. Click a pack name to view the status.
+
Details include the last time each query ran, how many results were returned, and the number of agents the query ran against.
If there are errors, expand the row to view the details.
If there are errors, expand the row to view the details, including an option to view more information in the Logs.
+
[role="screenshot"]
image::images/scheduled-pack.png[Shows queries in the pack and details about each query, including the last time it ran, how many results were returned, the number of agents it ran against, and if there are errors]
Expand Down
5 changes: 2 additions & 3 deletions docs/user/ml/index.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ If {stack-security-features} are enabled, users must have the necessary
privileges to use {ml-features}. Refer to
{ml-docs}/setup.html#setup-privileges[Set up {ml-features}].

NOTE: There are limitations in {ml-features} that affect {kib}. For more information, refer to {ml-docs}/ml-limitations.html[Machine learning].
NOTE: There are limitations in {ml-features} that affect {kib}. For more
information, refer to {ml-docs}/ml-limitations.html[{ml-cap}].

--

Expand Down Expand Up @@ -84,8 +85,6 @@ and {ml-docs}/ml-ad-overview.html[{ml-cap} {anomaly-detect}].
[[xpack-ml-dfanalytics]]
== {dfanalytics-cap}

experimental[]

The Elastic {ml} {dfanalytics} feature enables you to analyze your data using
{classification}, {oldetection}, and {regression} algorithms and generate new
indices that contain the results alongside your source data.
Expand Down
20 changes: 10 additions & 10 deletions docs/user/troubleshooting/trace-query.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,16 @@ Now, you can see the request to {es} has been initiated by the `[Logs] Unique Vi
[source,text]
----
[DEBUG][execution_context] stored the execution context: {
"parent": {
"type": "application",
"name": "dashboard",
"id": "edf84fe0-e1a0-11e7-b6d5-4dc382ef7f5b",
"description": "[Logs] Web Traffic","url":"/view/edf84fe0-e1a0-11e7-b6d5-4dc382ef7f5b"
"type": "application",
"name": "dashboard",
"id": "edf84fe0-e1a0-11e7-b6d5-4dc382ef7f5b",
"description": "[Logs] Web Traffic","url":"/view/edf84fe0-e1a0-11e7-b6d5-4dc382ef7f5b"
"child": {
"type": "visualization",
"name": "Vega",
"id": "cb099a20-ea66-11eb-9425-113343a037e3",
"description": "[Logs] Unique Visitor Heatmap",
"url": "/app/visualize#/edit/cb099a20-ea66-11eb-9425-113343a037e3"
},
"type": "visualization",
"name": "Vega",
"id": "cb099a20-ea66-11eb-9425-113343a037e3",
"description": "[Logs] Unique Visitor Heatmap",
"url": "/app/visualize#/edit/cb099a20-ea66-11eb-9425-113343a037e3"
}
----
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@
"base64-js": "^1.3.1",
"bitmap-sdf": "^1.0.3",
"brace": "0.11.1",
"broadcast-channel": "^4.9.0",
"broadcast-channel": "^4.10.0",
"canvg": "^3.0.9",
"chalk": "^4.1.0",
"cheerio": "^1.0.0-rc.10",
Expand Down
89 changes: 89 additions & 0 deletions packages/kbn-dev-utils/src/ci_stats_reporter/ci_stats_client.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
/*
* 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 Axios from 'axios';
import { ToolingLog } from '../tooling_log';

import { parseConfig, Config } from './ci_stats_config';
import { CiStatsMetadata } from './ci_stats_metadata';

interface LatestTestGroupStatsOptions {
/** The Kibana branch to get stats for, eg "main" */
branch: string;
/** The CI job names to filter builds by, eg "kibana-hourly" */
ciJobNames: string[];
/** Filter test groups by group type */
testGroupType?: string;
}

interface CompleteSuccessBuildSource {
jobName: string;
jobRunner: string;
completedAt: string;
commit: string;
startedAt: string;
branch: string;
result: 'SUCCESS';
jobId: string;
targetBranch: string | null;
fromKibanaCiProduction: boolean;
requiresValidMetrics: boolean | null;
jobUrl: string;
mergeBase: string | null;
}

interface TestGroupSource {
'@timestamp': string;
buildId: string;
name: string;
type: string;
startTime: string;
durationMs: number;
meta: CiStatsMetadata;
}

interface LatestTestGroupStatsResp {
build: CompleteSuccessBuildSource & { id: string };
testGroups: Array<TestGroupSource & { id: string }>;
}

export class CiStatsClient {
/**
* Create a CiStatsReporter by inspecting the ENV for the necessary config
*/
static fromEnv(log: ToolingLog) {
return new CiStatsClient(parseConfig(log));
}

constructor(private readonly config?: Config) {}

isEnabled() {
return !!this.config?.apiToken;
}

async getLatestTestGroupStats(options: LatestTestGroupStatsOptions) {
if (!this.config || !this.config.apiToken) {
throw new Error('No ciStats config available, call `isEnabled()` before using the client');
}

const resp = await Axios.request<LatestTestGroupStatsResp>({
baseURL: 'https://ci-stats.kibana.dev',
url: '/v1/test_group_stats',
params: {
branch: options.branch,
ci_job_name: options.ciJobNames.join(','),
test_group_type: options.testGroupType,
},
headers: {
Authentication: `token ${this.config.apiToken}`,
},
});

return resp.data;
}
}
16 changes: 16 additions & 0 deletions packages/kbn-dev-utils/src/ci_stats_reporter/ci_stats_metadata.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* 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.
*/

/** Container for metadata that can be attached to different ci-stats objects */
export interface CiStatsMetadata {
/**
* Arbitrary key-value pairs which can be attached to CiStatsTiming and CiStatsMetric
* objects stored in the ci-stats service
*/
[key: string]: string | string[] | number | boolean | undefined;
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,10 @@ import httpAdapter from 'axios/lib/adapters/http';
import { ToolingLog } from '../tooling_log';
import { parseConfig, Config } from './ci_stats_config';
import type { CiStatsTestGroupInfo, CiStatsTestRun } from './ci_stats_test_group_types';
import { CiStatsMetadata } from './ci_stats_metadata';

const BASE_URL = 'https://ci-stats.kibana.dev';

/** Container for metadata that can be attached to different ci-stats objects */
export interface CiStatsMetadata {
/**
* Arbitrary key-value pairs which can be attached to CiStatsTiming and CiStatsMetric
* objects stored in the ci-stats service
*/
[key: string]: string | string[] | number | boolean | undefined;
}

/** A ci-stats metric record */
export interface CiStatsMetric {
/** Top-level categorization for the metric, e.g. "page load bundle size" */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Side Public License, v 1.
*/

import type { CiStatsMetadata } from './ci_stats_reporter';
import type { CiStatsMetadata } from './ci_stats_metadata';

export type CiStatsTestResult = 'fail' | 'pass' | 'skip';
export type CiStatsTestType =
Expand Down
1 change: 1 addition & 0 deletions packages/kbn-dev-utils/src/ci_stats_reporter/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ export type { Config } from './ci_stats_config';
export * from './ship_ci_stats_cli';
export { getTimeReporter } from './report_time';
export * from './ci_stats_test_group_types';
export * from './ci_stats_client';
2 changes: 1 addition & 1 deletion packages/kbn-pm/dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9049,7 +9049,7 @@ var _ci_stats_config = __webpack_require__(218);
*/
// @ts-expect-error not "public", but necessary to prevent Jest shimming from breaking things
const BASE_URL = 'https://ci-stats.kibana.dev';
/** Container for metadata that can be attached to different ci-stats objects */
/** A ci-stats metric record */

/** Object that helps report data to the ci-stats service */
class CiStatsReporter {
Expand Down
Loading

0 comments on commit a0698a5

Please sign in to comment.