Skip to content

Commit f42f5f9

Browse files
committed
Merge remote-tracking branch 'upstream/master' into task/ingest-60677-add-rest-api-response-types
# Conflicts: # x-pack/plugins/endpoint/public/applications/endpoint/store/policy_list/middleware.ts
2 parents 60c6ae3 + 48fd5c0 commit f42f5f9

File tree

66 files changed

+1048
-601
lines changed

Some content is hidden

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

66 files changed

+1048
-601
lines changed
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].

x-pack/legacy/plugins/canvas/canvas_plugin_src/functions/common/saved_map.ts

Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
*/
66

77
import { ExpressionFunctionDefinition } from 'src/plugins/expressions/common';
8-
import { TimeRange, Filter as DataFilter } from 'src/plugins/data/public';
9-
import { EmbeddableInput } from 'src/plugins/embeddable/public';
108
import { getQueryFilters } from '../../../public/lib/build_embeddable_filters';
119
import { Filter, MapCenter, TimeRange as TimeRangeArg } from '../../../types';
1210
import {
@@ -15,6 +13,7 @@ import {
1513
EmbeddableExpression,
1614
} from '../../expression_types';
1715
import { getFunctionHelp } from '../../../i18n';
16+
import { MapEmbeddableInput } from '../../../../../plugins/maps/public';
1817

1918
interface Arguments {
2019
id: string;
@@ -24,32 +23,12 @@ interface Arguments {
2423
timerange: TimeRangeArg | null;
2524
}
2625

27-
// Map embeddable is missing proper typings, so type is just to document what we
28-
// are expecting to pass to the embeddable
29-
export type SavedMapInput = EmbeddableInput & {
30-
id: string;
31-
isLayerTOCOpen: boolean;
32-
timeRange?: TimeRange;
33-
refreshConfig: {
34-
isPaused: boolean;
35-
interval: number;
36-
};
37-
hideFilterActions: true;
38-
filters: DataFilter[];
39-
mapCenter?: {
40-
lat: number;
41-
lon: number;
42-
zoom: number;
43-
};
44-
hiddenLayers?: string[];
45-
};
46-
4726
const defaultTimeRange = {
4827
from: 'now-15m',
4928
to: 'now',
5029
};
5130

52-
type Output = EmbeddableExpression<SavedMapInput>;
31+
type Output = EmbeddableExpression<MapEmbeddableInput>;
5332

5433
export function savedMap(): ExpressionFunctionDefinition<
5534
'savedMap',
@@ -108,8 +87,8 @@ export function savedMap(): ExpressionFunctionDefinition<
10887
filters: getQueryFilters(filters),
10988
timeRange: args.timerange || defaultTimeRange,
11089
refreshConfig: {
111-
isPaused: false,
112-
interval: 0,
90+
pause: false,
91+
value: 0,
11392
},
11493

11594
mapCenter: center,

x-pack/legacy/plugins/canvas/canvas_plugin_src/plugin.ts

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,14 @@
66

77
import { CoreSetup, CoreStart, Plugin } from 'src/core/public';
88
import { CanvasSetup } from '../public';
9+
import { EmbeddableStart } from '../../../../../src/plugins/embeddable/public';
10+
import { UiActionsStart } from '../../../../../src/plugins/ui_actions/public';
11+
import { Start as InspectorStart } from '../../../../../src/plugins/inspector/public';
912

1013
import { functions } from './functions/browser';
1114
import { typeFunctions } from './expression_types';
1215
// @ts-ignore: untyped local
13-
import { renderFunctions } from './renderers';
16+
import { renderFunctions, renderFunctionFactories } from './renderers';
1417

1518
import { elementSpecs } from './elements';
1619
// @ts-ignore Untyped Local
@@ -30,13 +33,26 @@ interface SetupDeps {
3033
canvas: CanvasSetup;
3134
}
3235

36+
export interface StartDeps {
37+
embeddable: EmbeddableStart;
38+
uiActions: UiActionsStart;
39+
inspector: InspectorStart;
40+
}
41+
3342
/** @internal */
34-
export class CanvasSrcPlugin implements Plugin<{}, {}, SetupDeps, {}> {
35-
public setup(core: CoreSetup, plugins: SetupDeps) {
43+
export class CanvasSrcPlugin implements Plugin<void, void, SetupDeps, StartDeps> {
44+
public setup(core: CoreSetup<StartDeps>, plugins: SetupDeps) {
3645
plugins.canvas.addFunctions(functions);
3746
plugins.canvas.addTypes(typeFunctions);
47+
3848
plugins.canvas.addRenderers(renderFunctions);
3949

50+
core.getStartServices().then(([coreStart, depsStart]) => {
51+
plugins.canvas.addRenderers(
52+
renderFunctionFactories.map((factory: any) => factory(coreStart, depsStart))
53+
);
54+
});
55+
4056
plugins.canvas.addElements(elementSpecs);
4157
plugins.canvas.addDatasourceUIs(datasourceSpecs);
4258
plugins.canvas.addModelUIs(modelSpecs);
@@ -45,11 +61,7 @@ export class CanvasSrcPlugin implements Plugin<{}, {}, SetupDeps, {}> {
4561
plugins.canvas.addTagUIs(tagSpecs);
4662
plugins.canvas.addTemplates(templateSpecs);
4763
plugins.canvas.addTransformUIs(transformSpecs);
48-
49-
return {};
5064
}
5165

52-
public start(core: CoreStart, plugins: {}) {
53-
return {};
54-
}
66+
public start(core: CoreStart, plugins: StartDeps) {}
5567
}

0 commit comments

Comments
 (0)