Skip to content

Commit

Permalink
Bootstrap profiling indices at startup (#95666)
Browse files Browse the repository at this point in the history
With this commit we bootstrap all indices and related structures that
are required for Elastic Universal Profiling.
  • Loading branch information
danielmitterdorfer authored May 16, 2023
1 parent ebaefc6 commit 3aed349
Show file tree
Hide file tree
Showing 35 changed files with 1,728 additions and 105 deletions.
5 changes: 5 additions & 0 deletions docs/changelog/95666.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pr: 95666
summary: Bootstrap profiling indices at startup
area: Indices APIs
type: enhancement
issues: []
42 changes: 39 additions & 3 deletions docs/reference/snapshot-restore/restore-snapshot.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ snapshot as well as each feature's indices.

To restore a specific feature state from the snapshot, specify the
`feature_name` from the response in the restore snapshot API's
<<restore-snapshot-api-feature-states,`feature_states`>> parameter.
<<restore-snapshot-api-feature-states,`feature_states`>> parameter.

NOTE: When you restore a feature state, {es} closes and overwrites the feature's existing indices.

Expand All @@ -247,7 +247,7 @@ realm>> to ensure you'll still be able to access your cluster.
POST _snapshot/my_repository/my_snapshot_2099.05.06/_restore
{
"feature_states": [ "geoip" ],
"include_global_state": false, <1>
"include_global_state": false, <1>
"indices": "-*" <2>
}
----
Expand All @@ -256,7 +256,7 @@ POST _snapshot/my_repository/my_snapshot_2099.05.06/_restore
// TEST[s/_restore/_restore?wait_for_completion=true/]
// TEST[s/"feature_states": \[ "geoip" \],//]

<1> Exclude the cluster state from the restore operation.
<1> Exclude the cluster state from the restore operation.
<2> Exclude the other indices and data streams in the snapshot from the restore operation.

[discrete]
Expand Down Expand Up @@ -365,6 +365,27 @@ POST _watcher/_start
. {blank}
+
--
* Universal Profiling
+
Check if Universal Profiling index template management is enabled:
+
[source,console]
----
GET /_cluster/settings?filter_path=**.xpack.profiling.templates.enabled&include_defaults=true
----
+
If the value is `true`, disable Universal Profiling index template management:
+
[source,console]
----
PUT _cluster/settings
{
"persistent": {
"xpack.profiling.templates.enabled": false
}
}
----

[[restore-create-file-realm-user]]
If you use {es} security features, log in to a node host, navigate to the {es}
installation directory, and add a user with the `superuser` role to the file
Expand Down Expand Up @@ -480,6 +501,21 @@ POST _watcher/_start
----
--

* Universal Profiling
+
If the value was `true` initially, enable Universal Profiling index template management again, otherwise skip this step:
+
[source,console]
----
PUT _cluster/settings
{
"persistent": {
"xpack.profiling.templates.enabled": true
}
}
----
//TEST[s/true/false/]

. If wanted, reset the `action.destructive_requires_name` cluster setting.
+
[source,console]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,7 @@ protected Set<String> preserveILMPolicyIds() {
"ml-size-based-ilm-policy",
"logs",
"metrics",
"profiling",
"synthetics",
"7-days-default",
"30-days-default",
Expand Down Expand Up @@ -1814,11 +1815,15 @@ protected static boolean isXPackTemplate(String name) {
if (name.startsWith("behavioral_analytics-")) {
return true;
}
if (name.startsWith("profiling-")) {
return true;
}
switch (name) {
case ".watches":
case "security_audit_log":
case ".slm-history":
case ".async-search":
case ".profiling-ilm-lock": // TODO: Remove after switch to K/V indices
case "saml-service-provider":
case "logs":
case "logs-settings":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ private static String maybeRewriteSingleAuthenticationHeaderForVersion(
public static final String TRANSFORM_ORIGIN = "transform";
public static final String ASYNC_SEARCH_ORIGIN = "async_search";
public static final String IDP_ORIGIN = "idp";
public static final String PROFILING_ORIGIN = "profiling";
public static final String STACK_ORIGIN = "stack";
public static final String SEARCHABLE_SNAPSHOTS_ORIGIN = "searchable_snapshots";
public static final String LOGSTASH_MANAGEMENT_ORIGIN = "logstash_management";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,13 @@ public Iterator<Setting<?>> settings() {
Setting.Property.NodeScope
);

/** Setting for enabling or disabling universal profiling. Defaults to true. */
public static final Setting<Boolean> PROFILING_ENABLED = Setting.boolSetting(
"xpack.profiling.enabled",
true,
Setting.Property.NodeScope
);

/** Setting for enabling or disabling enterprise search. Defaults to true. */
public static final Setting<Boolean> ENTERPRISE_SEARCH_ENABLED = Setting.boolSetting(
"xpack.ent_search.enabled",
Expand Down Expand Up @@ -318,6 +325,7 @@ public static List<Setting<?>> getAllSettings() {
settings.add(SECURITY_ENABLED);
settings.add(GRAPH_ENABLED);
settings.add(MACHINE_LEARNING_ENABLED);
settings.add(PROFILING_ENABLED);
settings.add(ENTERPRISE_SEARCH_ENABLED);
settings.add(AUDIT_ENABLED);
settings.add(WATCHER_ENABLED);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.elasticsearch.xpack.core.ilm.LifecyclePolicyUtils;
import org.elasticsearch.xpack.core.ilm.LifecycleType;
import org.elasticsearch.xpack.core.ilm.RolloverAction;
import org.elasticsearch.xpack.core.ilm.SetPriorityAction;
import org.elasticsearch.xpack.core.ilm.ShrinkAction;
import org.elasticsearch.xpack.core.ilm.TimeseriesLifecycleType;

Expand All @@ -36,6 +37,7 @@ public class LifecyclePolicyConfig {
(p) -> TimeseriesLifecycleType.INSTANCE
),
new NamedXContentRegistry.Entry(LifecycleAction.class, new ParseField(RolloverAction.NAME), RolloverAction::parse),
new NamedXContentRegistry.Entry(LifecycleAction.class, new ParseField(SetPriorityAction.NAME), SetPriorityAction::parse),
new NamedXContentRegistry.Entry(LifecycleAction.class, new ParseField(ForceMergeAction.NAME), ForceMergeAction::parse),
new NamedXContentRegistry.Entry(LifecycleAction.class, new ParseField(ShrinkAction.NAME), ShrinkAction::parse),
new NamedXContentRegistry.Entry(LifecycleAction.class, new ParseField(DeleteAction.NAME), DeleteAction::parse)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,26 @@
{
"settings": {
"index": {
"number_of_shards": "4",
"max_result_window": 150000,
"refresh_interval": "10s",
"sort": {
"field": [
"service.name",
"@timestamp",
"orchestrator.resource.name",
"container.name",
"process.thread.name",
"host.id"
]
}
"template": {
"settings": {
"index": {
"number_of_shards": 4,
"number_of_replicas": 0,
"auto_expand_replicas": "0-1",
"max_result_window": 150000,
"refresh_interval": "10s",
"sort": {
"field": [
"service.name",
"@timestamp",
"orchestrator.resource.name",
"container.name",
"process.thread.name",
"host.id"
]
}
},
"codec": "best_compression"
},
"codec": "best_compression"
},
"mappings": {
"_doc": {
"mappings": {
"_source": {
"enabled": false
},
Expand Down Expand Up @@ -60,9 +62,6 @@
"host.ip": {
"type": "ip"
},
"host.ipstring": {
"type": "keyword"
},
"host.name": {
"type": "keyword"
},
Expand All @@ -74,5 +73,6 @@
}
}
}
}
},
"version": ${xpack.profiling.template.version}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
{
"settings": {
"index": {
"refresh_interval": "10s"
}
},
"mappings": {
"_doc": {
"template": {
"settings": {
"index": {
"number_of_replicas": 0,
"auto_expand_replicas": "0-1",
"refresh_interval": "10s"
}
},
"mappings": {
"_source": {
"mode": "synthetic"
},
Expand All @@ -25,8 +27,14 @@
"@timestamp": {
"type": "date",
"format": "epoch_second"
},
"Symbolization.lastprocessed": {
"type": "date",
"format": "epoch_second",
"index": false
}
}
}
}
},
"version": ${xpack.profiling.template.version}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"template": {
"settings": {
"index": {
"lifecycle": {
"name": "profiling"
}
}
}
},
"version": ${xpack.profiling.template.version}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"template": {
"settings": {
"index": {
"number_of_replicas": 0,
"auto_expand_replicas": "0-1",
"refresh_interval": "10s",
"sort": {
"field": [
"project.id",
"@timestamp",
"host.id"
]
}
},
"codec": "best_compression"
},
"mappings": {
"_source": {
"enabled": false
},
"properties": {
"ecs.version": {
"type": "keyword",
"index": true
},
"project.id": {
"type": "keyword"
},
"host.id": {
"type": "keyword"
},
"@timestamp": {
"type": "date",
"format": "epoch_second"
},
"Elasticsearch.cluster.id": {
"type": "keyword"
}
}
}
},
"version": ${xpack.profiling.template.version}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
{
"settings": {
"index": {
"number_of_shards": "16",
"refresh_interval": "10s"
}
},
"mappings": {
"_doc": {
"template": {
"settings": {
"index": {
"number_of_shards": 16,
"number_of_replicas": 0,
"auto_expand_replicas": "0-1",
"refresh_interval": "10s"
}
},
"mappings": {
"_source": {
"enabled": true
},
Expand Down Expand Up @@ -34,8 +36,15 @@
"index": false,
"doc_values": false,
"store": false
},
"Stackframe.function.offset": {
"type": "integer",
"index": false,
"doc_values": false,
"store": false
}
}
}
}
},
"version": ${xpack.profiling.template.version}
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
{
"settings": {
"index": {
"number_of_shards": "16",
"refresh_interval": "10s",
"sort": {
"field": [
"Stacktrace.frame.ids"
]
"template": {
"settings": {
"index": {
"number_of_shards": 16,
"number_of_replicas": 0,
"auto_expand_replicas": "0-1",
"refresh_interval": "10s",
"sort": {
"field": [
"Stacktrace.frame.ids"
]
}
}
}
},
"mappings": {
"_doc": {
},
"mappings": {
"_source": {
"mode": "synthetic"
},
Expand All @@ -27,12 +29,9 @@
"Stacktrace.frame.types": {
"type": "keyword",
"index": false
},
"@timestamp": {
"type": "date",
"format": "epoch_second"
}
}
}
}
},
"version": ${xpack.profiling.template.version}
}
Loading

0 comments on commit 3aed349

Please sign in to comment.