Skip to content

Commit af7f011

Browse files
committed
Merge branch 'master' into alerting/deleted-alert-error
* master: document code splitting for client code (#62593) Escape single quotes surrounded by double quotes (#63229) [Endpoint] Update cli mapping to match endpoint package (#63372) update in-app links to metricbeat configuration docs (#63295) investigation notes field (documentation / metadata) (#63386) [Maps] fix bug where toggling Scaling type does not re-fetch data (#63326) [Alerting] set correct parameter for unauthented email action (#63086) [Telemetry] force staging urls in tests (#63356) Migrate legacy maps service to NP & update refs (#60942) Fix task manager query to return tasks to retry (#63360) [Endpoint] Policy list support for URL pagination state (#63291) [Canvas] Migrate saved object mappings and migrations to Kibana Platform (#58891) [DOCS] Add ILM tutorial (#59502) [Maps] Add SOURCE_TYPES enumeration (#62975) [Maps] update geospatial filters to use geo_shape query for geo_point fields (#62966) Move away from npStart for embeddables in canvas (#62680)
2 parents 876dea5 + f44d951 commit af7f011

File tree

160 files changed

+2092
-1012
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

160 files changed

+2092
-1012
lines changed

.i18nrc.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"src/legacy/core_plugins/management",
2525
"src/plugins/management"
2626
],
27+
"maps_legacy": "src/plugins/maps_legacy",
2728
"indexPatternManagement": "src/plugins/index_pattern_management",
2829
"advancedSettings": "src/plugins/advanced_settings",
2930
"kibana_legacy": "src/plugins/kibana_legacy",
471 KB
Loading
69.4 KB
Loading
121 KB
Loading
247 KB
Loading
444 KB
Loading
Lines changed: 171 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,179 @@
11
[role="xpack"]
2+
23
[[example-using-index-lifecycle-policy]]
3-
=== Example of using an index lifecycle policy
4+
=== Tutorial: Use {ilm-init} to manage {filebeat} time-based indices
5+
6+
With {ilm} ({ilm-init}), you can create policies that perform actions automatically
7+
on indices as they age and grow. {ilm-init} policies help you to manage
8+
performance, resilience, and retention of your data during its lifecycle. This tutorial shows
9+
you how to use {kib}’s *Index Lifecycle Policies* to modify and create {ilm-init}
10+
policies. You can learn more about all of the actions, benefits, and lifecycle
11+
phases in the {ref}/overview-index-lifecycle-management.html[{ilm-init} overview].
12+
13+
14+
[discrete]
15+
[[example-using-index-lifecycle-policy-scenario]]
16+
==== Scenario
17+
18+
You’re tasked with sending syslog files to an {es} cluster. This
19+
log data has the following data retention guidelines:
20+
21+
* Keep logs on hot data nodes for 30 days
22+
* Roll over to a new index if the size reaches 50GB
23+
* After 30 days:
24+
** Move the logs to warm data nodes
25+
** Set {ref}/glossary.html#glossary-replica-shard[replica shards] to 1
26+
** {ref}/indices-forcemerge.html[Force merge] multiple index segments to free up the space used by deleted documents
27+
* Delete logs after 90 days
28+
29+
30+
[discrete]
31+
[[example-using-index-lifecycle-policy-prerequisites]]
32+
==== Prerequisites
33+
34+
To complete this tutorial, you'll need:
35+
36+
* An {es} cluster with hot and warm nodes configured for shard allocation
37+
awareness. If you’re using {cloud}/ec-getting-started-templates-hot-warm.html[{ess}],
38+
choose the hot-warm architecture deployment template.
39+
40+
+
41+
For a self-managed cluster, add node attributes as described for {ref}/shard-allocation-filtering.html[shard allocation filtering]
42+
to label data nodes as hot or warm. This step is required to migrate shards between
43+
nodes configured with specific hardware for the hot or warm phases.
44+
+
45+
For example, you can set this in your `elasticsearch.yml` for each data node:
46+
+
47+
[source,yaml]
48+
--------------------------------------------------------------------------------
49+
node.attr.data: "warm"
50+
--------------------------------------------------------------------------------
51+
52+
* A server with {filebeat} installed and configured to send logs to the `elasticsearch`
53+
output as described in {filebeat-ref}/filebeat-getting-started.html[Getting Started with {filebeat}].
54+
55+
[discrete]
56+
[[example-using-index-lifecycle-policy-view-fb-ilm-policy]]
57+
==== View the {filebeat} {ilm-init} policy
58+
59+
{filebeat} includes a default {ilm-init} policy that enables rollover. {ilm-init}
60+
is enabled automatically if you’re using the default `filebeat.yml` and index template.
61+
62+
To view the default policy in {kib}, go to *Management > Index Lifecycle Policies*,
63+
search for _filebeat_, and choose the _filebeat-version_ policy.
64+
65+
This policy initiates the rollover action when the index size reaches 50GB or
66+
becomes 30 days old.
67+
68+
[role="screenshot"]
69+
image::images/tutorial-ilm-hotphaserollover-default.png["Default policy"]
70+
71+
72+
[float]
73+
==== Modify the policy
74+
75+
The default policy is enough to prevent the creation of many tiny daily indices.
76+
You can modify the policy to meet more complex requirements.
77+
78+
. Activate the warm phase.
79+
80+
+
81+
. Set either of the following options to control when the index moves to the warm phase:
82+
83+
** Provide a value for *Timing for warm phase*. Setting this to *15* keeps the
84+
indices on hot nodes for a range of 15-45 days, depending on when the initial
85+
rollover occurred.
86+
87+
** Enable *Move to warm phase on rollover*. The index might move to the warm phase
88+
more quickly than intended if it reaches the *Maximum index size* before the
89+
the *Maximum age*.
90+
91+
. In the *Select a node attribute to control shard allocation* dropdown, select
92+
*data:warm(2)* to migrate shards to warm data nodes.
93+
94+
. Change *Number of replicas* to *1*.
95+
96+
. Enable *Force merge data* and set *Number of segments* to *1*.
97+
+
98+
NOTE: When rollover is enabled in the hot phase, action timing in the other phases
99+
is based on the rollover date.
100+
101+
+
102+
[role="screenshot"]
103+
image::images/tutorial-ilm-modify-default-warm-phase-rollover.png["Modify to add warm phase"]
104+
105+
. Activate the delete phase and set *Timing for delete phase* to *90* days.
106+
+
107+
[role="screenshot"]
108+
image::images/tutorial-ilm-delete-rollover.png["Add a delete phase"]
109+
110+
[float]
111+
==== Create a custom policy
112+
113+
If meeting a specific retention time period is most important, you can create a
114+
custom policy. For this option, you will use {filebeat} daily indices without
115+
rollover.
116+
117+
. Create a custom policy in {kib}, go to *Management > Index Lifecycle Policies >
118+
Create Policy*.
119+
120+
. Activate the warm phase and configure it as follows:
121+
+
122+
|===
123+
|*Setting* |*Value*
124+
125+
|Timing for warm phase
126+
|30 days from index creation
127+
128+
|Node attribute
129+
|`data:warm`
130+
131+
|Number of replicas
132+
|1
133+
134+
|Force merge data
135+
|enable
136+
137+
|Number of segments
138+
|1
139+
|===
140+
141+
+
142+
[role="screenshot"]
143+
image::images/tutorial-ilm-custom-policy.png["Modify the custom policy to add a warm phase"]
144+
4145

