Skip to content

Commit

Permalink
Merge branch 'main' into connectors-deprecated-icon
Browse files Browse the repository at this point in the history
  • Loading branch information
kibanamachine authored Dec 6, 2021
2 parents 10772b9 + 1ea1870 commit 383d05c
Show file tree
Hide file tree
Showing 222 changed files with 11,922 additions and 4,242 deletions.
11 changes: 11 additions & 0 deletions .buildkite/pipelines/pull_request/osquery_cypress.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
steps:
- command: .buildkite/scripts/steps/functional/osquery_cypress.sh
label: 'Osquery Cypress Tests'
agents:
queue: ci-group-6
depends_on: build
timeout_in_minutes: 120
retry:
automatic:
- exit_status: '*'
limit: 1
10 changes: 10 additions & 0 deletions .buildkite/scripts/pipelines/pull_request/pipeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,16 @@ const uploadPipeline = (pipelineContent) => {
pipeline.push(getPipeline('.buildkite/pipelines/pull_request/fleet_cypress.yml'));
}

if (
(await doAnyChangesMatch([
/^x-pack\/plugins\/osquery/,
/^x-pack\/test\/osquery_cypress/,
])) ||
process.env.GITHUB_PR_LABELS.includes('ci:all-cypress-suites')
) {
pipeline.push(getPipeline('.buildkite/pipelines/pull_request/osquery_cypress.yml'));
}

if (await doAnyChangesMatch([/^x-pack\/plugins\/uptime/])) {
pipeline.push(getPipeline('.buildkite/pipelines/pull_request/uptime.yml'));
}
Expand Down
20 changes: 20 additions & 0 deletions .buildkite/scripts/steps/functional/osquery_cypress.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env bash

set -euo pipefail

source .buildkite/scripts/common/util.sh

.buildkite/scripts/bootstrap.sh
.buildkite/scripts/download_build_artifacts.sh

export JOB=kibana-osquery-cypress

echo "--- Osquery Cypress tests"

cd "$XPACK_DIR"

checks-reporter-with-killswitch "Osquery Cypress Tests" \
node scripts/functional_tests \
--debug --bail \
--kibana-install-dir "$KIBANA_BUILD_LOCATION" \
--config test/osquery_cypress/cli_config.ts
18 changes: 16 additions & 2 deletions dev_docs/key_concepts/performance.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ id: kibDevPerformance
slug: /kibana-dev-docs/key-concepts/performance
title: Performance
summary: Performance tips for Kibana development.
date: 2021-09-02
date: 2021-12-03
tags: ['kibana', 'onboarding', 'dev', 'performance']
---

## Keep Kibana fast
## Client-side considerations

### Lazy load code

