kibana/packages/kbn-data-stream-adapter
Patryk Kopyciński 2064a2c310
[8.16] [Security Assistant] Knowledge base switch to use semantic_text (#197007) (#198439)
# Backport

This will backport the following commits from `main` to `8.16`:
- [[Security Assistant] Knowledge base switch to use `semantic_text`
(#197007)](https://github.com/elastic/kibana/pull/197007)

<!--- Backport version: 8.9.8 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Patryk
Kopyciński","email":"contact@patrykkopycinski.com"},"sourceCommit":{"committedDate":"2024-10-30T19:20:45Z","message":"[Security
Assistant] Knowledge base switch to use `semantic_text` (#197007)\n\n##
Summary\n\n- `text_expansion` is deprecated, use `semantic_text`
instead\n- fix KB index entry form field options \n- explicitly create
inference endpoint on KB setup if\n`assistantKnowledgeBaseByDefault` is
true\n- when upgrade from v1 update KB ingest pipeline and remove
unnecessary\nprocessor, but keep the pipeline for the backward
compatibility\n- switch to use `doc` update for KB entries due to the
limitations
od\n`semantic_text`\nhttps://www.elastic.co/guide/en/elasticsearch/reference/current/semantic-text.html#update-script\n-
split loading Security labs content into smaller
chunks\n\n---------\n\nCo-authored-by: kibanamachine
<42973632+kibanamachine@users.noreply.github.com>\nCo-authored-by: Pedro
Jaramillo
<pedro.jaramillo@elastic.co>","sha":"a8c54f2ea4f482285eda15c72c56da35d76a6719","branchLabelMapping":{"^v9.0.0$":"main","^v8.17.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["bug","release_note:skip","v9.0.0","Feature:Security
Assistant","ci:project-deploy-security","Team:Security Generative
AI","v8.16.0","backport:version","v8.17.0"],"number":197007,"url":"https://github.com/elastic/kibana/pull/197007","mergeCommit":{"message":"[Security
Assistant] Knowledge base switch to use `semantic_text` (#197007)\n\n##
Summary\n\n- `text_expansion` is deprecated, use `semantic_text`
instead\n- fix KB index entry form field options \n- explicitly create
inference endpoint on KB setup if\n`assistantKnowledgeBaseByDefault` is
true\n- when upgrade from v1 update KB ingest pipeline and remove
unnecessary\nprocessor, but keep the pipeline for the backward
compatibility\n- switch to use `doc` update for KB entries due to the
limitations
od\n`semantic_text`\nhttps://www.elastic.co/guide/en/elasticsearch/reference/current/semantic-text.html#update-script\n-
split loading Security labs content into smaller
chunks\n\n---------\n\nCo-authored-by: kibanamachine
<42973632+kibanamachine@users.noreply.github.com>\nCo-authored-by: Pedro
Jaramillo
<pedro.jaramillo@elastic.co>","sha":"a8c54f2ea4f482285eda15c72c56da35d76a6719"}},"sourceBranch":"main","suggestedTargetBranches":["8.16"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","labelRegex":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/197007","number":197007,"mergeCommit":{"message":"[Security
Assistant] Knowledge base switch to use `semantic_text` (#197007)\n\n##
Summary\n\n- `text_expansion` is deprecated, use `semantic_text`
instead\n- fix KB index entry form field options \n- explicitly create
inference endpoint on KB setup if\n`assistantKnowledgeBaseByDefault` is
true\n- when upgrade from v1 update KB ingest pipeline and remove
unnecessary\nprocessor, but keep the pipeline for the backward
compatibility\n- switch to use `doc` update for KB entries due to the
limitations
od\n`semantic_text`\nhttps://www.elastic.co/guide/en/elasticsearch/reference/current/semantic-text.html#update-script\n-
split loading Security labs content into smaller
chunks\n\n---------\n\nCo-authored-by: kibanamachine
<42973632+kibanamachine@users.noreply.github.com>\nCo-authored-by: Pedro
Jaramillo
<pedro.jaramillo@elastic.co>","sha":"a8c54f2ea4f482285eda15c72c56da35d76a6719"}},{"branch":"8.16","label":"v8.16.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.x","label":"v8.17.0","labelRegex":"^v8.17.0$","isSourceBranch":false,"url":"https://github.com/elastic/kibana/pull/198437","number":198437,"state":"OPEN"}]}]
BACKPORT-->
2024-10-30 16:03:48 -06:00
..
src [8.16] [Security Assistant] Knowledge base switch to use semantic_text (#197007) (#198439) 2024-10-30 16:03:48 -06:00
index.ts Adds AGPL 3.0 license (#192025) 2024-09-06 19:02:41 -06:00
jest.config.js Adds AGPL 3.0 license (#192025) 2024-09-06 19:02:41 -06:00
kibana.jsonc [Security Solution] Data quality dashboard persistence (#173185) 2024-01-24 10:20:49 -07:00
package.json Adds AGPL 3.0 license (#192025) 2024-09-06 19:02:41 -06:00
README.md [Security Solution] Data quality dashboard persistence (#173185) 2024-01-24 10:20:49 -07:00
tsconfig.json [DataStreamAdapter] Remove alerts-as-data package dependency (#178127) 2024-03-06 17:51:17 +01:00

@kbn/data-stream-adapter

Utility library for Elasticsearch data stream management.

DataStreamAdapter

Manage single data streams. Example:

// Setup
const dataStream = new DataStreamAdapter('my-awesome-datastream', { kibanaVersion: '8.12.1' });

dataStream.setComponentTemplate({
    name: 'awesome-component-template',
    fieldMap: {
        'awesome.field1: { type: 'keyword', required: true },
        'awesome.nested.field2: { type: 'number', required: false },
        // ...
    },
});

dataStream.setIndexTemplate({
    name: 'awesome-index-template',
    componentTemplateRefs: ['awesome-component-template', 'ecs-component-template'],
    template: {
        lifecycle: {
            data_retention: '5d',
        },
    },
});

// Start
await dataStream.install({ logger, esClient, pluginStop$ }); // Installs templates and the data stream, or updates existing.

DataStreamSpacesAdapter

Manage data streams per space. Example:

// Setup
const spacesDataStream = new DataStreamSpacesAdapter('my-awesome-datastream', { kibanaVersion: '8.12.1' });

spacesDataStream.setComponentTemplate({
    name: 'awesome-component-template',
    fieldMap: {
        'awesome.field1: { type: 'keyword', required: true },
        'awesome.nested.field2: { type: 'number', required: false },
        // ...
    },
});

spacesDataStream.setIndexTemplate({
    name: 'awesome-index-template',
    componentTemplateRefs: ['awesome-component-template', 'ecs-component-template'],
    template: {
        lifecycle: {
            data_retention: '5d',
        },
    },
});

// Start
await spacesDataStream.install({ logger, esClient, pluginStop$ }); // Installs templates and updates existing data streams.

// Create a space data stream on the fly
await spacesDataStream.installSpace('space2'); // creates 'my-awesome-datastream-space2' data stream if it does not exist.