5-
A common use case for managing index lifecycle policies is when you’re using
6-
{beats-ref}/beats-reference.html[Beats] to continually send time-series data,
7-
such as metrics and log data, to {es}. When you create the Beats packages, an
8-
index template is installed. The template includes a default policy to apply
9-
when new indices are created.
146+
+
147+
. Activate the delete phase and set the timing.
148+
+
149+
|===
150+
|*Setting* |*Value*
151+
|Timing for delete phase
152+
|90
153+
|===
10154

11-
You can edit the policy in {kib}'s *Index Lifecycle Policies*. For example, you might:
155+
+
156+
[role="screenshot"]
157+
image::images/tutorial-ilm-delete-phase-creation.png["Delete phase"]
12158

13-
* Rollover the index when it reaches 50 GB in size or is 30 days old. These
14-
settings are the default for the Beats lifecycle policy. This avoids
15-
having 1000s of tiny indices. When a rollover occurs, a new “hot” index is
16-
created and added to the index alias.
159+
. Configure the index to use the new policy in *{kib} > Management > Index Lifecycle
160+
Policies*
17161

18-
* Move the index into the warm phase, shrink the index down to a single shard,
19-
and force merge to a single segment.
162+
.. Find your {ilm-init} policy.
163+
.. Click the *Actions* link next to your policy name.
164+
.. Choose *Add policy to index template*.
165+
.. Select your {filebeat} index template name from the *Index template* list. For example, `filebeat-7.5.x`.
166+
.. Click *Add Policy* to save the changes.
20167

