Commit d40aeed
[Fleet] Knowledge base integration support (elastic#230107)
## Summary
Closes elastic/ingest-dev#5678
- Adds support for writing the knowledge_base docs in a package to a
system index `.integration_knowledge` with per-document indexing.
- Also checks that the license is appropriate (`enterprise`), otherwise
skips this step as usage of inference models is needed due to the
`semantic_text` field.
- Automatically removes knowledge base files from the index when the
package is removed
- Updates the docs when the package updates
- Also adds an internal endpoint for getting indexed knowledge base docs
for a specific package `GET
/internal/fleet/epm/packages/{pkgName}/knowledge_base`
- In order to improve UX, we also added a generic doc during fleet setup
with some basic fleet knowledge that will be indexed asynchronously (if
the user has the correct license of `enterprise`) so that later on when
the docs need indexed, we dont need to wait for inference model
deployment. See [this
comment](elastic#230107 (comment))
for more context.
_**As part of these changes, I also realized there was an issue with the
custom integrations upload feature where it would error due to a missing
integration name as it relied on the pipeline, so I added a step to use
the name from the `_meta` field (with fallback to the pipeline) in order
to stop issues during manual testing. Can remove before finalized if
needed cc: @elastic/security-scalability. If kept, will close
elastic#231712 .
https://github.com/user-attachments/assets/0a7559af-b312-4356-bdb1-e05531721f89
**NOTE**: In the video, the indexing fails the first time. Turns out, it
was due to a timeout as the index was being created by ES and the
indexing would fail as creation took too long. It is now wrapped in a
retry so this has been resolved.
## Testing instructions
Cloud Deployment for testing without pulling everything down to local:
https://supplementing-pr-230107-knowledge-base-integration-support.kbndev.co/
Manual Testing:
1. If elastic/elasticsearch#132506 has been
merged, run `yarn es snapshot` in Kibana, otherwise, checkout that
branch in your local ES and then in kibana run `yarn es source` in order
to use that version of ES which contains the index management, mappings,
etc.
2. Install a package with any number of knowledge base docs in the
`docs/knowledge_base` folder. You can use [this sample
package](https://github.com/user-attachments/files/21867395/masonstestpackage-0.0.1.zip),
or create your own following the guide below:
- Using `elastic-package`, create a new package using `elastic-package
create integration`
- Once created add `knowledge_base` as a folder inside of the generated
`docs` folder of the integration
- Add an arbitrary amount of `.md` files to the knowledge_base folder
- Run `elastic-package build` to build the package
- There are a lot of different options for installing the package in a
local kibana instance. I prefer to just take the generated .zip folder
from `/build` in `elastic-package` and upload it to kibana using the
custom integrations feature. You can also expose the package registry,
or whatever you see fit.
3. Watch the Kibana logs for errors/debug messages etc
4. Use the new endpoint or just directly check the index using `GET
/.integration_knowledge/_search` to verify that the documents are
ingested into the system index of `.integration_knowledge`
5. Update the package and verify that the KB documents are updated by
checking the response again, they should have the updated pkgVersion on
the associated docs.
6. Remove the package and then verify (using the endpoint) that the docs
are removed from the index
### Checklist
Check the PR satisfies following conditions.
Reviewers should verify this PR satisfies this list as well.
- [ ] Any text added follows [EUI's writing
guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses
sentence case text and includes [i18n
support](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md)
- [ ]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials
- [ ] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [ ] If a plugin configuration key changed, check if it needs to be
allowlisted in the cloud and added to the [docker
list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)
- [ ] This was checked for breaking HTTP API changes, and any breaking
changes have been approved by the breaking-change committee. The
`release_note:breaking` label should be applied in these situations.
- [ ] [Flaky Test
Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was
used on any tests changed
- [ ] The PR description includes the appropriate Release Notes section,
and the correct `release_note:*` label is applied per the
[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)
- [ ] Review the [backport
guidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)
and apply applicable `backport:*` labels.
### Identify risks
Does this PR introduce any risks? For example, consider risks like hard
to test bugs, performance regression, potential of data loss.
Describe the risk, its severity, and mitigation for each identified
risk. Invite stakeholders and evaluate how to proceed before merging.
- [ ] [See some risk
examples](https://github.com/elastic/kibana/blob/main/RISK_MATRIX.mdx)
- [ ] ...
# Release Note
Adds support for indexing package knowledge base docs into the
.integration_knowledge system index, with per-document updates and
automatic removal when a package is deleted. To be utilized by package
developers allowing the AI assistants to have greater context relevant
to particular packages.
---------
Co-authored-by: kibanamachine <[email protected]>
Co-authored-by: Elastic Machine <[email protected]>1 parent fee09c9 commit d40aeed
File tree
48 files changed
+2779
-25
lines changed- oas_docs
- output
- x-pack
- platform
- test
- api_integration/apis/ml/model_management
- fleet_api_integration/apis
- epm
- fixtures/test_packages/knowledge_base_test/1.0.0
- data_stream/logs
- agent/stream
- docs
- knowledge_base
- img
- functional/page_objects
- solutions/security
- plugins/security_solution/public/management/pages/policy/view/ingest_manager_integration
- test/serverless/functional/test_suites/ml
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
48 files changed
+2779
-25
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21262 | 21262 | | |
21263 | 21263 | | |
21264 | 21264 | | |
21265 | | - | |
| 21265 | + | |
| 21266 | + | |
21266 | 21267 | | |
21267 | 21268 | | |
21268 | 21269 | | |
| |||
21828 | 21829 | | |
21829 | 21830 | | |
21830 | 21831 | | |
21831 | | - | |
| 21832 | + | |
| 21833 | + | |
21832 | 21834 | | |
21833 | 21835 | | |
21834 | 21836 | | |
| |||
22276 | 22278 | | |
22277 | 22279 | | |
22278 | 22280 | | |
22279 | | - | |
| 22281 | + | |
| 22282 | + | |
22280 | 22283 | | |
22281 | 22284 | | |
22282 | 22285 | | |
| |||
22494 | 22497 | | |
22495 | 22498 | | |
22496 | 22499 | | |
22497 | | - | |
| 22500 | + | |
| 22501 | + | |
22498 | 22502 | | |
22499 | 22503 | | |
22500 | 22504 | | |
| |||
23562 | 23566 | | |
23563 | 23567 | | |
23564 | 23568 | | |
23565 | | - | |
| 23569 | + | |
| 23570 | + | |
23566 | 23571 | | |
23567 | 23572 | | |
23568 | 23573 | | |
| |||
23981 | 23986 | | |
23982 | 23987 | | |
23983 | 23988 | | |
23984 | | - | |
| 23989 | + | |
| 23990 | + | |
23985 | 23991 | | |
23986 | 23992 | | |
23987 | 23993 | | |
| |||
24513 | 24519 | | |
24514 | 24520 | | |
24515 | 24521 | | |
24516 | | - | |
| 24522 | + | |
| 24523 | + | |
24517 | 24524 | | |
24518 | 24525 | | |
24519 | 24526 | | |
| |||
24929 | 24936 | | |
24930 | 24937 | | |
24931 | 24938 | | |
24932 | | - | |
| 24939 | + | |
| 24940 | + | |
24933 | 24941 | | |
24934 | 24942 | | |
24935 | 24943 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21262 | 21262 | | |
21263 | 21263 | | |
21264 | 21264 | | |
21265 | | - | |
| 21265 | + | |
| 21266 | + | |
21266 | 21267 | | |
21267 | 21268 | | |
21268 | 21269 | | |
| |||
21828 | 21829 | | |
21829 | 21830 | | |
21830 | 21831 | | |
21831 | | - | |
| 21832 | + | |
| 21833 | + | |
21832 | 21834 | | |
21833 | 21835 | | |
21834 | 21836 | | |
| |||
22276 | 22278 | | |
22277 | 22279 | | |
22278 | 22280 | | |
22279 | | - | |
| 22281 | + | |
| 22282 | + | |
22280 | 22283 | | |
22281 | 22284 | | |
22282 | 22285 | | |
| |||
22494 | 22497 | | |
22495 | 22498 | | |
22496 | 22499 | | |
22497 | | - | |
| 22500 | + | |
| 22501 | + | |
22498 | 22502 | | |
22499 | 22503 | | |
22500 | 22504 | | |
| |||
23562 | 23566 | | |
23563 | 23567 | | |
23564 | 23568 | | |
23565 | | - | |
| 23569 | + | |
| 23570 | + | |
23566 | 23571 | | |
23567 | 23572 | | |
23568 | 23573 | | |
| |||
23981 | 23986 | | |
23982 | 23987 | | |
23983 | 23988 | | |
23984 | | - | |
| 23989 | + | |
| 23990 | + | |
23985 | 23991 | | |
23986 | 23992 | | |
23987 | 23993 | | |
| |||
24513 | 24519 | | |
24514 | 24520 | | |
24515 | 24521 | | |
24516 | | - | |
| 24522 | + | |
| 24523 | + | |
24517 | 24524 | | |
24518 | 24525 | | |
24519 | 24526 | | |
| |||
24929 | 24936 | | |
24930 | 24937 | | |
24931 | 24938 | | |
24932 | | - | |
| 24939 | + | |
| 24940 | + | |
24933 | 24941 | | |
24934 | 24942 | | |
24935 | 24943 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24480 | 24480 | | |
24481 | 24481 | | |
24482 | 24482 | | |
| 24483 | + | |
24483 | 24484 | | |
24484 | 24485 | | |
24485 | 24486 | | |
| |||
24872 | 24873 | | |
24873 | 24874 | | |
24874 | 24875 | | |
| 24876 | + | |
24875 | 24877 | | |
24876 | 24878 | | |
24877 | 24879 | | |
| |||
25175 | 25177 | | |
25176 | 25178 | | |
25177 | 25179 | | |
| 25180 | + | |
25178 | 25181 | | |
25179 | 25182 | | |
25180 | 25183 | | |
| |||
25325 | 25328 | | |
25326 | 25329 | | |
25327 | 25330 | | |
| 25331 | + | |
25328 | 25332 | | |
25329 | 25333 | | |
25330 | 25334 | | |
| |||
25787 | 25791 | | |
25788 | 25792 | | |
25789 | 25793 | | |
| 25794 | + | |
25790 | 25795 | | |
25791 | 25796 | | |
25792 | 25797 | | |
| |||
26076 | 26081 | | |
26077 | 26082 | | |
26078 | 26083 | | |
| 26084 | + | |
26079 | 26085 | | |
26080 | 26086 | | |
26081 | 26087 | | |
| |||
26435 | 26441 | | |
26436 | 26442 | | |
26437 | 26443 | | |
| 26444 | + | |
26438 | 26445 | | |
26439 | 26446 | | |
26440 | 26447 | | |
| |||
26723 | 26730 | | |
26724 | 26731 | | |
26725 | 26732 | | |
| 26733 | + | |
26726 | 26734 | | |
26727 | 26735 | | |
26728 | 26736 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28262 | 28262 | | |
28263 | 28263 | | |
28264 | 28264 | | |
| 28265 | + | |
28265 | 28266 | | |
28266 | 28267 | | |
28267 | 28268 | | |
| |||
28675 | 28676 | | |
28676 | 28677 | | |
28677 | 28678 | | |
| 28679 | + | |
28678 | 28680 | | |
28679 | 28681 | | |
28680 | 28682 | | |
| |||
28985 | 28987 | | |
28986 | 28988 | | |
28987 | 28989 | | |
| 28990 | + | |
28988 | 28991 | | |
28989 | 28992 | | |
28990 | 28993 | | |
| |||
29142 | 29145 | | |
29143 | 29146 | | |
29144 | 29147 | | |
| 29148 | + | |
29145 | 29149 | | |
29146 | 29150 | | |
29147 | 29151 | | |
| |||
29639 | 29643 | | |
29640 | 29644 | | |
29641 | 29645 | | |
| 29646 | + | |
29642 | 29647 | | |
29643 | 29648 | | |
29644 | 29649 | | |
| |||
29928 | 29933 | | |
29929 | 29934 | | |
29930 | 29935 | | |
| 29936 | + | |
29931 | 29937 | | |
29932 | 29938 | | |
29933 | 29939 | | |
| |||
30300 | 30306 | | |
30301 | 30307 | | |
30302 | 30308 | | |
| 30309 | + | |
30303 | 30310 | | |
30304 | 30311 | | |
30305 | 30312 | | |
| |||
30595 | 30602 | | |
30596 | 30603 | | |
30597 | 30604 | | |
| 30605 | + | |
30598 | 30606 | | |
30599 | 30607 | | |
30600 | 30608 | | |
| |||
Lines changed: 4 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
42 | 46 | | |
43 | 47 | | |
44 | 48 | | |
| |||
Lines changed: 33 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
64 | 97 | | |
Lines changed: 9 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
12 | | - | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
16 | 23 | | |
17 | 24 | | |
18 | 25 | | |
| |||
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
301 | 301 | | |
302 | 302 | | |
303 | 303 | | |
| 304 | + | |
304 | 305 | | |
305 | 306 | | |
306 | 307 | | |
| |||
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
130 | 130 | | |
131 | 131 | | |
132 | 132 | | |
| 133 | + | |
133 | 134 | | |
134 | 135 | | |
135 | 136 | | |
| |||
Lines changed: 3 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
114 | 114 | | |
115 | 115 | | |
116 | 116 | | |
117 | | - | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
118 | 120 | | |
119 | 121 | | |
120 | 122 | | |
| |||
0 commit comments