Skip to content

Commit

Permalink
Merge branch 'master' into fix/112799
Browse files Browse the repository at this point in the history
  • Loading branch information
kibanamachine authored Sep 23, 2021
2 parents 2db4668 + 8cd6df6 commit a6e9a8a
Show file tree
Hide file tree
Showing 370 changed files with 11,578 additions and 2,433 deletions.
4 changes: 2 additions & 2 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -381,9 +381,9 @@
#CC# /x-pack/plugins/security_solution/ @elastic/security-solution

# Security Solution sub teams
/x-pack/plugins/cases @elastic/security-threat-hunting
/x-pack/plugins/cases @elastic/security-threat-hunting-cases
/x-pack/plugins/timelines @elastic/security-threat-hunting
/x-pack/test/case_api_integration @elastic/security-threat-hunting
/x-pack/test/case_api_integration @elastic/security-threat-hunting-cases
/x-pack/plugins/lists @elastic/security-detections-response

## Security Solution sub teams - security-onboarding-and-lifecycle-mgt
Expand Down
83 changes: 83 additions & 0 deletions dev_docs/key_concepts/persistable_state.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
---
id: kibDevDocsPersistableStateIntro
slug: /kibana-dev-docs/persistable-state-intro
title: Persistable State
summary: Persitable state is a key concept to understand when building a Kibana plugin.
date: 2021-02-02
tags: ['kibana','dev', 'contributor', 'api docs']
---

“Persistable state” is developer-defined state that supports being persisted by a plugin other than the one defining it. Persistable State needs to be serializable and the owner can/should provide utilities to migrate it, extract and inject any <DocLink id="kibDevDocsSavedObjectsIntro" section="references" text="references to Saved Objects"/> it may contain, as well as telemetry collection utilities.

## Exposing state that can be persisted

Any plugin that exposes state that another plugin might persist should implement <DocLink id="kibKibanaUtilsPluginApi" section="def-common.PersistableStateService" text="`PersistableStateService`"/> interface on their `setup` contract. This will allow plugins persisting the state to easily access migrations and other utilities.

Example: Data plugin allows you to generate filters. Those filters can be persisted by applications in their saved
objects or in the URL. In order to allow apps to migrate the filters in case the structure changes in the future, the Data plugin implements `PersistableStateService` on <DocLink id="kibDataQueryPluginApi" section="def-public.FilterManager" text="`data.query.filterManager`"/>.

note: There is currently no obvious way for a plugin to know which state is safe to persist. The developer must manually look for a matching `PersistableStateService`, or ad-hoc provided migration utilities (as is the case with Rule Type Parameters).
In the future, we hope to make it easier for producers of state to understand when they need to write a migration with changes, and also make it easier for consumers of such state, to understand whether it is safe to persist.

## Exposing state that can be persisted but is not owned by plugin exposing it (registry)

Any plugin that owns collection of items (registry) whose state/configuration can be persisted should implement `PersistableStateService`
interface on their `setup` contract and each item in the collection should implement <DocLink id="kibKibanaUtilsPluginApi" section="def-common.PersistableStateDefinition" text="`PersistableStateDefinition`"/> interface.

Example: Embeddable plugin owns the registry of embeddable factories to which other plugins can register new embeddable factories. Dashboard plugin
stores a bunch of embeddable panels input in its saved object and URL. Embeddable plugin setup contract implements `PersistableStateService`
interface and each `EmbeddableFactory` needs to implement `PersistableStateDefinition` interface.

Embeddable plugin exposes this interfaces:
```
// EmbeddableInput implements Serializable
export interface EmbeddableRegistryDefinition extends PersistableStateDefinition<EmbeddableInput> {
id: string;
...
}
export interface EmbeddableSetup extends PersistableStateService<EmbeddableInput>;
```

Note: if your plugin doesn't expose the state (it is the only one storing state), the plugin doesn't need to implement the `PersistableStateService` interface.
If the state your plugin is storing can be provided by other plugins (your plugin owns a registry) items in that registry still need to implement `PersistableStateDefinition` interface.