21-
* After 60 days, move the index into the cold phase and onto less expensive hardware.
168+
+
169+
NOTE: If you initially used the default {filebeat} {ilm-init} policy, you will
170+
see a notice that the template already has a policy associated with it. Confirm
171+
that you want to overwrite that configuration.
22172

23-
* Delete the index after 90 days.
173+
+
174+
+
175+
TIP: When you change the policy associated with the index template, the active
176+
index will continue to use the policy it was associated with at index creation
177+
unless you manually update it. The next new index will use the updated policy.
178+
For more reasons that your {ilm-init} policy changes might be delayed, see
179+
{ref}/update-lifecycle-policy.html#update-lifecycle-policy[Update Lifecycle Policy].

src/core/MIGRATION.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
- [7. Switch to new platform services](#7-switch-to-new-platform-services)
2525
- [8. Migrate to the new plugin system](#8-migrate-to-the-new-plugin-system)
2626
- [Bonus: Tips for complex migration scenarios](#bonus-tips-for-complex-migration-scenarios)
27+
- [Keep Kibana fast](#keep-kibana-fast)
2728
- [Frequently asked questions](#frequently-asked-questions)
2829
- [Is migrating a plugin an all-or-nothing thing?](#is-migrating-a-plugin-an-all-or-nothing-thing)
2930
- [Do plugins need to be converted to TypeScript?](#do-plugins-need-to-be-converted-to-typescript)
@@ -933,6 +934,66 @@ For a few plugins, some of these steps (such as angular removal) could be a mont
933934

934935
One convention that is useful for this is creating a dedicated `public/np_ready` directory to house the code that is ready to migrate, and gradually move more and more code into it until the rest of your plugin is essentially empty. At that point, you'll be able to copy your `index.ts`, `plugin.ts`, and the contents of `./np_ready` over into your plugin in the new platform, leaving your legacy shim behind. This carries the added benefit of providing a way for us to introduce helpful tooling in the future, such as [custom eslint rules](https://github.com/elastic/kibana/pull/40537), which could be run against that specific directory to ensure your code is ready to migrate.
935936

937+
## Keep Kibana fast
938+
**tl;dr**: Load as much code lazily as possible.
939+
Everyone loves snappy applications with responsive UI and hates spinners. Users deserve the best user experiences regardless of whether they run Kibana locally or in the cloud, regardless of their hardware & environment.
940+
There are 2 main aspects of the perceived speed of an application: loading time and responsiveness to user actions.
941+
New platform loads and bootstraps **all** the plugins whenever a user lands on any page. It means that adding every new application affects overall **loading performance** in the new platform, as plugin code is loaded **eagerly** to initialize the plugin and provide plugin API to dependent plugins.
942+
However, it's usually not necessary that the whole plugin code should be loaded and initialized at once. The plugin could keep on loading code covering API functionality on Kibana bootstrap but load UI related code lazily on-demand, when an application page or management section is mounted.
943+
Always prefer to require UI root components lazily when possible (such as in mount handlers). Even if their size may seem negligible, they are likely using some heavy-weight libraries that will also be removed from the initial plugin bundle, therefore, reducing its size by a significant amount.
944+
945+
```typescript
946+
import { Plugin, CoreSetup, AppMountParameters } from 'src/core/public';
947+
export class MyPlugin implements Plugin<MyPluginSetup> {
948+
setup(core: CoreSetup, plugins: SetupDeps){
949+
core.application.register({
950+
id: 'app',
951+
title: 'My app',
952+
async mount(params: AppMountParameters) {
953+
const { mountApp } = await import('./app/mount_app');
954+
return mountApp(await core.getStartServices(), params);
955+
},
956+
});
957+
plugins.management.sections.getSection('another').registerApp({
958+
id: 'app',
959+
title: 'My app',
960+
order: 1,
961+
async mount(params) {
962+
const { mountManagementSection } = await import('./app/mount_management_section');
963+
return mountManagementSection(coreSetup, params);
964+
},
965+
})
966+
return {
967+
doSomething(){}
968+
}
969+
}
970+
}
971+
```
972+
973+
#### How to understand how big the bundle size of my plugin is?
974+
New platform plugins are distributed as a pre-built with `@kbn/optimizer` package artifacts. It allows us to get rid of the shipping of `optimizer` in the distributable version of Kibana.
975+
Every NP plugin artifact contains all plugin dependencies required to run the plugin, except some stateful dependencies shared across plugin bundles via `@kbn/ui-shared-deps`.
976+
It means that NP plugin artifacts tend to have a bigger size than the legacy platform version.
977+
To understand the current size of your plugin artifact, run `@kbn/optimizer` as
978+
```bash
979+
node scripts/build_kibana_platform_plugins.js --dist --no-examples
980+
```
981+
and check the output in the `target` sub-folder of your plugin folder
982+
```bash
983+
ls -lh plugins/my_plugin/target/public/
984+
# output
985+
# an async chunk loaded on demand
986+
... 262K 0.plugin.js
987+
# eagerly loaded chunk
988+
... 50K my_plugin.plugin.js
989+
```
990+
you might see at least one js bundle - `my_plugin.plugin.js`. This is the only artifact loaded by the platform during bootstrap in the browser. The rule of thumb is to keep its size as small as possible.
991+
Other lazily loaded parts of your plugin present in the same folder as separate chunks under `{number}.plugin.js` names.
992+
If you want to investigate what your plugin bundle consists of you need to run `@kbn/optimizer` with `--profile` flag to get generated [webpack stats file](https://webpack.js.org/api/stats/).
993+
Many OSS tools are allowing you to analyze generated stats file
994+
- [an official tool](http://webpack.github.io/analyse/#modules) from webpack authors
995+
- [webpack-visualizer](https://chrisbateman.github.io/webpack-visualizer/)
996+
936997
## Frequently asked questions
937998

938999
### Is migrating a plugin an all-or-nothing thing?

src/legacy/core_plugins/kibana/public/index.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
@import './visualize/index';
1818
// Has to come after visualize because of some
1919
// bad cascading in the Editor layout
20-
@import 'src/legacy/ui/public/vis/index';
20+
@import '../../../../plugins/maps_legacy/public/index';
2121

2222
// Home styles
2323
@import '../../../../plugins/home/public/application/index';

src/legacy/core_plugins/region_map/public/__tests__/region_map_visualization.js

Lines changed: 41 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,18 @@ import _ from 'lodash';
2323
import ChoroplethLayer from '../choropleth_layer';
2424
import { ImageComparator } from 'test_utils/image_comparator';
2525
import worldJson from './world.json';
26-
import EMS_CATALOGUE from '../../../../ui/public/vis/__tests__/map/ems_mocks/sample_manifest.json';
27-
import EMS_FILES from '../../../../ui/public/vis/__tests__/map/ems_mocks/sample_files.json';
28-
import EMS_TILES from '../../../../ui/public/vis/__tests__/map/ems_mocks/sample_tiles.json';
29-
import EMS_STYLE_ROAD_MAP_BRIGHT from '../../../../ui/public/vis/__tests__/map/ems_mocks/sample_style_bright';
30-
import EMS_STYLE_ROAD_MAP_DESATURATED from '../../../../ui/public/vis/__tests__/map/ems_mocks/sample_style_desaturated';
31-
import EMS_STYLE_DARK_MAP from '../../../../ui/public/vis/__tests__/map/ems_mocks/sample_style_dark';
26+
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
27+
import EMS_CATALOGUE from '../../../../../plugins/maps_legacy/public/__tests__/map/ems_mocks/sample_manifest.json';
28+
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
29+
import EMS_FILES from '../../../../../plugins/maps_legacy/public/__tests__/map/ems_mocks/sample_files.json';
30+
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
31+
import EMS_TILES from '../../../../../plugins/maps_legacy/public/__tests__/map/ems_mocks/sample_tiles.json';
32+
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
33+
import EMS_STYLE_ROAD_MAP_BRIGHT from '../../../../../plugins/maps_legacy/public/__tests__/map/ems_mocks/sample_style_bright';
34+
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
35+
import EMS_STYLE_ROAD_MAP_DESATURATED from '../../../../../plugins/maps_legacy/public/__tests__/map/ems_mocks/sample_style_desaturated';
36+
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
37+
import EMS_STYLE_DARK_MAP from '../../../../../plugins/maps_legacy/public/__tests__/map/ems_mocks/sample_style_dark';
3238

3339
import initialPng from './initial.png';
3440
import toiso3Png from './toiso3.png';
@@ -44,6 +50,10 @@ import { createRegionMapTypeDefinition } from '../region_map_type';
4450
import { ExprVis } from '../../../../../plugins/visualizations/public/expressions/vis';
4551
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
4652
import { BaseVisType } from '../../../../../plugins/visualizations/public/vis_types/base_vis_type';
53+
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
54+
import { setInjectedVarFunc } from '../../../../../plugins/maps_legacy/public/kibana_services';
55+
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
56+
import { ServiceSettings } from '../../../../../plugins/maps_legacy/public/map/service_settings';
4757

4858
const THRESHOLD = 0.45;
4959
const PIXEL_DIFF = 96;
@@ -92,7 +102,31 @@ describe('RegionMapsVisualizationTests', function() {
92102
let getManifestStub;
93103
beforeEach(
94104
ngMock.inject((Private, $injector) => {
95-
const serviceSettings = $injector.get('serviceSettings');
105+
setInjectedVarFunc(injectedVar => {
106+
switch (injectedVar) {
107+
case 'mapConfig':
108+
return {
109+
emsFileApiUrl: '',
110+
emsTileApiUrl: '',
111+
emsLandingPageUrl: '',
112+
};
113+
case 'tilemapsConfig':
114+
return {
115+
deprecated: {
116+
config: {
117+
options: {
118+
attribution: '123',
119+
},
120+
},
121+
},
122+
};
123+
case 'version':
124+
return '123';
125+
default:
126+
return 'not found';
127+
}
128+
});
129+
const serviceSettings = new ServiceSettings();
96130
const uiSettings = $injector.get('config');
97131
const regionmapsConfig = {
98132
includeElasticMapsService: true,

0 commit comments

Comments
 (0)