Skip to content

Commit 96f0c66

Browse files
authored
[APM] Allow kibana to collect APM telemetry in background task (#52917) (#54106)
* Required for elastic/kibana#50757. Allows the kibana user to collect APM telemetry in a background task. * removed unnecessary priviledges on `.ml-anomalies-*` for the `kibana_system` reserved role
1 parent cb73de2 commit 96f0c66

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/store/ReservedRolesStore.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,11 +126,16 @@ private static Map<String, RoleDescriptor> initializeReservedRoles() {
126126
.indices(".monitoring-*").privileges("read", "read_cross_cluster").build(),
127127
RoleDescriptor.IndicesPrivileges.builder()
128128
.indices(".management-beats").privileges("create_index", "read", "write").build(),
129-
// .apm-* is for APM's agent configuration and custom link index creation
129+
// APM agent configuration
130130
RoleDescriptor.IndicesPrivileges.builder()
131131
.indices(".apm-agent-configuration").privileges("all").build(),
132+
// APM custom link index creation
132133
RoleDescriptor.IndicesPrivileges.builder()
133134
.indices(".apm-custom-link").privileges("all").build(),
135+
// APM telemetry queries APM indices in kibana task runner
136+
RoleDescriptor.IndicesPrivileges.builder()
137+
.indices("apm-*")
138+
.privileges("read", "read_cross_cluster").build(),
134139
},
135140
null,
136141
new ConfigurableClusterPrivilege[] { new ManageApplicationPrivileges(Collections.singleton("kibana-*")) },

x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/authz/store/ReservedRolesStoreTests.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,22 @@ public void testKibanaSystemRole() {
402402
assertThat(kibanaRole.indices().allowedIndicesMatcher(READ_CROSS_CLUSTER_NAME).test(index), is(true));
403403
});
404404

405+
// read-only indices for APM telemetry
406+
Arrays.asList("apm-*").forEach((index) -> {
407+
assertThat(kibanaRole.indices().allowedIndicesMatcher("indices:foo").test(index), is(false));
408+
assertThat(kibanaRole.indices().allowedIndicesMatcher("indices:bar").test(index), is(false));
409+
assertThat(kibanaRole.indices().allowedIndicesMatcher(DeleteIndexAction.NAME).test(index), is(false));
410+
assertThat(kibanaRole.indices().allowedIndicesMatcher(GetIndexAction.NAME).test(index), is(false));
411+
assertThat(kibanaRole.indices().allowedIndicesMatcher(CreateIndexAction.NAME).test(index), is(false));
412+
assertThat(kibanaRole.indices().allowedIndicesMatcher(IndexAction.NAME).test(index), is(false));
413+
assertThat(kibanaRole.indices().allowedIndicesMatcher(DeleteAction.NAME).test(index), is(false));
414+
assertThat(kibanaRole.indices().allowedIndicesMatcher(UpdateSettingsAction.NAME).test(index), is(false));
415+
assertThat(kibanaRole.indices().allowedIndicesMatcher(SearchAction.NAME).test(index), is(true));
416+
assertThat(kibanaRole.indices().allowedIndicesMatcher(MultiSearchAction.NAME).test(index), is(true));
417+
assertThat(kibanaRole.indices().allowedIndicesMatcher(GetAction.NAME).test(index), is(true));
418+
assertThat(kibanaRole.indices().allowedIndicesMatcher(READ_CROSS_CLUSTER_NAME).test(index), is(true));
419+
});
420+
405421
// Beats management index
406422
final String index = ".management-beats";
407423
assertThat(kibanaRole.indices().allowedIndicesMatcher("indices:foo").test(index), is(false));

0 commit comments

Comments
 (0)