## Storing persistable state as part of saved object

Any plugin that stores any persistable state as part of their saved object should make sure that its saved object migration
and reference extraction and injection methods correctly use the matching `PersistableStateService` implementation for the state they are storing.

Take a look at [example saved object](https://github.com/elastic/kibana/blob/master/examples/embeddable_examples/server/searchable_list_saved_object.ts#L32) which stores an embeddable state. Note how the `migrations`, `extractReferences` and `injectReferences` are defined.

## Storing persistable state as part of URL

When storing persistable state as part of URL you must make sure your URL is versioned. When loading the state `migrateToLatest` method
of `PersistableStateService` should be called, which will migrate the state from its original version to latest.

note: Currently there is no recommended way on how to store version in url and its up to every application to decide on how to implement that.

## Available state operations

### Extraction/Injection of References

In order to support import and export, and space-sharing capabilities, Saved Objects need to explicitly list any references they contain to other Saved Objects.
To support persisting your state in saved objects owned by another plugin, the <DocLink id="kibKibanaUtilsPluginApi" section="def-common.PersistableState.extract" text="`extract`"/> and <DocLink id="kibKibanaUtilsPluginApi" section="def-common.PersistableState.inject" text="`inject`"/> methods of Persistable State interface should be implemented.

<DocLink id="kibDevTutorialSavedObject" section="references" text="Learn how to define Saved Object references"/>

[See example embeddable providing extract/inject functions](https://github.com/elastic/kibana/blob/master/examples/embeddable_examples/public/migrations/migrations_embeddable_factory.ts)

### Migrations and Backward compatibility

As your plugin evolves, you may need to change your state in a breaking way. If that happens, you should write a migration to upgrade the state that existed prior to the change.

<DocLink id="kibDevTutorialSavedObject" section="migrations" text="How to write a migration"/>.

[See an example saved object storing embeddable state implementing saved object migration function](https://github.com/elastic/kibana/blob/master/examples/embeddable_examples/server/searchable_list_saved_object.ts)

[See example embeddable providing migration functions](https://github.com/elastic/kibana/blob/master/examples/embeddable_examples/public/migrations/migrations_embeddable_factory.ts)

## Telemetry

You might want to collect statistics about how your state is used. If that is the case you should implement the telemetry method of Persistable State interface.
1 change: 1 addition & 0 deletions docs/dev-tools/console/console.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ shortcuts, click *Help*.
[[console-settings]]
=== Disable Console

deprecated:[7.16.0,"In 8.0 and later, this setting will no longer be supported."]
If you don’t want to use *Console*, you can disable it by setting `console.enabled`
to `false` in your `kibana.yml` configuration file. Changing this setting
causes the server to regenerate assets on the next startup,
Expand Down
3 changes: 3 additions & 0 deletions docs/management/advanced-options.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,9 @@ The default placeholder value to use in
Fields that exist outside of `_source`. Kibana merges these fields into the
document when displaying it.

[[metrics:allowStringIndices]]`metrics:allowStringIndices`::
Enables you to use {es} indices in *TSVB* visualizations.

[[metrics-maxbuckets]]`metrics:max_buckets`::
Affects the *TSVB* histogram density. Must be set higher than `histogram:maxBars`.

Expand Down
1 change: 1 addition & 0 deletions docs/settings/alert-action-settings.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ Be sure to back up the encryption key value somewhere safe, as your alerting rul
==== Action settings

`xpack.actions.enabled`::
deprecated:[7.16.0,"In 8.0 and later, this setting will no longer be supported."]
Feature toggle that enables Actions in {kib}.
If `false`, all features dependent on Actions are disabled, including the *Observability* and *Security* apps. Default: `true`.

Expand Down
3 changes: 2 additions & 1 deletion docs/settings/apm-settings.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ Changing these settings may disable features of the APM App.
[cols="2*<"]
|===
| `xpack.apm.enabled`
| Set to `false` to disable the APM app. Defaults to `true`.
| deprecated:[7.16.0,"In 8.0 and later, this setting will no longer be supported."]
Set to `false` to disable the APM app. Defaults to `true`.

| `xpack.apm.maxServiceEnvironments`
| Maximum number of unique service environments recognized by the UI. Defaults to `100`.
Expand Down
3 changes: 3 additions & 0 deletions docs/settings/dev-settings.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ They are enabled by default.
==== Grok Debugger settings

`xpack.grokdebugger.enabled` {ess-icon}::
deprecated:[7.16.0,"In 8.0 and later, this setting will no longer be supported."]
Set to `true` to enable the <<xpack-grokdebugger,Grok Debugger>>. Defaults to `true`.


Expand All @@ -21,11 +22,13 @@ Set to `true` to enable the <<xpack-grokdebugger,Grok Debugger>>. Defaults to `t
==== {searchprofiler} settings

`xpack.searchprofiler.enabled`::
deprecated:[7.16.0,"In 8.0 and later, this setting will no longer be supported."]
Set to `true` to enable the <<xpack-profiler,{searchprofiler}>>. Defaults to `true`.

[float]
[[painless_lab-settings]]
==== Painless Lab settings

`xpack.painless_lab.enabled`::
deprecated:[7.16.0,"In 8.0 and later, this setting will no longer be supported."]
When set to `true`, enables the <<painlesslab, Painless Lab>>. Defaults to `true`.
3 changes: 2 additions & 1 deletion docs/settings/fleet-settings.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ See the {fleet-guide}/index.html[{fleet}] docs for more information.
[cols="2*<"]
|===
| `xpack.fleet.enabled` {ess-icon}
| Set to `true` (default) to enable {fleet}.
| deprecated:[7.16.0,"In 8.0 and later, this setting will no longer be supported."]
Set to `true` (default) to enable {fleet}.
| `xpack.fleet.agents.enabled` {ess-icon}
| Set to `true` (default) to enable {fleet}.
|===
Expand Down
3 changes: 2 additions & 1 deletion docs/settings/general-infra-logs-ui-settings.asciidoc
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
[cols="2*<"]
|===
| `xpack.infra.enabled`
| Set to `false` to disable the Logs and Metrics app plugin {kib}. Defaults to `true`.
| deprecated:[7.16.0,"In 8.0 and later, this setting will no longer be supported."]
Set to `false` to disable the Logs and Metrics app plugin {kib}. Defaults to `true`.

| `xpack.infra.sources.default.logAlias`
| Index pattern for matching indices that contain log data. Defaults to `filebeat-*,kibana_sample_data_logs*`. To match multiple wildcard patterns, use a comma to separate the names, with no space after the comma. For example, `logstash-app1-*,default-logs-*`.
Expand Down
1 change: 1 addition & 0 deletions docs/settings/graph-settings.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@
You do not need to configure any settings to use the {graph-features}.

`xpack.graph.enabled` {ess-icon}::
deprecated:[7.16.0,"In 8.0 and later, this setting will no longer be supported."]
Set to `false` to disable the {graph-features}.
3 changes: 2 additions & 1 deletion docs/settings/ml-settings.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ enabled by default.
[cols="2*<"]
|===
| `xpack.ml.enabled` {ess-icon}
| Set to `true` (default) to enable {kib} {ml-features}. +
| deprecated:[7.16.0,"In 8.0 and later, this setting will no longer be supported."]
Set to `true` (default) to enable {kib} {ml-features}. +
+
If set to `false` in `kibana.yml`, the {ml} icon is hidden in this {kib}
instance. If `xpack.ml.enabled` is set to `true` in `elasticsearch.yml`, however,
Expand Down
3 changes: 2 additions & 1 deletion docs/settings/monitoring-settings.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ For more information, see
[cols="2*<"]
|===
| `monitoring.enabled`
| Set to `true` (default) to enable the {monitor-features} in {kib}. Unlike the
| deprecated:[7.16.0,"In 8.0 and later, this setting will no longer be supported."]
Set to `true` (default) to enable the {monitor-features} in {kib}. Unlike the
<<monitoring-ui-enabled, `monitoring.ui.enabled`>> setting, when this setting is `false`, the
monitoring back-end does not run and {kib} stats are not sent to the monitoring
cluster.
Expand Down
3 changes: 2 additions & 1 deletion docs/settings/security-settings.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ You do not need to configure any additional settings to use the
[cols="2*<"]
|===
| `xpack.security.enabled`
| By default, {kib} automatically detects whether to enable the
| deprecated:[7.16.0,"In 8.0 and later, this setting will no longer be supported."]
By default, {kib} automatically detects whether to enable the
{security-features} based on the license and whether {es} {security-features}
are enabled. +
+
Expand Down
5 changes: 3 additions & 2 deletions docs/settings/spaces-settings.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ roles when Security is enabled.
[cols="2*<"]
|===
| `xpack.spaces.enabled`
| Set to `true` (default) to enable Spaces in {kib}.
This setting is deprecated. Starting in 8.0, it will not be possible to disable this plugin.
| deprecated:[7.16.0,"In 8.0 and later, this setting will no longer be supported."]
Set to `true` (default) to enable Spaces in {kib}.
This setting is deprecated. Starting in 8.0, it will not be possible to disable this plugin.

| `xpack.spaces.maxSpaces`
| The maximum amount of Spaces that can be used with this instance of {kib}. Some operations
Expand Down
3 changes: 2 additions & 1 deletion docs/settings/url-drilldown-settings.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ Configure the URL drilldown settings in your `kibana.yml` configuration file.
[cols="2*<"]
|===
| [[url-drilldown-enabled]] `url_drilldown.enabled`
| When `true`, enables URL drilldowns on your {kib} instance.
| deprecated:[7.16.0,"In 8.0 and later, this setting will no longer be supported."]
When `true`, enables URL drilldowns on your {kib} instance.

| [[external-URL-policy]] `externalUrl.policy`
| Configures the external URL policies. URL drilldowns respect the global *External URL* service, which you can use to deny or allow external URLs.
Expand Down
2 changes: 1 addition & 1 deletion docs/setup/docker.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ Some example translations are shown here:
**Environment Variable**:: **Kibana Setting**
`SERVER_NAME`:: `server.name`
`SERVER_BASEPATH`:: `server.basePath`
`MONITORING_ENABLED`:: `monitoring.enabled`
`ELASTICSEARCH_HOSTS`:: `elasticsearch.hosts`

In general, any setting listed in <<settings>> can be configured with this technique.

Expand Down
12 changes: 7 additions & 5 deletions docs/setup/settings.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ configuration using `${MY_ENV_VAR}` syntax.
|===

| `console.enabled:`
| Toggling this causes the server to regenerate assets on the next startup,
| deprecated:[7.16.0,"In 8.0 and later, this setting will no longer be supported."]
Toggling this causes the server to regenerate assets on the next startup,
which may cause a delay before pages start being served.
Set to `false` to disable Console. *Default: `true`*

Expand Down Expand Up @@ -706,12 +707,13 @@ sources and images. When false, Vega can only get data from {es}. *Default: `fal
| Enables you to view the underlying documents in a data series from a dashboard panel. *Default: `false`*

| `xpack.license_management.enabled`
| Set this value to false to
disable the License Management UI. *Default: `true`*
| deprecated:[7.16.0,"In 8.0 and later, this setting will no longer be supported."]
Set this value to false to disable the License Management UI.
*Default: `true`*

| `xpack.rollup.enabled:`
| Set this value to false to disable the
Rollup UI. *Default: true*
| deprecated:[7.16.0,"In 8.0 and later, this setting will no longer be supported."]
Set this value to false to disable the Rollup UI. *Default: true*

| `i18n.locale` {ess-icon}
| Set this value to change the {kib} interface language.
Expand Down
Binary file modified docs/user/dashboard/images/tsvb_index_pattern_selection_mode.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions docs/user/dashboard/tsvb.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ When you use only {data-sources}, you are able to:

* Improve performance

IMPORTANT: Creating *TSVB* visualizations with an {es} index string is deprecated and will be removed in a future release.
It is the default one for new visualizations but it can also be switched for the old implementations:
IMPORTANT: Creating *TSVB* visualizations with an {es} index string is deprecated. To use an {es} index string, contact your administrator, or go to <<advanced-options, Advanced Settings>> and set `metrics:allowStringIndices` to `true`. Creating *TSVB* visualizations with an {es} index string will be removed in a future release.
Creating visualizations with only {data-sources} is the default one for new visualizations but it can also be switched for the old implementations:

. Click *Panel options*, then open the *Index pattern selection mode* options next to the *Index pattern* dropdown.

Expand Down
2 changes: 2 additions & 0 deletions docs/user/dashboard/vega-reference.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ Tokens include the following:
* `"%dashboard_context-filter_clause%"`: String replaced by an object containing filters
* `"%dashboard_context-must_not_clause%"`: String replaced by an object containing filters

NOTE: Vega supports the `interval` parameter, which is unsupported {es} 8.0.0 and later. To use intervals, use `fixed_interval` or `calendar_interval` instead.

For example, the following query counts the number of documents in a specific index:

[source,yaml]
Expand Down
4 changes: 3 additions & 1 deletion docs/user/plugins.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ NOTE: Removing a plugin will result in an "optimize" run which will delay the ne
[[disable-plugin]]
== Disable plugins

deprecated:[7.16.0,"In 8.0 and later, this setting will only be supported for a subset of plugins that have opted in to the behavior."]

Use the following command to disable a plugin:

[source,shell]
Expand All @@ -158,7 +160,7 @@ Use the following command to disable a plugin:

NOTE: Disabling or enabling a plugin will result in an "optimize" run which will delay the start of {kib}.

<1> You can find a plugin's plugin ID as the value of the `name` property in the plugin's `package.json` file.
<1> You can find a plugin's plugin ID as the value of the `name` property in the plugin's `kibana.json` file.

[float]
[[configure-plugin-manager]]
Expand Down
2 changes: 1 addition & 1 deletion examples/embeddable_examples/kibana.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"githubTeam": "kibana-app-services"
},
"description": "Example app that shows how to register custom embeddables",
"requiredPlugins": ["embeddable", "uiActions", "savedObjects", "dashboard"],
"requiredPlugins": ["embeddable", "uiActions", "savedObjects", "dashboard", "kibanaUtils"],
"optionalPlugins": [],
"extraPublicDirs": ["public/todo", "public/hello_world", "public/todo/todo_ref_embeddable"],
"requiredBundles": ["kibanaReact"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*/

import { i18n } from '@kbn/i18n';
import { EmbeddableStateWithType } from '../../../../src/plugins/embeddable/common';
import {
IContainer,
EmbeddableInput,
Expand Down Expand Up @@ -35,6 +36,16 @@ export class SimpleEmbeddableFactoryDefinition
'7.3.0': migration730,
};

public extract(state: EmbeddableStateWithType) {
// this embeddable does not store references to other saved objects
return { state, references: [] };
}

public inject(state: EmbeddableStateWithType) {
// this embeddable does not store references to other saved objects
return state;
}

/**
* In our simple example, we let everyone have permissions to edit this. Most
* embeddables should check the UI Capabilities service to be sure of
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* 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 { mergeWith } from 'lodash';
import type { SerializableRecord } from '@kbn/utility-types';
import { MigrateFunctionsObject, MigrateFunction } from '../../../src/plugins/kibana_utils/common';

export const mergeMigrationFunctionMaps = (
obj1: MigrateFunctionsObject,
obj2: MigrateFunctionsObject
) => {
const customizer = (objValue: MigrateFunction, srcValue: MigrateFunction) => {
if (!srcValue || !objValue) {
return srcValue || objValue;
}
return (state: SerializableRecord) => objValue(srcValue(state));
};

return mergeWith({ ...obj1 }, obj2, customizer);
};
Loading

0 comments on commit a6e9a8a

Please sign in to comment.