Skip to content

[Logs Shared] Move LogStream and LogView into new shared plugin#161151

Merged
tonyghiani merged 87 commits intoelastic:mainfrom
tonyghiani:tonyghiani-159128-split-log-stream-into-plugin
Jul 5, 2023
Merged

[Logs Shared] Move LogStream and LogView into new shared plugin#161151
tonyghiani merged 87 commits intoelastic:mainfrom
tonyghiani:tonyghiani-159128-split-log-stream-into-plugin

Conversation

@tonyghiani
Copy link
Copy Markdown
Contributor

📓 Summary

Closes #159128

Due to a dependencies issue when disabling a plugin in serverless mode, the LogStream feature and related logic were disabled for every consumer.

We decided to split this shared component and endpoint into their own plugin of shared logs utilities, reducing to the minimum the required dependency that could disable the plugin.

What we moved can be summarized with:

  • infrastructure-monitoring-log-view saved object definition and registration
  • LogViews server/client services (exposed with start contract) + related endpoints
  • LogEntries server service + related endpoints
  • LogEntriesDomain logic (exposed with start contract)
  • <LogStream /> component
  • <ScrollableLogTextStreamView /> component and related logic
  • LogView state machine
  • Containers/Hooks to consume the moved APIs.
  • Common types/utils definition, now exported and consumed as a dependency from the infra plugin.

🤓 Review hints

Most of the changes are just renaming and moving stuff into the new plugin, but for some operations was required to implement new logic, which may deserve a more critical review:

  • server/public plugin.ts files for the infra and logs_shared plugins. The new plugin now registers the fallback actions to retrieve a source configuration if there's no stored log view. It also set the configuration for the message field and registers the log view saved object.
  • the logEntriesDomain has also been moved inside the new plugin, but is also used by the logs-analysis endpoints, so it is exposed by the logs_shared plugin and consumed by infra.

👣 Following steps

We currently are still using the observability plugin for consuming the CoPilot feature on our LogsStream flyout.
The plugin dependency is marked as optional, so disabling the observability plugin in a serverless environment won't disable also the exposed features in this new plugin, but it'll affect only the CoPilot feature, which won't be loaded.

