Skip to content

Commit

Permalink
Merge branch 'master' into enable-sm-debug-logging-option
Browse files Browse the repository at this point in the history
  • Loading branch information
kibanamachine authored Aug 10, 2021
2 parents 22bc038 + 5d9b9a1 commit b35c86e
Show file tree
Hide file tree
Showing 1,282 changed files with 26,684 additions and 21,515 deletions.
5 changes: 0 additions & 5 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -470,11 +470,6 @@ module.exports = {
errorMessage:
'Server modules cannot be imported into client modules or shared modules.',
},
{
target: ['src/**/*'],
from: ['x-pack/**/*'],
errorMessage: 'OSS cannot import x-pack files.',
},
{
target: ['src/core/**/*'],
from: ['plugins/**/*', 'src/plugins/**/*'],
Expand Down
5 changes: 5 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
# The #CC# prefix delineates Code Coverage,
# used for the 'team' designator within Kibana Stats

# Tech leads
/dev_docs @elastic/kibana-tech-leads
/packages/kbn-docs-utils/ @elastic/kibana-tech-leads @elastic/kibana-operations

# App
/x-pack/plugins/discover_enhanced/ @elastic/kibana-app
/x-pack/plugins/lens/ @elastic/kibana-app
Expand Down Expand Up @@ -201,6 +205,7 @@
/test/functional/services/remote @elastic/kibana-qa

# Core
/examples/hello_world/ @elastic/kibana-core
/src/core/ @elastic/kibana-core
/src/plugins/saved_objects_tagging_oss @elastic/kibana-core
/config/kibana.yml @elastic/kibana-core
Expand Down
2 changes: 2 additions & 0 deletions .i18nrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"data": "src/plugins/data",
"embeddableApi": "src/plugins/embeddable",
"embeddableExamples": "examples/embeddable_examples",
"fieldFormats": "src/plugins/field_formats",
"uiActionsExamples": "examples/ui_action_examples",
"share": "src/plugins/share",
"home": "src/plugins/home",
Expand All @@ -35,6 +36,7 @@
"monaco": "packages/kbn-monaco/src",
"esQuery": "packages/kbn-es-query/src",
"presentationUtil": "src/plugins/presentation_util",
"indexPatternEditor": "src/plugins/index_pattern_editor",
"indexPatternFieldEditor": "src/plugins/index_pattern_field_editor",
"indexPatternManagement": "src/plugins/index_pattern_management",
"interactiveSetup": "src/plugins/interactive_setup",
Expand Down
2 changes: 1 addition & 1 deletion api_docs/timelines.json
Original file line number Diff line number Diff line change
Expand Up @@ -10918,7 +10918,7 @@
"label": "alertConsumers",
"description": [],
"signature": [
"ALERTS_CONSUMERS",
"AlertConsumers",
"[] | undefined"
],
"path": "x-pack/plugins/timelines/common/search_strategy/timeline/index.ts",
Expand Down
17 changes: 0 additions & 17 deletions dev_docs/dev_welcome.mdx

This file was deleted.

20 changes: 20 additions & 0 deletions dev_docs/getting_started/dev_welcome.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
id: kibDevDocsWelcome
slug: /kibana-dev-docs/welcome
title: Welcome
summary: Build custom solutions and applications on top of Kibana.
date: 2021-01-02
tags: ['kibana', 'dev', 'contributor']
---

[Kibana](https://www.elastic.co/what-is/kibana) is a pluggable platform that allows users to search, visualize and analyze data in Elasticsearch.

Kibana ships with many out-of-the-box capabilities that can be extended and enhanced by custom javascript plugins. Developers can also write their own custom applications.

Recommended next reading:

1. <DocLink id="kibDevTutorialSetupDevEnv" text="Set up your development environment" />
2. Create a simple <DocLink id="kibHelloWorldApp" text="Hello World plugin"/>.

Check out our <DocLink id="kibDevDocsApiWelcome" text="API documentation" /> to dig into the nitty gritty details of
every public plugin API.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added dev_docs/getting_started/hello_world_manual.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
157 changes: 157 additions & 0 deletions dev_docs/getting_started/hello_world_plugin.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
---
id: kibHelloWorldApp
slug: /kibana-dev-docs/hello-world-app
title: Hello World
summary: Build a very basic plugin that registers an application that says "Hello World!".
date: 2021-08-03
tags: ['kibana', 'dev', 'contributor', 'tutorials']
---

This tutorial walks you through two ways to create a plugin that registers an application that says "Hello World!".

You can view the tested example plugin at [examples/hello_world](https://github.com/elastic/kibana/tree/master/examples/hello_world).

## 1. Set up your development environment

Read through <DocLink id="kibDevTutorialSetupDevEnv" text="these instructions"/> to get your development environment set up.

## 2. Option 1 - Write it manually

This is a good option if you want to understand the bare minimum needed to register a "Hello world" application. The example plugin is based off of this option.

1. Create your plugin folder. Start off in the `kibana` folder.

```
$ cd examples
$ mkdir hello_world
$ cd hello_world
```

2. Create the <DocLink id="kibDevTutorialBuildAPlugin" section="1-kibanajson" text="kibana.json manifest file"/>.

```
$ touch kibana.json
```

and add the following:

```
{
"id": "helloWorld",
"version": "1.0.0",
"kibanaVersion": "kibana",
"ui": true
}
```

3. Create a `tsconfig.json` file.

```
$ touch tsconfig.json
```

And add the following to it:

```
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"outDir": "./target",
"skipLibCheck": true
},
"include": [
"index.ts",
"common/**/*.ts",
"public/**/*.ts",
"public/**/*.tsx",
"server/**/*.ts",
"../../typings/**/*"
],
"exclude": []
}
```

4. Create a <DocLink id="kibDevTutorialBuildAPlugin" section="2-publicindexts" text="`public/plugin.tsx` file "/>.

```
$ mkdir public
$ touch plugin.tsx
```

And add the following to it:

```ts
import React from 'react';
import ReactDOM from 'react-dom';
import { AppMountParameters, CoreSetup, CoreStart, Plugin } from '../../../src/core/public';

export class HelloWorldPlugin implements Plugin {
public setup(core: CoreSetup) {
// Register an application into the side navigation menu
core.application.register({
id: 'helloWorld',
title: 'Hello World',
async mount({ element }: AppMountParameters) {
ReactDOM.render(<div>Hello World!</div>, element);
return () => ReactDOM.unmountComponentAtNode(element);
},
});
}
public start(core: CoreStart) {
return {};
}
public stop() {}
}
```

5. Create a <DocLink id="kibDevTutorialBuildAPlugin" section="3-publicplugints" text="`public/index.ts` file "/>.

```
$ touch index.ts
```

```ts
import { HelloWorldPlugin } from './plugin';

export function plugin() {
return new HelloWorldPlugin();
}
```

## 2. Option 2 - Use the automatic plugin generator

This is an easy option to get up and running ASAP and includes additional code.

Use the Automatic plugin generator to get a basic structure for a new plugin. Plugins that are not part of the Kibana repo should be developed inside the plugins folder. If you are building a new plugin to check in to the Kibana repo, you will choose between a few locations:

`x-pack/plugins` for plugins related to subscription features
`src/plugins` for plugins related to free features
`examples` for developer example plugins (these will not be included in the distributables)

```
% node scripts/generate_plugin hello_world
? Plugin name (use camelCase) helloWorld
? Will this plugin be part of the Kibana repository? Yes
? What type of internal plugin would you like to create Kibana Example
? Should an UI plugin be generated? Yes
? Should a server plugin be generated? No
succ 🎉
Your plugin has been created in examples/hello_world
```

## 3. Build your new application

Run `yarn kbn bootstrap`

## 3. Start Kibana with examples and navigate to your new application

In one terminal window, run `yarn es snapshot --license trial` to boot up Elasticsearch.

In another terminal window, run `yarn start --run-examples` to boot up Kibana and include the example plugins. Your example plugin should show up in the navigation at the very bottom.

If you build it manually it will look something like this:
![hello world manual](./hello_world_manual.png)

If you built it with the generator, it will look something like this:
![hello world generated](./hello_world_generated.png)
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
---
id: kibDevTutorialSetupDevEnv
slug: /kibana-dev-docs/tutorial/setup-dev-env
title: Setting up a Development Environment
summary: Learn how to setup a development environemnt for contributing to the Kibana repository
title: Set up a Development Environment
summary: Learn how to setup a development environment for contributing to the Kibana repository
date: 2021-04-26
tags: ['kibana', 'onboarding', 'dev', 'architecture', 'setup']
---
Expand All @@ -12,11 +12,11 @@ Setting up a development environment is pretty easy.
<DocCallOut title="A note about Windows">
In order to support Windows development we currently require you to use one of the following:

- [Git Bash](https://git-scm.com/download/win)
- [Windows Subsystem for Linux](https://docs.microsoft.com/en-us/windows/wsl/about)
- [Git Bash](https://git-scm.com/download/win)
- [Windows Subsystem for Linux](https://docs.microsoft.com/en-us/windows/wsl/about)

Before running the steps below, please make sure you have installed [Visual C++ Redistributable for Visual Studio 2015](https://www.microsoft.com/en-us/download/details.aspx?id=48145) and that you are running all commands in either Git Bash or WSL.

Before running the steps below, please make sure you have installed [Visual C++ Redistributable for Visual Studio 2015](https://www.microsoft.com/en-us/download/details.aspx?id=48145) and that you are running all commands in either Git Bash or WSL.
</DocCallOut>

## Get the code
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
---
id: kibDevTutorialBuildAPlugin
slug: /kibana-dev-docs/tutorials/build-a-plugin
title: Kibana plugin tutorial
summary: Anatomy of a Kibana plugin and how to build one
date: 2021-02-05
tags: ['kibana', 'onboarding', 'dev', 'tutorials']
slug: /kibana-dev-docs/tutorials/anatomy-of-a-plugin
title: Anatomy of a plugin
summary: Anatomy of a Kibana plugin.
date: 2021-08-03
tags: ['kibana', 'onboarding', 'dev']
---

Prereading material:
Pre-reading material:

- <DocLink id="kibPlatformIntro" />

Expand Down Expand Up @@ -39,27 +39,50 @@ plugins/

```
{
"id": "demo",
"version": "kibana",
"id": "examplePluginId",
"version": "1.0.0",
"kibanaVersion": "7.14.0",
"server": true,
"ui": true,
"owner": { [1]
"configPath": "path/to/config",
"type": "standard",
"owner": {
"name": "App Services",
"githubTeam": "kibana-app-services"
},
"description": "This plugin extends Kibana by doing xyz, and allows other plugins to extend Kibana by offering abc functionality. It also exposes some helper utilities that do efg", [2]
"requiredPlugins": ["data"], [3]
"optionalPlugins": ["alerting"] [4]
"requiredBundles": ["anotherPlugin"] [5]
"description": "A description about this plugin!",
"requiredPlugins": ["data"],
"optionalPlugins": ["alerting"]
"requiredBundles": ["anotherPlugin"]
}
```

[1], [2]: Every internal plugin should fill in the owner and description properties.
`id` - [Required] The id of your plugin can be anything, though it should be fairly unique, as every plugin in an installation needs to be unique. It must be snakeCase.

`version` - [Required] Note the version of your plugin. For internal plugins that don't specify a `kibanaVersion`, this will have to match the version of Kibana or ci will fail. Because teams won't want to be bumping this number for every release, internal plugins should set `kibanaVersion` to "kibana", and set this to anything.

`kibanaVersion` - [Optional] If your plugin is only compatible with a specific version of Kibana, put it here. Internal, first-party plugins should set this to "kibana", otherwise they will need to bump this value, or the one in `version`, every time the Kibana version is bumped. When [#61087](https://github.com/elastic/kibana/issues/61087) is fixed, we will stop requiring this field for internal plugins.

`server` - [Optional] If your plugin contains server-side code, this must be true.

`ui` - [Optional] If your plugin contains client-side code, this must be true.

`configPath` - [Optional] Every plugin might allow Kibana users to adjust configuration via kibana.yml file. If your plugin needs to read config from `kibana.yml , you should declare what property name it should have access to.

`type` - [Optional] Should be either `preboot` or `standard` which specifies the type of plugin. Default value, if unspecified, is `standard`. There are two types of plugins:

- preboot plugins are bootstrapped to prepare the environment before Kibana starts.
- standard plugins define Kibana functionality while Kibana is running.

`owner` - [Required] Help users of your plugin know who manages this plugin and how to get in touch. This is required for internal plugins. `Owner.name` should be the name of the team that manages this plugin. This should match the team that owns this code in the [CODEOWNERS](https://github.com/elastic/kibana/blob/master/.github/CODEOWNERS) file (however, this is not currently enforced). Internal teams should also use a [GitHub team alias](https://github.com/orgs/elastic/teams) for `owner.githubTeam`. While many teams can contribute to a plugin, only a single team should be the primary owner.

`description` - [Required] Give your plugin a description to help other developers understand what it does. This is required for internal plugins.

[3], [4]: Any plugin that you have a dependency on should be listed in `requiredPlugins` or `optionalPlugins`. Doing this will ensure that you have access to that plugin's start and setup contract inside your own plugin's start and setup lifecycle methods. If a plugin you optionally depend on is not installed or disabled, it will be undefined if you try to access it. If a plugin you require is not installed or disabled, kibana will fail to build.
`requiredPlugins` - [Optional] If your plugin requires any other plugins to work, you must list them here by id. If any of the required plugins are disabled or not installed, then your plugin will be disabled.

[5]: Don't worry too much about getting 5 right. The build optimizer will complain if any of these values are incorrect.
`optionalPlugins` - [Optional] If your plugin has an optional dependency on other plugins, you must list them here by id. If any of the optional plugins are disabled or not installed, your plugin will still load, however that plugin's API contract will be undefined in the second parameter of the setup and start functions.

`requiredBundles` - [Required in certain situations] Don't worry about getting this right. The build optimizer will complain if any of these values are incorrect.

<DocCallOut>
You don't need to declare a dependency on a plugin if you only wish to access its types.
Expand Down Expand Up @@ -233,7 +256,7 @@ With that specified in the plugin manifest, the appropriate interfaces are then
import type { CoreSetup, CoreStart } from 'kibana/server';
import type { FoobarPluginSetup, FoobarPluginStart } from '../../foobar/server';

interface DemoSetupPlugins { [1]
interface DemoSetupPlugins { [1];
foobar: FoobarPluginSetup;
}

Expand All @@ -242,13 +265,13 @@ interface DemoStartPlugins {
}

export class DemoPlugin {
public setup(core: CoreSetup, plugins: DemoSetupPlugins) { [2]
public setup(core: CoreSetup, plugins: DemoSetupPlugins) { [2];
const { foobar } = plugins;
foobar.getFoo(); // 'foo'
foobar.getBar(); // throws because getBar does not exist
}

public start(core: CoreStart, plugins: DemoStartPlugins) { [3]
public start(core: CoreStart, plugins: DemoStartPlugins) { [3];
const { foobar } = plugins;
foobar.getFoo(); // throws because getFoo does not exist
foobar.getBar(); // 'bar'
Expand Down
Loading

0 comments on commit b35c86e

Please sign in to comment.