Skip to content

Commit

Permalink
Merge branch 'main' into charts_expressions-pie-lens-adaptation
Browse files Browse the repository at this point in the history
  • Loading branch information
Kuznietsov committed Feb 4, 2022
2 parents 49cf182 + a5b4b82 commit 427a0a3
Show file tree
Hide file tree
Showing 852 changed files with 4,424 additions and 1,690 deletions.
2 changes: 1 addition & 1 deletion dev_docs/api_welcome.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
id: kibDevDocsApiWelcome
slug: /kibana-dev-docs/api-meta/welcome
title: Welcome
summary: How to use our automatically generated API documentation
description: How to use our automatically generated API documentation
date: 2021-02-25
tags: ['kibana','dev', 'contributor', 'api docs']
---
Expand Down
14 changes: 11 additions & 3 deletions dev_docs/getting_started/add_data.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
id: kibDevAddData
slug: /kibana-dev-docs/getting-started/sample-data
title: Add data
summary: Learn how to add data to Kibana
description: Learn how to add data to Kibana
date: 2021-08-11
tags: ['kibana', 'onboarding', 'dev', 'architecture', 'tutorials']
---

Building a feature and need an easy way to test it out with some data? Below are three options.

## 1. Add Sample Data from the UI
## Sample data

Kibana ships with sample data that you can install at the click of the button. If you are building a feature and need some data to test it out with, sample data is a great option. The only limitation is that this data will not work for Security or Observability solutions (see [#62962](https://github.com/elastic/kibana/issues/62962)).

Expand All @@ -20,7 +20,7 @@ Kibana ships with sample data that you can install at the click of the button. I

![Sample Data](../assets/sample_data.png)

## CSV Upload
## CSV upload

1. If you don't have any data, navigate to Stack Management > Index Patterns and click the link to the uploader. If you do have data, navigate to the **Machine Learning** application.
2. Click on the **Data Visualizer** tab.
Expand All @@ -35,3 +35,11 @@ The makelogs script generates sample web server logs. Make sure Elasticsearch is
```sh
node scripts/makelogs --auth <username>:<password>
```

## Realistic solution data

<DocCallOut color="warning" title="Internal only">

Security and Observability solution applications only work if data exists in particularly named indices, abiding by our [ECS format](https://www.elastic.co/guide/en/ecs/current/index.html). If you would like to use these applications with realistic data, check out the [oblt_cli tool](https://github.com/elastic/observability-test-environments/blob/master/tools/oblt_cli/README.md). This tool sets you up to connect to a remote Elasticsearch cluster that contains the appropriate data via CCS.

</DocCallOut>
2 changes: 1 addition & 1 deletion dev_docs/kibana_server_core_components.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
id: kibServerAndCoreComponents
slug: /kibana-dev-docs/core-intro
title: Kibana Server and Core components
summary: An introduction to the Kibana server and core components.
description: An introduction to the Kibana server and core components.
date: 2021-02-26
tags: ['kibana','onboarding', 'dev', 'architecture']
---
Expand Down
2 changes: 0 additions & 2 deletions docs/CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ Review important information about the {kib} 8.0.0 releases.
[[release-notes-8.0.0-rc2]]
== {kib} 8.0.0-rc2

coming::[8.0.0-rc2]

For information about the {kib} 8.0.0-rc2 release, review the following information.

[float]
Expand Down
2 changes: 1 addition & 1 deletion docs/development/core/server/kibana-plugin-core-server.md
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ The plugin integrates with the core system via lifecycle events: `setup`<!-- -->
| --- | --- |
| [APP\_WRAPPER\_CLASS](./kibana-plugin-core-server.app_wrapper_class.md) | The class name for top level \*and\* nested application wrappers to ensure proper layout |
| [kibanaResponseFactory](./kibana-plugin-core-server.kibanaresponsefactory.md) | Set of helpers used to create <code>KibanaResponse</code> to form HTTP response on an incoming request. Should be returned as a result of [RequestHandler](./kibana-plugin-core-server.requesthandler.md) execution. |
| [mergeSavedObjectMigrationMaps](./kibana-plugin-core-server.mergesavedobjectmigrationmaps.md) | Merges two saved object migration maps. |
| [mergeSavedObjectMigrationMaps](./kibana-plugin-core-server.mergesavedobjectmigrationmaps.md) | Merges two saved object migration maps.<!-- -->If there is a migration for a given version on only one of the maps, that migration function will be used:<!-- -->mergeSavedObjectMigrationMaps(<!-- -->{ '1.2.3': f }<!-- -->, { '4.5.6': g }<!-- -->) -<!-- -->&gt; { '1.2.3': f, '4.5.6': g }<!-- -->If there is a migration for a given version on both maps, the migrations will be composed:<!-- -->mergeSavedObjectMigrationMaps(<!-- -->{ '1.2.3': f }<!-- -->, { '1.2.3': g }<!-- -->) -<!-- -->&gt; { '1.2.3': (doc, context) =<!-- -->&gt; f(g(doc, context), context) } |
| [pollEsNodesVersion](./kibana-plugin-core-server.pollesnodesversion.md) | |
| [ServiceStatusLevels](./kibana-plugin-core-server.servicestatuslevels.md) | The current "level" of availability of a service. |
| [validBodyOutput](./kibana-plugin-core-server.validbodyoutput.md) | The set of valid body.output |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@

Merges two saved object migration maps.

If there is a migration for a given version on only one of the maps, that migration function will be used:

mergeSavedObjectMigrationMaps(<!-- -->{ '1.2.3': f }<!-- -->, { '4.5.6': g }<!-- -->) -<!-- -->&gt; { '1.2.3': f, '4.5.6': g }

If there is a migration for a given version on both maps, the migrations will be composed:

mergeSavedObjectMigrationMaps(<!-- -->{ '1.2.3': f }<!-- -->, { '1.2.3': g }<!-- -->) -<!-- -->&gt; { '1.2.3': (doc, context) =<!-- -->&gt; f(g(doc, context), context) }

<b>Signature:</b>

```typescript
Expand Down
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,7 @@
"@emotion/babel-preset-css-prop": "^11.2.0",
"@emotion/jest": "^11.3.0",
"@istanbuljs/schema": "^0.1.2",
"@jest/console": "^26.6.2",
"@jest/reporters": "^26.6.2",
"@kbn/babel-code-parser": "link:bazel-bin/packages/kbn-babel-code-parser",
"@kbn/babel-preset": "link:bazel-bin/packages/kbn-babel-preset",
Expand All @@ -474,6 +475,7 @@
"@kbn/storybook": "link:bazel-bin/packages/kbn-storybook",
"@kbn/telemetry-tools": "link:bazel-bin/packages/kbn-telemetry-tools",
"@kbn/test": "link:bazel-bin/packages/kbn-test",
"@kbn/test-jest-helpers": "link:bazel-bin/packages/kbn-test-jest-helpers",
"@kbn/test-subj-selector": "link:bazel-bin/packages/kbn-test-subj-selector",
"@loaders.gl/polyfills": "^2.3.5",
"@mapbox/vector-tile": "1.3.1",
Expand Down Expand Up @@ -610,6 +612,8 @@
"@types/kbn__std": "link:bazel-bin/packages/kbn-std/npm_module_types",
"@types/kbn__storybook": "link:bazel-bin/packages/kbn-storybook/npm_module_types",
"@types/kbn__telemetry-tools": "link:bazel-bin/packages/kbn-telemetry-tools/npm_module_types",
"@types/kbn__test": "link:bazel-bin/packages/kbn-test/npm_module_types",
"@types/kbn__test-jest-helpers": "link:bazel-bin/packages/kbn-test-jest-helpers/npm_module_types",
"@types/kbn__ui-shared-deps-npm": "link:bazel-bin/packages/kbn-ui-shared-deps-npm/npm_module_types",
"@types/kbn__ui-shared-deps-src": "link:bazel-bin/packages/kbn-ui-shared-deps-src/npm_module_types",
"@types/kbn__ui-theme": "link:bazel-bin/packages/kbn-ui-theme/npm_module_types",
Expand Down
3 changes: 3 additions & 0 deletions packages/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ filegroup(
"//packages/kbn-storybook:build",
"//packages/kbn-telemetry-tools:build",
"//packages/kbn-test:build",
"//packages/kbn-test-jest-helpers:build",
"//packages/kbn-test-subj-selector:build",
"//packages/kbn-timelion-grammar:build",
"//packages/kbn-tinymath:build",
Expand Down Expand Up @@ -126,6 +127,8 @@ filegroup(
"//packages/kbn-std:build_types",
"//packages/kbn-storybook:build_types",
"//packages/kbn-telemetry-tools:build_types",
"//packages/kbn-test:build_types",
"//packages/kbn-test-jest-helpers:build_types",
"//packages/kbn-ui-shared-deps-npm:build_types",
"//packages/kbn-ui-shared-deps-src:build_types",
"//packages/kbn-ui-theme:build_types",
Expand Down
5 changes: 5 additions & 0 deletions packages/elastic-eslint-config-kibana/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ module.exports = {
to: false,
disallowedMessage: `Use "@kbn/ui-theme" to access theme vars.`
})),
{
from: '@kbn/test/jest',
to: '@kbn/test-jest-helpers',
disallowedMessage: `import from @kbn/test-jest-helpers instead`
},
],
],

Expand Down
2 changes: 2 additions & 0 deletions packages/kbn-dev-utils/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ NPM_MODULE_EXTRA_FILES = [

RUNTIME_DEPS = [
"//packages/kbn-utils",
"//packages/kbn-std",
"@npm//@babel/core",
"@npm//axios",
"@npm//chalk",
Expand All @@ -67,6 +68,7 @@ RUNTIME_DEPS = [

TYPES_DEPS = [
"//packages/kbn-utils:npm_module_types",
"//packages/kbn-std:npm_module_types",
"@npm//@babel/parser",
"@npm//@babel/types",
"@npm//@types/babel__core",
Expand Down
105 changes: 80 additions & 25 deletions packages/kbn-dev-utils/src/ci_stats_reporter/ci_stats_reporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,28 @@ import Os from 'os';
import Fs from 'fs';
import Path from 'path';
import crypto from 'crypto';

import execa from 'execa';
import Axios from 'axios';
import Axios, { AxiosRequestConfig } from 'axios';
// @ts-expect-error not "public", but necessary to prevent Jest shimming from breaking things
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';

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" */
group: string;
Expand All @@ -40,13 +52,7 @@ export interface CiStatsMetric {
meta?: CiStatsMetadata;
}

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 timing event */
export interface CiStatsTiming {
/** Top-level categorization for the timing, e.g. "scripts/foo", process type, etc. */
group: string;
Expand All @@ -58,13 +64,7 @@ export interface CiStatsTiming {
meta?: CiStatsMetadata;
}

interface ReqOptions {
auth: boolean;
path: string;
body: any;
bodyDesc: string;
}

/** Options for reporting timings to ci-stats */
export interface TimingsOptions {
/** list of timings to record */
timings: CiStatsTiming[];
Expand All @@ -74,10 +74,41 @@ export interface TimingsOptions {
kibanaUuid?: string | null;
}

/** Options for reporting metrics to ci-stats */
export interface MetricsOptions {
/** Default metadata to add to each metric */
defaultMeta?: CiStatsMetadata;
}

/** Options for reporting tests to ci-stats */
export interface CiStatsReportTestsOptions {
/**
* Information about the group of tests that were run
*/
group: CiStatsTestGroupInfo;
/**
* Information about each test that ran, including failure information
*/
testRuns: CiStatsTestRun[];
}

/* @internal */
interface ReportTestsResponse {
buildId: string;
groupId: string;
testRunCount: number;
}

/* @internal */
interface ReqOptions {
auth: boolean;
path: string;
body: any;
bodyDesc: string;
query?: AxiosRequestConfig['params'];
}

/** Object that helps report data to the ci-stats service */
export class CiStatsReporter {
/**
* Create a CiStatsReporter by inspecting the ENV for the necessary config
Expand All @@ -86,7 +117,7 @@ export class CiStatsReporter {
return new CiStatsReporter(parseConfig(log), log);
}

constructor(private config: Config | undefined, private log: ToolingLog) {}
constructor(private readonly config: Config | undefined, private readonly log: ToolingLog) {}

/**
* Determine if CI_STATS is explicitly disabled by the environment. To determine
Expand Down Expand Up @@ -165,7 +196,7 @@ export class CiStatsReporter {

this.log.debug('CIStatsReporter committerHash: %s', defaultMeta.committerHash);

return await this.req({
return !!(await this.req({
auth: !!buildId,
path: '/v1/timings',
body: {
Expand All @@ -175,7 +206,7 @@ export class CiStatsReporter {
timings,
},
bodyDesc: timings.length === 1 ? `${timings.length} timing` : `${timings.length} timings`,
});
}));
}

/**
Expand All @@ -188,12 +219,11 @@ export class CiStatsReporter {
}

const buildId = this.config?.buildId;

if (!buildId) {
throw new Error(`CiStatsReporter can't be authorized without a buildId`);
throw new Error(`metrics can't be reported without a buildId`);
}

return await this.req({
return !!(await this.req({
auth: true,
path: '/v1/metrics',
body: {
Expand All @@ -204,6 +234,30 @@ export class CiStatsReporter {
bodyDesc: `metrics: ${metrics
.map(({ group, id, value }) => `[${group}/${id}=${value}]`)
.join(' ')}`,
}));
}

/**
* Send test reports to ci-stats
*/
async reportTests({ group, testRuns }: CiStatsReportTestsOptions) {
if (!this.config?.buildId || !this.config?.apiToken) {
throw new Error(
'unable to report tests unless buildId is configured and auth config available'
);
}

return await this.req<ReportTestsResponse>({
auth: true,
path: '/v1/test_group',
query: {
buildId: this.config?.buildId,
},
bodyDesc: `[${group.name}/${group.type}] test groups with ${testRuns.length} tests`,
body: [
JSON.stringify({ group }),
...testRuns.map((testRun) => JSON.stringify({ testRun })),
].join('\n'),
});
}

Expand Down Expand Up @@ -241,7 +295,7 @@ export class CiStatsReporter {
}
}

private async req({ auth, body, bodyDesc, path }: ReqOptions) {
private async req<T>({ auth, body, bodyDesc, path, query }: ReqOptions) {
let attempt = 0;
const maxAttempts = 5;

Expand All @@ -251,23 +305,24 @@ export class CiStatsReporter {
Authorization: `token ${this.config.apiToken}`,
};
} else if (auth) {
throw new Error('this.req() shouldnt be called with auth=true if this.config is defined');
throw new Error('this.req() shouldnt be called with auth=true if this.config is not defined');
}

while (true) {
attempt += 1;

try {
await Axios.request({
const resp = await Axios.request<T>({
method: 'POST',
url: path,
baseURL: BASE_URL,
headers,
data: body,
params: query,
adapter: httpAdapter,
});

return true;
return resp.data;
} catch (error) {
if (!error?.request) {
// not an axios error, must be a usage error that we should notify user about
Expand Down
Loading

0 comments on commit 427a0a3

Please sign in to comment.