Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CM] Event Stream service #153211

Merged
merged 31 commits into from
Apr 5, 2023
Merged

[CM] Event Stream service #153211

merged 31 commits into from
Apr 5, 2023

Conversation

vadimkibana
Copy link
Contributor

@vadimkibana vadimkibana commented Mar 14, 2023

Summary

This PR implements the Event Stream service for Content Management.

For high-level overview see:

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.

For maintainers

@vadimkibana vadimkibana changed the title Event stream 6 [CM] Event Stream service Mar 15, 2023
@vadimkibana vadimkibana added review release_note:skip Skip the PR/issue when compiling release notes Team:SharedUX Team label for AppEx-SharedUX (formerly Global Experience) Feature:Content Management User generated content (saved objects) management v8.8.0 labels Mar 15, 2023
@vadimkibana vadimkibana self-assigned this Mar 15, 2023
@vadimkibana vadimkibana marked this pull request as ready for review March 15, 2023 07:45
@vadimkibana vadimkibana requested review from a team as code owners March 15, 2023 07:45
@elasticmachine
Copy link
Contributor

Pinging @elastic/appex-sharedux (Team:SharedUX)

Copy link
Contributor

@sebelga sebelga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing work @vadimkibana ! Overall looks great, I left a few questions but no blockers. Great test coverage 👍

@vadimkibana
Copy link
Contributor Author

@elasticmachine merge upstream

Copy link
Member

@lukasolson lukasolson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DataDiscovery changes LGTM (code review only), suggested tests.

@vadimkibana
Copy link
Contributor Author

vadimkibana commented Mar 21, 2023

Maybe take a look at ES client retry logic, maybe disable. Maybe idempotent id generate on client.

@vadimkibana
Copy link
Contributor Author

@elasticmachine merge upstream

@vadimkibana
Copy link
Contributor Author

@elasticmachine merge upstream

@Dosant Dosant self-assigned this Mar 30, 2023
Copy link
Member

@pmuellr pmuellr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for the changes!

Copy link
Member

@azasypkin azasypkin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Dosant
Copy link
Contributor

Dosant commented Apr 3, 2023

@elasticmachine merge upstream

@Dosant
Copy link
Contributor

Dosant commented Apr 3, 2023

@elasticmachine merge upstream

@Dosant
Copy link
Contributor

Dosant commented Apr 4, 2023

@elasticmachine merge upstream

@Dosant
Copy link
Contributor

Dosant commented Apr 4, 2023

@elasticmachine merge upstream

@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
@kbn/es-query 193 197 +4
bfetch 74 75 +1
total +5

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
bfetch 6.7KB 6.9KB +128.0B
kbnUiSharedDeps-srcJs 2.2MB 2.2MB +136.0B
total +264.0B
Unknown metric groups

API count

id before after diff
@kbn/es-query 251 255 +4
bfetch 89 91 +2
total +6

ESLint disabled line counts

id before after diff
securitySolution 432 435 +3

Total ESLint disabled count

id before after diff
securitySolution 512 515 +3

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

cc @Dosant @vadimkibana

@Dosant Dosant merged commit f442a0d into elastic:main Apr 5, 2023
@kibanamachine kibanamachine added the backport:skip This commit does not require backporting label Apr 5, 2023
nreese pushed a commit to nreese/kibana that referenced this pull request Apr 10, 2023
## 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 <[email protected]>
Co-authored-by: Anton Dosov <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting Feature:Content Management User generated content (saved objects) management Feature:ExpressionLanguage Interpreter expression language (aka canvas pipeline) release_note:skip Skip the PR/issue when compiling release notes review Team:SharedUX Team label for AppEx-SharedUX (formerly Global Experience) v8.8.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants