Skip to content

Commit a0ee239

Browse files
committed
Required for elastic/kibana#50757.
Allows the kibana user to collect APM telemetry in a background task.
1 parent ca7a135 commit a0ee239

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,11 +124,19 @@ private static Map<String, RoleDescriptor> initializeReservedRoles() {
124124
.indices(".monitoring-*").privileges("read", "read_cross_cluster").build(),
125125
RoleDescriptor.IndicesPrivileges.builder()
126126
.indices(".management-beats").privileges("create_index", "read", "write").build(),
127-
// .apm-* is for APM's agent configuration and custom link index creation
127+
// APM agent configuration
128128
RoleDescriptor.IndicesPrivileges.builder()
129129
.indices(".apm-agent-configuration").privileges("all").build(),
130+
// APM custom link index creation
130131
RoleDescriptor.IndicesPrivileges.builder()
131132
.indices(".apm-custom-link").privileges("all").build(),
133+
// APM telemetry queries APM & ML anomalies indices in kibana task runner
134+
RoleDescriptor.IndicesPrivileges.builder()
135+
.indices("apm-*")
136+
.privileges("read", "read_cross_cluster", "view_index_metadata").build(),
137+
RoleDescriptor.IndicesPrivileges.builder()
138+
.indices(".ml-anomalies-*")
139+
.privileges("read", "read_cross_cluster", "view_index_metadata").build(),
132140
},
133141
null,
134142
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: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,25 @@ public void testKibanaSystemRole() {
396396
assertThat(kibanaRole.indices().allowedIndicesMatcher(READ_CROSS_CLUSTER_NAME).test(index), is(true));
397397
});
398398

399+
// read-only indices for APM telemetry
400+
Arrays.asList(
401+
"apm-*",
402+
".ml-anomalies-*"
403+
).forEach((index) -> {
404+
assertThat(kibanaRole.indices().allowedIndicesMatcher("indices:foo").test(index), is(false));
405+
assertThat(kibanaRole.indices().allowedIndicesMatcher("indices:bar").test(index), is(false));
406+
assertThat(kibanaRole.indices().allowedIndicesMatcher(DeleteIndexAction.NAME).test(index), is(false));
407+
assertThat(kibanaRole.indices().allowedIndicesMatcher(GetIndexAction.NAME).test(index), is(true));
408+
assertThat(kibanaRole.indices().allowedIndicesMatcher(CreateIndexAction.NAME).test(index), is(false));
409+
assertThat(kibanaRole.indices().allowedIndicesMatcher(IndexAction.NAME).test(index), is(false));
410+
assertThat(kibanaRole.indices().allowedIndicesMatcher(DeleteAction.NAME).test(index), is(false));
411+
assertThat(kibanaRole.indices().allowedIndicesMatcher(UpdateSettingsAction.NAME).test(index), is(false));
412+
assertThat(kibanaRole.indices().allowedIndicesMatcher(SearchAction.NAME).test(index), is(true));
413+
assertThat(kibanaRole.indices().allowedIndicesMatcher(MultiSearchAction.NAME).test(index), is(true));
414+
assertThat(kibanaRole.indices().allowedIndicesMatcher(GetAction.NAME).test(index), is(true));
415+
assertThat(kibanaRole.indices().allowedIndicesMatcher(READ_CROSS_CLUSTER_NAME).test(index), is(true));
416+
});
417+
399418
// Beats management index
400419
final String index = ".management-beats";
401420
assertThat(kibanaRole.indices().allowedIndicesMatcher("indices:foo").test(index), is(false));

0 commit comments

Comments
 (0)