Skip to content

Commit 3ccb52d

Browse files
Supplementingelasticsearchmachinejen-huang
authored
[Fleet] Add integration_knowledge system index for Fleet (#132506)
* added privilege and test * [CI] Auto commit changes from spotless * changed privileges * removed conflict i missed * [CI] Auto commit changes from spotless * updated test * rolled back test to be correct to investigate failure * added additional indexAbstraction function with actual type to avoid adding the wrong privileges * changed test to true for now due to BWC logic * [CI] Auto commit changes from spotless * changed to let index management be the responsibility of ES * Removed unneeded function * [CI] Auto commit changes from spotless * fixed formatting of variable in json * Update x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/store/KibanaOwnedReservedRoleDescriptors.java Co-authored-by: Jen Huang <[email protected]> * Update x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/test/TestRestrictedIndices.java Co-authored-by: Jen Huang <[email protected]> * added changelog and removed whitespace * actually remove whitespace * [CI] Auto commit changes from spotless * changed area in changelog * fixed indicies IT to use correct url * fixed mapping issues by updating plugins needed to use types, also fixed tests to assert on the correct field * changed index to externally mananged, and removed permissive warnings * [CI] Auto commit changes from spotless * made changes to support semantic search with the .md content being added in content field --------- Co-authored-by: elasticsearchmachine <[email protected]> Co-authored-by: Jen Huang <[email protected]>
1 parent 74d219d commit 3ccb52d

File tree

10 files changed

+103
-3
lines changed

10 files changed

+103
-3
lines changed

docs/changelog/132506.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 132506
2+
summary: Add .integration_knowledge system index for usage by AI assistants
3+
area: Infra/Core
4+
type: feature
5+
issues: []

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,14 @@ static RoleDescriptor kibanaSystem(String name) {
174174
.privileges("write", "delete", "create_index")
175175
.allowRestrictedIndices(true)
176176
.build(),
177+
// Integrations knowledge base: Fleet creates, manages, and uses this index to store knowledge base documents to be consumed
178+
// by AI assistants to support integrations
179+
// assistants.
180+
RoleDescriptor.IndicesPrivileges.builder()
181+
.indices(".integration_knowledge*")
182+
.privileges("read", "write", "create_index")
183+
.allowRestrictedIndices(true)
184+
.build(),
177185
// Other Fleet indices. Kibana reads and writes to these indices to manage
178186
// Elastic Agents.
179187
RoleDescriptor.IndicesPrivileges.builder()

x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/test/TestRestrictedIndices.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,8 @@ public class TestRestrictedIndices {
103103
SystemIndexDescriptorUtils.createUnmanaged(".fleet-policies-[0-9]+*", "fleet policies"),
104104
SystemIndexDescriptorUtils.createUnmanaged(".fleet-policies-leader*", "fleet policies leader"),
105105
SystemIndexDescriptorUtils.createUnmanaged(".fleet-servers*", "fleet servers"),
106-
SystemIndexDescriptorUtils.createUnmanaged(".fleet-artifacts*", "fleet artifacts")
106+
SystemIndexDescriptorUtils.createUnmanaged(".fleet-artifacts*", "fleet artifacts"),
107+
SystemIndexDescriptorUtils.createUnmanaged(".integration_knowledge*", "fleet integration knowledge base")
107108
),
108109
List.of(
109110
new SystemDataStreamDescriptor(
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"settings": {
3+
"auto_expand_replicas": "0-1",
4+
"index.hidden": true
5+
},
6+
"mappings": {
7+
"_doc": {
8+
"dynamic": false,
9+
"_meta": {
10+
"version": "${fleet.version}",
11+
"managed_index_mappings_version": ${fleet.managed.index.version},
12+
"description": "Integration package knowledge base content storage"
13+
},
14+
"properties": {
15+
"filename": {
16+
"type": "keyword"
17+
},
18+
"content": {
19+
"type": "semantic_text",
20+
"inference_id": ".elser-2-elasticsearch",
21+
"model_settings": {
22+
"service": "elasticsearch",
23+
"task_type": "sparse_embedding"
24+
}
25+
},
26+
"version": {
27+
"type": "version"
28+
},
29+
"package_name": {
30+
"type": "keyword"
31+
},
32+
"installed_at": {
33+
"type": "date"
34+
}
35+
}
36+
}
37+
}
38+
}

x-pack/plugin/fleet/build.gradle

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@ dependencies {
2424
javaRestTestImplementation(project(path: xpackModule('core')))
2525
javaRestTestImplementation(testArtifact(project(xpackModule('core'))))
2626
compileOnly project(path: xpackModule('ilm'))
27+
testImplementation project(path: xpackModule('mapper-version'))
2728

2829
clusterModules project(xpackModule('ilm'))
30+
clusterModules project(xpackModule('mapper-version'))
31+
clusterModules project(xpackModule('inference'))
2932
clusterModules project(':modules:data-streams')
3033
}

x-pack/plugin/fleet/src/javaRestTest/java/org/elasticsearch/xpack/fleet/AbstractFleetIT.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ public abstract class AbstractFleetIT extends ESRestTestCase {
1717
public static ElasticsearchCluster cluster = ElasticsearchCluster.local()
1818
.module("x-pack-fleet")
1919
.module("x-pack-ilm")
20+
.module("mapper-version")
21+
.module("x-pack-inference")
2022
.module("data-streams")
2123
.setting("xpack.security.enabled", "true")
2224
.setting("xpack.security.autoconfiguration.enabled", "false")

x-pack/plugin/fleet/src/javaRestTest/java/org/elasticsearch/xpack/fleet/FleetSystemIndicesIT.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,4 +293,20 @@ public void verifyFileDeliveryDataILMPolicyExists() throws Exception {
293293
assertThat(policyMap.size(), equalTo(2));
294294
});
295295
}
296+
297+
public void testCreationOfIntegrationKnowledge() throws Exception {
298+
Request request = new Request("PUT", ".integration_knowledge");
299+
Response response = client().performRequest(request);
300+
assertEquals(200, response.getStatusLine().getStatusCode());
301+
302+
request = new Request("GET", ".integration_knowledge/_mapping");
303+
response = client().performRequest(request);
304+
String responseBody = EntityUtils.toString(response.getEntity());
305+
assertThat(responseBody, containsString("content"));
306+
307+
request = new Request("GET", ".integration_knowledge-7/_mapping");
308+
response = client().performRequest(request);
309+
responseBody = EntityUtils.toString(response.getEntity());
310+
assertThat(responseBody, containsString("content"));
311+
}
296312
}

x-pack/plugin/fleet/src/main/java/org/elasticsearch/xpack/fleet/Fleet.java

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ public class Fleet extends Plugin implements SystemIndexPlugin {
8787
private static final int FLEET_SERVERS_MAPPINGS_VERSION = 1;
8888
private static final int FLEET_ARTIFACTS_MAPPINGS_VERSION = 1;
8989
private static final int FLEET_ACTIONS_RESULTS_MAPPINGS_VERSION = 1;
90+
private static final int FLEET_INTEGRATION_KNOWLEDGE_MAPPINGS_VERSION = 1;
9091

9192
@Override
9293
public Collection<?> createComponents(PluginServices services) {
@@ -111,7 +112,8 @@ public Collection<SystemIndexDescriptor> getSystemIndexDescriptors(Settings sett
111112
fleetPoliciesSystemIndexDescriptor(),
112113
fleetPoliciesLeaderSystemIndexDescriptor(),
113114
fleetServersSystemIndexDescriptors(),
114-
fleetArtifactsSystemIndexDescriptors()
115+
fleetArtifactsSystemIndexDescriptors(),
116+
fleetIntegrationKnowledgeSystemIndexDescriptor()
115117
);
116118
}
117119

@@ -267,6 +269,26 @@ private static SystemIndexDescriptor fleetArtifactsSystemIndexDescriptors() {
267269
.build();
268270
}
269271

272+
private static SystemIndexDescriptor fleetIntegrationKnowledgeSystemIndexDescriptor() {
273+
PutIndexTemplateRequest request = new PutIndexTemplateRequest();
274+
request.source(
275+
loadTemplateSource("/fleet-integration-knowledge.json", FLEET_INTEGRATION_KNOWLEDGE_MAPPINGS_VERSION),
276+
XContentType.JSON
277+
);
278+
279+
return SystemIndexDescriptor.builder()
280+
.setType(Type.EXTERNAL_MANAGED)
281+
.setAllowedElasticProductOrigins(ALLOWED_PRODUCTS)
282+
.setOrigin(FLEET_ORIGIN)
283+
.setMappings(request.mappings())
284+
.setSettings(request.settings())
285+
.setPrimaryIndex(".integration_knowledge-" + CURRENT_INDEX_VERSION)
286+
.setIndexPattern(".integration_knowledge*")
287+
.setAliasName(".integration_knowledge")
288+
.setDescription("Integration package knowledge base content storage")
289+
.build();
290+
}
291+
270292
private static SystemDataStreamDescriptor fleetActionsResultsDescriptor() {
271293
final String source = loadTemplateSource("/fleet-actions-results.json", FLEET_ACTIONS_RESULTS_MAPPINGS_VERSION);
272294
try (XContentParser parser = XContentType.JSON.xContent().createParser(XContentParserConfiguration.EMPTY, source)) {

x-pack/plugin/fleet/src/test/java/org/elasticsearch/xpack/fleet/FleetTests.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ public void testFleetIndexNames() {
4545
".fleet-policies-leader*",
4646
".fleet-enrollment-api-keys*",
4747
".fleet-artifacts*",
48-
".fleet-secrets*"
48+
".fleet-secrets*",
49+
".integration_knowledge*"
4950
)
5051
);
5152

@@ -60,6 +61,8 @@ public void testFleetIndexNames() {
6061
assertFalse(fleetDescriptors.stream().anyMatch(d -> d.matchesIndexPattern(".fleet-actions-results")));
6162

6263
assertTrue(fleetDescriptors.stream().anyMatch(d -> d.matchesIndexPattern(".fleet-secrets")));
64+
65+
assertTrue(fleetDescriptors.stream().anyMatch(d -> d.matchesIndexPattern(".integration_knowledge")));
6366
}
6467

6568
public void testFleetFeature() {

x-pack/plugin/fleet/src/yamlRestTest/java/org/elasticsearch/xpack/fleet/FleetRestIT.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ public FleetRestIT(final ClientYamlTestCandidate testCandidate) {
2828
public static ElasticsearchCluster cluster = ElasticsearchCluster.local()
2929
.module("x-pack-fleet")
3030
.module("x-pack-ilm")
31+
.module("mapper-version")
32+
.module("x-pack-inference")
3133
.module("data-streams")
3234
.setting("xpack.license.self_generated.type", "basic")
3335
.setting("xpack.security.enabled", "true")

0 commit comments

Comments
 (0)