kibana/packages/kbn-es-query
Vadim Kibana f442a0dd6b
[CM] Event Stream service (#153211)
## Summary

This PR implements the Event Stream service for Content Management.

For high-level overview see:

- [Event Stream technical
summary](https://docs.google.com/document/d/1nyMhb0p4gNV43OVF6cLJkxhMf2V4V1BIjPsnACxe_t0/edit#heading=h.typ7x7sxmeye)
(a bit old, but still good as general overview read)

Implementation details in this PR:

- This PR introduces the `EventStreamService` high-level class, which is
the public interface to the Event Stream, holds any necessary state, and
follows plugin life-cycle methods.
- On a lower level the actual event storage is defined in the
`EventStreamClient` interface.
- There are two `EventStreamClient` implementations:
- `EsEventStreamClient` is the production implementation, which stores
events to Elasticsearch.
- `MemoryEventStreamClient` is used for testing and could be used for
demo purposes.
- The same test suite `testEventStreamClient` is reused for
`EsEventStreamClient` and `MemoryEventStreamClient`, which should help
with verifying that both implements work correctly and the same. For
`EsEventStreamClient` it is executed as Kibana integration test, but for
`MemoryEventStreamClient` it is executed as a Jest test.
- In `EventStreamService` events are buffered for 250ms or up to 100
events before they are flushed to the storage.
- Events are stored in the `.kibana-event-stream` data stream.
- The data stream and index template are create during plugin
initialization "start" life-cycle, similar to how it is done in the
Event Log and in the Reporting index.
- The mappings define a `meta` field, which is currently unused, but
will allow to add more fields in the future without needing to change
the schema of the data stream.
- The mappings define a transaction ID `txId` field, which can be used
to correlate multiple related events together or to store the
transaction ID.
- Events are written to Elasticsearch using the `_bulk` request API.



### Checklist

Delete any items that are not applicable to this PR.

- [x] [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

### For maintainers

- [x] This was checked for breaking API changes and was [labeled
appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)

---------
Co-authored-by: Aleh Zasypkin <aleh.zasypkin@gmail.com>
Co-authored-by: Anton Dosov <anton.dosov@elastic.co>
2023-04-05 11:35:09 +02:00
..
src [CM] Event Stream service (#153211) 2023-04-05 11:35:09 +02:00
BUILD.bazel Transpile packages on demand, validate all TS projects (#146212) 2022-12-22 19:00:29 -06:00
index.ts [Filters] Add support for combined filter query DSL editing (#148590) 2023-01-16 02:21:24 -07:00
jest.config.js [Es query] Move to package (#103530) 2021-07-21 17:10:55 +02:00
kibana.jsonc Update codeowners to move AppServices packages to DataDiscovery (#149065) 2023-01-18 13:34:28 -07:00
package.json Transpile packages on demand, validate all TS projects (#146212) 2022-12-22 19:00:29 -06:00
README.md [Es query] Move to package (#103530) 2021-07-21 17:10:55 +02:00
tsconfig.json Fix eslint rule for restricting certain lodash imports (#151023) 2023-02-16 08:35:09 -07:00

@kbn/es-query

Shared common (client and server sie) utilities shared across packages and plugins.