[Logs UI] <LogStream /> as a kibana embeddable#88618
[Logs UI] <LogStream /> as a kibana embeddable#88618afgomez merged 12 commits intoelastic:masterfrom
Conversation
bcf5b6c to
6766aed
Compare
102370d to
b487a0a
Compare
|
Pinging @elastic/logs-metrics-ui (Team:logs-metrics-ui) |
|
@elasticmachine merge upstream |
weltenwort
left a comment
There was a problem hiding this comment.
Not a code review, but our earlier conversation about the bundle size provoked my curiosity to see whether anything can be done quickly.
Just wanted to persist my thoughts, feel free to ignore. 😉
|
|
||
| public async create(initialInput: LogStreamEmbeddableInput, parent?: IContainer) { | ||
| const services = await this.getCoreServices(); | ||
| return new LogStreamEmbeddable(services, initialInput, parent); |
There was a problem hiding this comment.
Could we await import() this in here?
There was a problem hiding this comment.
Could we await import() this in here?
we can try, but given the size of the LogStreamEmbeddable module I'm not sure it will be worth it. Whatever gains we have in the bundle size will probably get lost with the overhead of the extra network request.
|
|
||
| export class LogStreamEmbeddableFactoryDefinition | ||
| implements EmbeddableFactoryDefinition<LogStreamEmbeddableInput> { | ||
| public readonly type = LOG_STREAM_EMBEDDABLE; |
There was a problem hiding this comment.
If we duplicate the constant or put it into a separate file in combination with importing the LogStreamEmbeddable asynchronously (see below), couldn't we avoid the sync runtime import?
| } from './types'; | ||
| import { getLogsHasDataFetcher, getLogsOverviewDataFetcher } from './utils/logs_overview_fetchers'; | ||
| import { createMetricsHasData, createMetricsFetchData } from './metrics_overview_fetchers'; | ||
| import { LOG_STREAM_EMBEDDABLE } from './components/log_stream/log_stream_embeddable'; |
There was a problem hiding this comment.
If we imported the constant from a separate file here too, wouldn't that turn this into a cheaper import?
There was a problem hiding this comment.
Code looks good, and works great 🎉
Since the <LogStream /> component is so popular it might be nice to provide an example in the docs or Storybook for how solutions can use the embeddable directly outside of the dashboard context. There's an <EmbeddableRenderer /> component that cuts down a lot of the boilerplate.
import { EmbeddableRenderer } from 'src/plugins/embeddable/public'
const { embeddable: embeddablePlugin } = useKibanaContextForPlugin().services;
const factory: any = embeddablePlugin.getEmbeddableFactory(LOG_STREAM_EMBEDDABLE);
const embeddableInput: LogStreamEmbeddableInput = useMemo(() => {
return {
timeRange,
query
}
}, [timeRange, query]);
return (
<EmbeddableRenderer input={embeddableInput} factory={factory} />
)Feel free to ignore though, I know adoption has been absolutely fine without the embeddable 😄
| return queryObj.query as string; | ||
| } | ||
|
|
||
| if (queryObj.language === 'lucene') { |
There was a problem hiding this comment.
👍
Do you want to address that in a separate followup? Do we know if there's something in the data plugin that could help there?
There was a problem hiding this comment.
I wanna tackle this today in this PR. I haven't looked into it yet, but I think what makes the most sense is to allow the <LogStream /> component to accept lucene queries, something like:
<LogStream
query="whatever"
queryLang="lucene"
/>
The queryLang will be optional and will default to "KQL", so we don't break anything.
Do you think it makes sense?
There was a problem hiding this comment.
Cool, sounds good. There's a Query type provided by the data plugin, and it probably makes most sense to use that as our prop so we're following the conventions set there.
The ML anomaly swimlane embeddable uses that here: https://github.com/elastic/kibana/blob/master/x-pack/plugins/ml/public/embeddables/types.ts#L34, and the type looks like so: https://github.com/elastic/kibana/blob/master/src/plugins/data/common/query/types.ts#L12
So it's basically exactly what you've said, but it's nice to buy into the data stuff where we can.
|
@Kerry350 do you mind taking another look at the last commits? The embeddable handles lucene queries now |
💚 Build SucceededMetrics [docs]Module Count
Async chunks
Page load bundle
History
To update your PR or re-run it, just comment with: |

Summary
Expose the
<LogStream />component as a kibana embeddable.Closes #84549
How to test
infraplugin enabled and data in anyfilebeat-*orlogs-*index.
4. Click on "Create new" and then select "Log Stream"
5. A log stream embeddable should appear. It should update when the date range or the query changes.Screenshots
Notes/ToDo
<LogStream />component accepts KQL queries. I need to find a way to either translate lucene queries into KQL, or modify the component to also take lucene queries.Checklist
Delete any items that are not applicable to this PR.