_tl;dr_: Load as much code lazily as possible. Everyone loves snappy
applications with a responsive UI and hates spinners. Users deserve the
Expand Down Expand Up @@ -105,3 +107,15 @@ Many OSS tools allow you to analyze the generated stats file:
Webpack authors
- [webpack-visualizer](https://chrisbateman.github.io/webpack-visualizer/)
- [webpack-bundle-analyzer](https://github.com/webpack-contrib/webpack-bundle-analyzer)

## Server-side considerations

### Don't block the event loop

[Node.js is single threaded](https://nodejs.dev/learn/introduction-to-nodejs) which means a single CPU-intensive server-side, synchronous operation will block any other functionality waiting to execute on the Kibana server. The affects background tasks, like alerts, and search sessions, as well as search requests and page loads.

**When writing code that will run on the server, [don't block the event loop](https://nodejs.org/en/docs/guides/dont-block-the-event-loop/)**. Instead consider:

- Writing async code. For example, leverage [setImmediate](https://nodejs.dev/learn/understanding-setimmediate) inside for loops.
- Executing logic on the client instead. This may not be a good option if you require a lot of data going back and forth between the server and the client, as that can also slow down the user's experience, especially over slower bandwidth internet connections.
- Worker threads are also an option if the code doesn't rely on stateful Kibana services. If you are interested in using worker threads, please reach out to a tech-lead before doing so. We will likely want to implement a worker threads pool to ensure worker threads cooperate appropriately.
73 changes: 49 additions & 24 deletions docs/setup/docker.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,13 @@ https://github.com/elastic/dockerfiles/tree/{branch}/kibana[GitHub].
These images contain both free and subscription features.
<<managing-licenses,Start a 30-day trial>> to try out all of the features.

[float]
[discrete]
[[run-kibana-on-docker-for-dev]]
=== Run {kib} on Docker for development

. Start an {es} container for development or testing:
+
--
ifeval::["{release-state}"=="unreleased"]

NOTE: No Docker images are currently available for {kib} {version}.
Expand All @@ -26,14 +29,16 @@ endif::[]

ifeval::["{release-state}"!="unreleased"]

. Start an {es} container for development or testing:
+
[source,sh,subs="attributes"]
----
docker network create elastic
docker pull {es-docker-image}
docker run --name es-node01 --net elastic -p 9200:9200 -p 9300:9300 -t {es-docker-image}
----

endif::[]

--
+
When you start {es} for the first time, the following security configuration
occurs automatically:
Expand All @@ -51,30 +56,26 @@ and enrollment token.
. Copy the generated password and enrollment token and save them in a secure
location. These values are shown only when you start {es} for the first time.
You'll use these to enroll {kib} with your {es} cluster and log in.

. In a new terminal session, start {kib} and connect it to your {es} container:
+
[NOTE]
====
If you need to reset the password for the `elastic` user or other
built-in users, run the {ref}/reset-password.html[`elasticsearch-reset-password`]
tool. To generate new enrollment tokens for {kib} or {es} nodes, run the
{ref}/create-enrollment-token.html[`elasticsearch-create-enrollment-token`] tool.
These tools are available in the {es} `bin` directory of the Docker container.
--
ifeval::["{release-state}"=="unreleased"]

For example:
NOTE: No Docker images are currently available for {kib} {version}.

[source,sh]
----
docker exec -it es-node01 /usr/share/elasticsearch/bin/elasticsearch-reset-password -u elastic
----
====
endif::[]

ifeval::["{release-state}"!="unreleased"]

. In a new terminal session, start {kib} and connect it to your {es} container:
+
[source,sh,subs="attributes"]
----
docker pull {docker-image}
docker run --name kib-01 --net elastic -p 5601:5601 {docker-image}
----

endif::[]
--
+
When you start {kib}, a unique link is output to your terminal.

Expand All @@ -86,7 +87,32 @@ When you start {kib}, a unique link is output to your terminal.
.. Log in to {kib} as the `elastic` user with the password that was generated
when you started {es}.

[float]
[[docker-generate]]
[discrete]
=== Generate passwords and enrollment tokens
If you need to reset the password for the `elastic` user or other
built-in users, run the {ref}/reset-password.html[`elasticsearch-reset-password`]
tool. This tool is available in the {es} `bin` directory of the Docker container.

For example, to reset the password for the `elastic` user:

[source,sh]
----
docker exec -it es-node01 /usr/share/elasticsearch/bin/elasticsearch-reset-password -u elastic
----

If you need to generate new enrollment tokens for {kib} or {es} nodes, run the
{ref}/create-enrollment-token.html[`elasticsearch-create-enrollment-token`] tool.
This tool is available in the {es} `bin` directory of the Docker container.

For example, to generate a new enrollment token for {kib}:

[source,sh]
----
docker exec -it es-node01 /usr/share/elasticsearch/bin/elasticsearch-create-enrollment-token -s kibana
----

[discrete]
=== Remove Docker containers

To remove the containers and their network, run:
Expand All @@ -98,8 +124,7 @@ docker rm es-node01
docker rm kib-01
----

endif::[]
[float]
[discrete]
[[configuring-kibana-docker]]
=== Configure Kibana on Docker

Expand All @@ -108,7 +133,7 @@ conventional approach is to provide a `kibana.yml` file as described in
{kibana-ref}/settings.html[Configuring Kibana], but it's also possible to use
environment variables to define settings.

[float]
[discrete]
[[bind-mount-config]]
==== Bind-mounted configuration

Expand All @@ -135,7 +160,7 @@ docker run -it --rm -v full_path_to/config:/usr/share/kibana/config -v full_path
docker run -it --rm -v full_path_to/config:/usr/share/kibana/config -v full_path_to/data:/usr/share/kibana/data {docker-image} bin/kibana-keystore add test_keystore_setting
----

[float]
[discrete]
[[environment-variable-config]]
==== Environment variable configuration

Expand Down Expand Up @@ -179,7 +204,7 @@ services:
Since environment variables are translated to CLI arguments, they take
precedence over settings configured in `kibana.yml`.

[float]
[discrete]
[[docker-defaults]]
==== Docker defaults
The following settings have different default values when using the Docker
Expand Down
11 changes: 7 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
"**/hoist-non-react-statics": "^3.3.2",
"**/html-minifier/uglify-js": "^3.14.3",
"**/isomorphic-fetch/node-fetch": "^2.6.1",
"**/istanbul-instrumenter-loader/schema-utils": "1.0.0",
"**/istanbul-lib-coverage": "^3.2.0",
"**/json-schema": "^0.4.0",
"**/minimist": "^1.2.5",
"**/node-jose/node-forge": "^0.10.0",
Expand All @@ -103,7 +103,7 @@
"@elastic/apm-rum": "^5.9.1",
"@elastic/apm-rum-react": "^1.3.1",
"@elastic/apm-synthtrace": "link:bazel-bin/packages/elastic-apm-synthtrace",
"@elastic/charts": "40.0.0",
"@elastic/charts": "40.1.0",
"@elastic/datemath": "link:bazel-bin/packages/elastic-datemath",
"@elastic/elasticsearch": "npm:@elastic/elasticsearch-canary@^8.0.0-canary.35",
"@elastic/ems-client": "8.0.0",
Expand Down Expand Up @@ -436,6 +436,7 @@
"@babel/types": "^7.16.0",
"@bazel/ibazel": "^0.15.10",
"@bazel/typescript": "^3.8.0",
"@cypress/code-coverage": "^3.9.11",
"@cypress/snapshot": "^2.1.7",
"@cypress/webpack-preprocessor": "^5.6.0",
"@elastic/eslint-config-kibana": "link:bazel-bin/packages/elastic-eslint-config-kibana",
Expand Down Expand Up @@ -565,6 +566,7 @@
"@types/kbn__apm-utils": "link:bazel-bin/packages/kbn-apm-utils/npm_module_types",
"@types/kbn__cli-dev-mode": "link:bazel-bin/packages/kbn-cli-dev-mode/npm_module_types",
"@types/kbn__config": "link:bazel-bin/packages/kbn-config/npm_module_types",
"@types/kbn__config-schema": "link:bazel-bin/packages/kbn-config-schema/npm_module_types",
"@types/kbn__crypto": "link:bazel-bin/packages/kbn-crypto/npm_module_types",
"@types/kbn__i18n": "link:bazel-bin/packages/kbn-i18n/npm_module_types",
"@types/kbn__i18n-react": "link:bazel-bin/packages/kbn-i18n-react/npm_module_types",
Expand Down Expand Up @@ -695,7 +697,9 @@
"cypress-file-upload": "^5.0.8",
"cypress-multi-reporters": "^1.5.0",
"cypress-pipe": "^2.0.0",
"cypress-react-selector": "^2.3.13",
"cypress-real-events": "^1.5.1",
"cypress-recurse": "^1.13.1",
"debug": "^2.6.9",
"delete-empty": "^2.0.0",
"dependency-check": "^4.1.0",
Expand Down Expand Up @@ -750,7 +754,6 @@
"http-proxy": "^1.18.1",
"is-glob": "^4.0.1",
"is-path-inside": "^3.0.2",
"istanbul-instrumenter-loader": "^3.0.1",
"jest": "^26.6.3",
"jest-canvas-mock": "^2.3.1",
"jest-circus": "^26.6.3",
Expand Down Expand Up @@ -787,7 +790,7 @@
"ncp": "^2.0.0",
"node-sass": "^6.0.1",
"null-loader": "^3.0.0",
"nyc": "^15.0.1",
"nyc": "^15.1.0",
"oboe": "^2.1.4",
"parse-link-header": "^1.0.1",
"pbf": "3.2.1",
Expand Down
1 change: 1 addition & 0 deletions packages/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ filegroup(
"//packages/kbn-apm-utils:build_types",
"//packages/kbn-cli-dev-mode:build_types",
"//packages/kbn-config:build_types",
"//packages/kbn-config-schema:build_types",
"//packages/kbn-crypto:build_types",
"//packages/kbn-i18n:build_types",
"//packages/kbn-i18n-react:build_types",
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-cli-dev-mode/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ RUNTIME_DEPS = [

TYPES_DEPS = [
"//packages/kbn-config:npm_module_types",
"//packages/kbn-config-schema",
"//packages/kbn-config-schema:npm_module_types",
"//packages/kbn-dev-utils",
"//packages/kbn-logging",
"//packages/kbn-optimizer",
Expand Down
26 changes: 22 additions & 4 deletions packages/kbn-config-schema/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
load("@npm//@bazel/typescript:index.bzl", "ts_config", "ts_project")
load("@build_bazel_rules_nodejs//:index.bzl", "js_library", "pkg_npm")
load("//src/dev/bazel:index.bzl", "jsts_transpiler")
load("@npm//@bazel/typescript:index.bzl", "ts_config")
load("@build_bazel_rules_nodejs//:index.bzl", "js_library")
load("//src/dev/bazel:index.bzl", "jsts_transpiler", "pkg_npm", "pkg_npm_types", "ts_project")

PKG_BASE_NAME = "kbn-config-schema"
PKG_REQUIRE_NAME = "@kbn/config-schema"
TYPES_PKG_REQUIRE_NAME = "@types/kbn__config-schema"

SOURCE_FILES = glob([
"src/**/*.ts",
Expand Down Expand Up @@ -72,7 +73,7 @@ ts_project(
js_library(
name = PKG_BASE_NAME,
srcs = NPM_MODULE_EXTRA_FILES,
deps = RUNTIME_DEPS + [":target_node", ":tsc_types"],
deps = RUNTIME_DEPS + [":target_node"],
package_name = PKG_REQUIRE_NAME,
visibility = ["//visibility:public"],
)
Expand All @@ -91,3 +92,20 @@ filegroup(
],
visibility = ["//visibility:public"],
)

pkg_npm_types(
name = "npm_module_types",
srcs = SRCS,
deps = [":tsc_types"],
package_name = TYPES_PKG_REQUIRE_NAME,
tsconfig = ":tsconfig",
visibility = ["//visibility:public"],
)

filegroup(
name = "build_types",
srcs = [
":npm_module_types",
],
visibility = ["//visibility:public"],
)
1 change: 0 additions & 1 deletion packages/kbn-config-schema/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"name": "@kbn/config-schema",
"main": "./target_node/index.js",
"types": "./target_types/index.d.ts",
"version": "1.0.0",
"license": "SSPL-1.0 OR Elastic License 2.0",
"private": true
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-config-schema/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ import {
StreamType,
} from './types';

export type { TypeOf, Props, NullableProps };
export type { AnyType, ConditionalType, TypeOf, Props, NullableProps };
export { ObjectType, Type };
export { ByteSizeValue } from './byte_size_value';
export { SchemaTypeError, ValidationError } from './errors';
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-config/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ RUNTIME_DEPS = [

TYPES_DEPS = [
"//packages/elastic-safer-lodash-set",
"//packages/kbn-config-schema",
"//packages/kbn-config-schema:npm_module_types",
"//packages/kbn-logging",
"//packages/kbn-std",
"//packages/kbn-utility-types",
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-docs-utils/src/api_docs/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Autogenerated API documentation

[RFC](../../../rfcs/text/0014_api_documentation.md)
[RFC](https://github.com/elastic/kibana/blob/main/legacy_rfcs/text/0014_api_documentation.md))

This is an experimental api documentation system that is managed by the Kibana Tech Leads until
we determine the value of such a system and what kind of maintenance burder it will incur.
Expand Down
1 change: 0 additions & 1 deletion packages/kbn-es-query/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ NPM_MODULE_EXTRA_FILES = [

RUNTIME_DEPS = [
"//packages/kbn-utility-types",
"//packages/kbn-config-schema",
"//packages/kbn-i18n",
"@npm//@elastic/elasticsearch",
"@npm//load-json-file",
Expand Down
Loading

0 comments on commit 383d05c

Please sign in to comment.