In future, would be nice to extract the CoPilot feature into its own package/plugin, so that also serverless projects can consume it without depending on `observability.

Marco Antonio Ghiani and others added 30 commits June 7, 2023 12:04
@ghost
Copy link
Copy Markdown

ghost commented Jul 4, 2023

🤖 GitHub comments

Expand to view the GitHub comments

Just comment with:

  • /oblt-deploy : Deploy a Kibana instance using the Observability test environments.
  • run elasticsearch-ci/docs : Re-trigger the docs validation. (use unformatted text in the comment!)

@tonyghiani tonyghiani added Team:Infra Monitoring UI - DEPRECATED DEPRECATED - Label for the Infra Monitoring UI team. Use Team:obs-ux-infra_services release_note:skip Skip the PR/issue when compiling release notes labels Jul 4, 2023
@elasticmachine
Copy link
Copy Markdown
Contributor

Pinging @elastic/infra-monitoring-ui (Team:Infra Monitoring UI)

Marco Antonio Ghiani added 2 commits July 4, 2023 10:26
…ub.com:tonyghiani/kibana into tonyghiani-159128-split-log-stream-into-plugin
@kibana-ci
Copy link
Copy Markdown

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
infra 1474 1380 -94
logsShared - 179 +179
total +85

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
infra 46 41 -5
logsShared - 256 +256
total +251

Any counts in public APIs

Total count of every any typed public API. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats any for more detailed information.

id before after diff
logsShared - 10 +10

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
infra 2.0MB 2.0MB -56.1KB
logsShared - 56.8KB +56.8KB
total +746.0B

Public APIs missing exports

Total count of every type that is part of your API that should be exported but is not. This will cause broken links in the API documentation system. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats exports for more detailed information.

id before after diff
infra 14 11 -3
logsShared - 27 +27
total +24

Page load bundle

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

id before after diff
apm 36.2KB 36.2KB +5.0B
enterpriseSearch 38.0KB 38.0KB +5.0B
fleet 133.8KB 133.8KB +5.0B
infra 119.7KB 93.8KB -25.9KB
logsShared - 218.7KB ⚠️ +218.7KB
total +192.8KB
Unknown metric groups

API count

id before after diff
infra 49 44 -5
logsShared - 269 +269
total +264

async chunk count

id before after diff
infra 29 27 -2
logsShared - 8 +8
total +6

ESLint disabled in files

id before after diff
infra 10 9 -1
logsShared - 3 +3
total +2

ESLint disabled line counts

id before after diff
enterpriseSearch 14 16 +2
infra 52 51 -1
logsShared - 6 +6
securitySolution 410 414 +4
total +11

References to deprecated APIs

id before after diff
infra 65 60 -5
logsShared - 5 +5
total -0

Total ESLint disabled count

id before after diff
enterpriseSearch 15 17 +2
infra 62 60 -2
logsShared - 9 +9
securitySolution 489 493 +4
total +13

History

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

@tonyghiani tonyghiani merged commit abe58cb into elastic:main Jul 5, 2023
@tonyghiani tonyghiani deleted the tonyghiani-159128-split-log-stream-into-plugin branch July 5, 2023 08:30
@kibanamachine kibanamachine added v8.10.0 backport:skip This PR does not require backporting labels Jul 5, 2023
jloleysens added a commit to jloleysens/kibana that referenced this pull request Jul 5, 2023
* main: (354 commits)
  [Synthetics] Overview page fix last refresh value display (elastic#161086)
  [Synthetics] Remove TLS alert option for ICMP monitor (elastic#161173)
  fixing the path of manifets for hints autodiscover (elastic#161075)
  [Fleet] Fix permissions in integrations Assets page (elastic#161233)
  Update publicBaseUrl warning id (elastic#161204)
  [ML] Fix Anomaly Explorer URL for alerting context with non-default space  (elastic#160899)
  [Enterprise Search]Add 404 error handling for mappings and documents endpoints (elastic#161203)
  [Logs Shared] Move LogStream and LogView into new shared plugin (elastic#161151)
  [Security Solutions] Fix  CellActions component should hide ShowTopN action for nested fields (elastic#159645)
  [SecuritySolutions] Remove filter actions from Cases alerts table and fix show_top_n action (elastic#161150)
  [Infrastructure UI] Add strict payload validation to inventory_views endpoint (elastic#160852)
  [api-docs] 2023-07-05 Daily api_docs build (elastic#161225)
  Fix errors in custom metric payload in SLO dev docs (elastic#161141)
  [data views] Fix overwrite param for create (elastic#160953)
  [Synthetics] Perform params API HTTP migration (elastic#160575)
  [Cloud Security][FTR]Refactor API FTR to use .to.eql instead of .to.be  (elastic#160694)
  Have SLO routes return a 403 instead of a 400 when user has an insufficient license (elastic#161193)
  [Discover] Fix shared links flaky test (elastic#161172)
  [ftr] Improve FTR error handling for NoSuchSessionError (elastic#161025)
  skip flaky suite (elastic#151981)
  ...
jloleysens added a commit to jloleysens/kibana that referenced this pull request Jul 5, 2023
* main: (354 commits)
  [Synthetics] Overview page fix last refresh value display (elastic#161086)
  [Synthetics] Remove TLS alert option for ICMP monitor (elastic#161173)
  fixing the path of manifets for hints autodiscover (elastic#161075)
  [Fleet] Fix permissions in integrations Assets page (elastic#161233)
  Update publicBaseUrl warning id (elastic#161204)
  [ML] Fix Anomaly Explorer URL for alerting context with non-default space  (elastic#160899)
  [Enterprise Search]Add 404 error handling for mappings and documents endpoints (elastic#161203)
  [Logs Shared] Move LogStream and LogView into new shared plugin (elastic#161151)
  [Security Solutions] Fix  CellActions component should hide ShowTopN action for nested fields (elastic#159645)
  [SecuritySolutions] Remove filter actions from Cases alerts table and fix show_top_n action (elastic#161150)
  [Infrastructure UI] Add strict payload validation to inventory_views endpoint (elastic#160852)
  [api-docs] 2023-07-05 Daily api_docs build (elastic#161225)
  Fix errors in custom metric payload in SLO dev docs (elastic#161141)
  [data views] Fix overwrite param for create (elastic#160953)
  [Synthetics] Perform params API HTTP migration (elastic#160575)
  [Cloud Security][FTR]Refactor API FTR to use .to.eql instead of .to.be  (elastic#160694)
  Have SLO routes return a 403 instead of a 400 when user has an insufficient license (elastic#161193)
  [Discover] Fix shared links flaky test (elastic#161172)
  [ftr] Improve FTR error handling for NoSuchSessionError (elastic#161025)
  skip flaky suite (elastic#151981)
  ...
Kerry350 added a commit that referenced this pull request Aug 17, 2023
## Summary

As part of #161151 a [selection of
component imports were made
lazy](https://github.com/elastic/kibana/blob/main/x-pack/plugins/logs_shared/public/index.ts#L52)
and wrapped with a [`dynamic` wrapper
component](https://github.com/elastic/kibana/blob/main/x-pack/plugins/logs_shared/common/dynamic.tsx#L22).
Unfortunately some of these imports did not adhere to the rules of
React's `lazy` imports (needing a `default` export, no named imports
etc), and the `dynamic` wrapper seems to have suppressed error
information that would have been available via using `lazy` directly.

Only the anomaly and categories log entry examples (in the expanded
rows) were affected by this, as the stream and embeddable import from
locations that were backed by a `default` export (and those top level
components don't import from that particular index file lower in the
hierarchy). For imports that weren't backed by a `default` I've added
them, and where necessary moved components to new files if needed (since
it's one `default` per file).

Also open to suggestions of ways we can alter the `<dynamic />`
component and maintain the error safety 🤔

## Examples

Without these changes:

![Screenshot 2023-08-16 at 17 35
50](https://github.com/elastic/kibana/assets/471693/78aa0300-109e-40b5-b64f-6574a547cbf3)

Warning using `lazy` directly without the `dynamic` wrapper:

![Screenshot 2023-08-16 at 17 36
27](https://github.com/elastic/kibana/assets/471693/a71e3c72-cf3a-4846-9ee9-df70c1729b03)

## Testing

- Check all instances render correctly (stream, embeddable uses, and ML
page log entry examples).
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Aug 17, 2023
## Summary

As part of elastic#161151 a [selection of
component imports were made
lazy](https://github.com/elastic/kibana/blob/main/x-pack/plugins/logs_shared/public/index.ts#L52)
and wrapped with a [`dynamic` wrapper
component](https://github.com/elastic/kibana/blob/main/x-pack/plugins/logs_shared/common/dynamic.tsx#L22).
Unfortunately some of these imports did not adhere to the rules of
React's `lazy` imports (needing a `default` export, no named imports
etc), and the `dynamic` wrapper seems to have suppressed error
information that would have been available via using `lazy` directly.

Only the anomaly and categories log entry examples (in the expanded
rows) were affected by this, as the stream and embeddable import from
locations that were backed by a `default` export (and those top level
components don't import from that particular index file lower in the
hierarchy). For imports that weren't backed by a `default` I've added
them, and where necessary moved components to new files if needed (since
it's one `default` per file).

Also open to suggestions of ways we can alter the `<dynamic />`
component and maintain the error safety 🤔

## Examples

Without these changes:

![Screenshot 2023-08-16 at 17 35
50](https://github.com/elastic/kibana/assets/471693/78aa0300-109e-40b5-b64f-6574a547cbf3)

Warning using `lazy` directly without the `dynamic` wrapper:

![Screenshot 2023-08-16 at 17 36
27](https://github.com/elastic/kibana/assets/471693/a71e3c72-cf3a-4846-9ee9-df70c1729b03)

## Testing

- Check all instances render correctly (stream, embeddable uses, and ML
page log entry examples).

(cherry picked from commit a96785c)
kibanamachine added a commit that referenced this pull request Aug 17, 2023
…4180)

# Backport

This will backport the following commits from `main` to `8.10`:
- [[Logs] Amend lazy imports in logs_shared plugin
(#164102)](#164102)

<!--- Backport version: 8.9.7 -->

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

<!--BACKPORT [{"author":{"name":"Kerry
Gallagher","email":"kerry.gallagher@elastic.co"},"sourceCommit":{"committedDate":"2023-08-17T13:44:57Z","message":"[Logs]
Amend lazy imports in logs_shared plugin (#164102)\n\n##
Summary\r\n\r\nAs part of #161151
a [selection of\r\ncomponent imports were
made\r\nlazy](https://github.com/elastic/kibana/blob/main/x-pack/plugins/logs_shared/public/index.ts#L52)\r\nand
wrapped with a [`dynamic`
wrapper\r\ncomponent](https://github.com/elastic/kibana/blob/main/x-pack/plugins/logs_shared/common/dynamic.tsx#L22).\r\nUnfortunately
some of these imports did not adhere to the rules of\r\nReact's `lazy`
imports (needing a `default` export, no named imports\r\netc), and the
`dynamic` wrapper seems to have suppressed error\r\ninformation that
would have been available via using `lazy` directly.\r\n\r\nOnly the
anomaly and categories log entry examples (in the expanded\r\nrows) were
affected by this, as the stream and embeddable import from\r\nlocations
that were backed by a `default` export (and those top
level\r\ncomponents don't import from that particular index file lower
in the\r\nhierarchy). For imports that weren't backed by a `default`
I've added\r\nthem, and where necessary moved components to new files if
needed (since\r\nit's one `default` per file).\r\n\r\nAlso open to
suggestions of ways we can alter the `<dynamic />`\r\ncomponent and
maintain the error safety 🤔\r\n\r\n## Examples\r\n\r\nWithout these
changes:\r\n\r\n![Screenshot 2023-08-16 at 17
35\r\n50](https://github.com/elastic/kibana/assets/471693/78aa0300-109e-40b5-b64f-6574a547cbf3)\r\n\r\nWarning
using `lazy` directly without the `dynamic` wrapper:\r\n\r\n![Screenshot
2023-08-16 at 17
36\r\n27](https://github.com/elastic/kibana/assets/471693/a71e3c72-cf3a-4846-9ee9-df70c1729b03)\r\n\r\n##
Testing\r\n\r\n- Check all instances render correctly (stream,
embeddable uses, and ML\r\npage log entry
examples).","sha":"a96785cd2cf6dc28b6d786423e4604a7aee10c97","branchLabelMapping":{"^v8.10.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["bug","release_note:fix","Feature:Logs
UI","Team:Infra Monitoring
UI","v8.10.0","v8.11.0"],"number":164102,"url":"https://github.com/elastic/kibana/pull/164102","mergeCommit":{"message":"[Logs]
Amend lazy imports in logs_shared plugin (#164102)\n\n##
Summary\r\n\r\nAs part of #161151
a [selection of\r\ncomponent imports were
made\r\nlazy](https://github.com/elastic/kibana/blob/main/x-pack/plugins/logs_shared/public/index.ts#L52)\r\nand
wrapped with a [`dynamic`
wrapper\r\ncomponent](https://github.com/elastic/kibana/blob/main/x-pack/plugins/logs_shared/common/dynamic.tsx#L22).\r\nUnfortunately
some of these imports did not adhere to the rules of\r\nReact's `lazy`
imports (needing a `default` export, no named imports\r\netc), and the
`dynamic` wrapper seems to have suppressed error\r\ninformation that
would have been available via using `lazy` directly.\r\n\r\nOnly the
anomaly and categories log entry examples (in the expanded\r\nrows) were
affected by this, as the stream and embeddable import from\r\nlocations
that were backed by a `default` export (and those top
level\r\ncomponents don't import from that particular index file lower
in the\r\nhierarchy). For imports that weren't backed by a `default`
I've added\r\nthem, and where necessary moved components to new files if
needed (since\r\nit's one `default` per file).\r\n\r\nAlso open to
suggestions of ways we can alter the `<dynamic />`\r\ncomponent and
maintain the error safety 🤔\r\n\r\n## Examples\r\n\r\nWithout these
changes:\r\n\r\n![Screenshot 2023-08-16 at 17
35\r\n50](https://github.com/elastic/kibana/assets/471693/78aa0300-109e-40b5-b64f-6574a547cbf3)\r\n\r\nWarning
using `lazy` directly without the `dynamic` wrapper:\r\n\r\n![Screenshot
2023-08-16 at 17
36\r\n27](https://github.com/elastic/kibana/assets/471693/a71e3c72-cf3a-4846-9ee9-df70c1729b03)\r\n\r\n##
Testing\r\n\r\n- Check all instances render correctly (stream,
embeddable uses, and ML\r\npage log entry
examples).","sha":"a96785cd2cf6dc28b6d786423e4604a7aee10c97"}},"sourceBranch":"main","suggestedTargetBranches":["8.11"],"targetPullRequestStates":[{"branch":"main","label":"v8.10.0","labelRegex":"^v8.10.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/164102","number":164102,"mergeCommit":{"message":"[Logs]
Amend lazy imports in logs_shared plugin (#164102)\n\n##
Summary\r\n\r\nAs part of #161151
a [selection of\r\ncomponent imports were
made\r\nlazy](https://github.com/elastic/kibana/blob/main/x-pack/plugins/logs_shared/public/index.ts#L52)\r\nand
wrapped with a [`dynamic`
wrapper\r\ncomponent](https://github.com/elastic/kibana/blob/main/x-pack/plugins/logs_shared/common/dynamic.tsx#L22).\r\nUnfortunately
some of these imports did not adhere to the rules of\r\nReact's `lazy`
imports (needing a `default` export, no named imports\r\netc), and the
`dynamic` wrapper seems to have suppressed error\r\ninformation that
would have been available via using `lazy` directly.\r\n\r\nOnly the
anomaly and categories log entry examples (in the expanded\r\nrows) were
affected by this, as the stream and embeddable import from\r\nlocations
that were backed by a `default` export (and those top
level\r\ncomponents don't import from that particular index file lower
in the\r\nhierarchy). For imports that weren't backed by a `default`
I've added\r\nthem, and where necessary moved components to new files if
needed (since\r\nit's one `default` per file).\r\n\r\nAlso open to
suggestions of ways we can alter the `<dynamic />`\r\ncomponent and
maintain the error safety 🤔\r\n\r\n## Examples\r\n\r\nWithout these
changes:\r\n\r\n![Screenshot 2023-08-16 at 17
35\r\n50](https://github.com/elastic/kibana/assets/471693/78aa0300-109e-40b5-b64f-6574a547cbf3)\r\n\r\nWarning
using `lazy` directly without the `dynamic` wrapper:\r\n\r\n![Screenshot
2023-08-16 at 17
36\r\n27](https://github.com/elastic/kibana/assets/471693/a71e3c72-cf3a-4846-9ee9-df70c1729b03)\r\n\r\n##
Testing\r\n\r\n- Check all instances render correctly (stream,
embeddable uses, and ML\r\npage log entry
examples).","sha":"a96785cd2cf6dc28b6d786423e4604a7aee10c97"}},{"branch":"8.11","label":"v8.11.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Kerry Gallagher <kerry.gallagher@elastic.co>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:skip This PR does not require backporting release_note:skip Skip the PR/issue when compiling release notes Team:APM - DEPRECATED Use Team:obs-ux-infra_services. Team:Fleet Team label for Observability Data Collection Fleet team Team:Infra Monitoring UI - DEPRECATED DEPRECATED - Label for the Infra Monitoring UI team. Use Team:obs-ux-infra_services v8.10.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Split log stream into a separate plugin