-
Notifications
You must be signed in to change notification settings - Fork 8.5k
[Discover][Traces] Showing Logs in context of the trace #232784
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
Merged
Merged
Changes from all commits
Commits
Show all changes
36 commits
Select commit
Hold shift + click to select a range
fef99c9
Display logs with LogsOverview component
kpatticha 98441e9
Merge branch 'main' of github.com:elastic/kibana into discover-add-logs
kpatticha 701f9f1
Remove the observability-logs-overview feature
kpatticha f708be5
Display trace context log event in trace flyout
kpatticha efb86df
Default columns
kpatticha db8848d
Update the query
kpatticha 6cafbde
Fix height
kpatticha 2415a24
Fix types
kpatticha 95103e1
Fix broken mock
kpatticha b1149b4
Fix storybook
kpatticha 25842fe
fix type
kpatticha cd0ef0d
[CI] Auto-commit changed files from 'node scripts/notice'
kibanamachine 588761d
Merge branch 'main' of github.com:elastic/kibana into discover-add-logs
kpatticha 5262323
Fix types
kpatticha 9de3cdd
Set max height for section content
kpatticha 2f791c7
Merge branch 'discover-add-logs' of github.com:kpatticha/kibana into …
kpatticha e943125
Use discover feature
kpatticha 4b916cf
More embeddable types in discover-utils
kpatticha 76c59f8
[CI] Auto-commit changed files from 'node scripts/notice'
kibanamachine b785a12
Revert "More embeddable types in discover-utils"
kpatticha 12bf80f
Register the log eventts table as feature in discover
kpatticha c60600d
Merge branch 'discover-add-logs' of github.com:kpatticha/kibana into …
kpatticha 8bb839e
Merge branch 'main' into discover-add-logs
kpatticha b5c20b1
Clean up
kpatticha bb1f4d1
[CI] Auto-commit changed files from 'node scripts/notice'
kibanamachine d269371
Add a comment
kpatticha 8291611
Merge branch 'discover-add-logs' of github.com:kpatticha/kibana into …
kpatticha dcd7fd5
Fix eslint
kpatticha 60c2592
Add transactionId and add tests
kpatticha 11469c3
Remove the mock
kpatticha 9b9548f
Update description
kpatticha a629b9a
Merge branch 'main' into discover-add-logs
kpatticha 9b19edd
Merge branch 'main' of github.com:elastic/kibana into discover-add-logs
kpatticha 7d763ac
Merge branch 'discover-add-logs' of github.com:kpatticha/kibana into …
kpatticha 498f249
Fix types
kpatticha c02a5ec
Merge branch 'main' into discover-add-logs
kpatticha File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 4 additions & 16 deletions
20
src/platform/plugins/shared/unified_doc_viewer/kibana.jsonc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,28 +1,16 @@ | ||
| { | ||
| "type": "plugin", | ||
| "id": "@kbn/unified-doc-viewer-plugin", | ||
| "owner": [ | ||
| "@elastic/kibana-data-discovery" | ||
| ], | ||
| "owner": ["@elastic/kibana-data-discovery"], | ||
| "group": "platform", | ||
| "visibility": "shared", | ||
| "description": "This plugin contains services reliant on the plugin lifecycle for the unified doc viewer component (see @kbn/unified-doc-viewer).", | ||
| "plugin": { | ||
| "id": "unifiedDocViewer", | ||
| "browser": true, | ||
| "server": false, | ||
| "requiredPlugins": [ | ||
| "data", | ||
| "fieldFormats", | ||
| "share", | ||
| "embeddable", | ||
| "discoverShared" | ||
| ], | ||
| "optionalPlugins": [ | ||
| "fieldsMetadata" | ||
| ], | ||
| "requiredBundles": [ | ||
| "kibanaUtils" | ||
| ] | ||
| "requiredPlugins": ["data", "fieldFormats", "share", "embeddable", "discoverShared"], | ||
| "optionalPlugins": ["fieldsMetadata"], | ||
| "requiredBundles": ["kibanaUtils"] | ||
| } | ||
| } |
72 changes: 72 additions & 0 deletions
72
...ewer/public/components/observability/traces/components/trace_context_log_events/index.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the "Elastic License | ||
| * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side | ||
| * Public License v 1"; you may not use this file except in compliance with, at | ||
| * your election, the "Elastic License 2.0", the "GNU Affero General Public | ||
| * License v3.0 only", or the "Server Side Public License, v 1". | ||
| */ | ||
|
|
||
| import React, { useMemo } from 'react'; | ||
| import { i18n } from '@kbn/i18n'; | ||
| import { ContentFrameworkSection } from '../../../../content_framework/section'; | ||
| import { getUnifiedDocViewerServices } from '../../../../../plugin'; | ||
| import { useDataSourcesContext } from '../../hooks/use_data_sources'; | ||
| import { useLogsQuery } from '../../hooks/use_logs_query'; | ||
|
|
||
| const logsTitle = i18n.translate('unifiedDocViewer.observability.traces.section.logs.title', { | ||
| defaultMessage: 'Logs', | ||
| }); | ||
|
|
||
| const logsDescription = i18n.translate( | ||
| 'unifiedDocViewer.observability.traces.section.logs.description', | ||
| { | ||
| defaultMessage: 'Correlated logs that occurred during the span', | ||
| } | ||
| ); | ||
|
|
||
| export interface TraceContextLogEventsProps { | ||
| traceId: string; | ||
| spanId?: string; | ||
| transactionId?: string; | ||
| } | ||
| export function TraceContextLogEvents({ | ||
| traceId, | ||
| transactionId, | ||
| spanId, | ||
| }: TraceContextLogEventsProps) { | ||
| const { data: dataService, discoverShared } = getUnifiedDocViewerServices(); | ||
| const { indexes } = useDataSourcesContext(); | ||
| const { from, to } = dataService.query.timefilter.timefilter.getTime(); | ||
|
|
||
| const timeRange = useMemo(() => ({ from, to }), [from, to]); | ||
| const query = useLogsQuery({ traceId, spanId, transactionId }); | ||
|
|
||
| const savedSearchTimeRange = useMemo( | ||
| () => ({ | ||
| from: timeRange.from, | ||
| to: timeRange.to, | ||
| }), | ||
| [timeRange.from, timeRange.to] | ||
| ); | ||
|
|
||
| const LogEvents = discoverShared.features.registry.getById('observability-log-events'); | ||
|
|
||
| if (!LogEvents || !indexes.logs) { | ||
| return null; | ||
| } | ||
|
|
||
| const LogEventsComponent = LogEvents.render; | ||
|
|
||
| return ( | ||
| <ContentFrameworkSection | ||
| title={logsTitle} | ||
| description={logsDescription} | ||
| id="traceContextLogEvents" | ||
| > | ||
| <div tabIndex={0} className="eui-yScrollWithShadows" style={{ maxHeight: '400px' }}> | ||
| <LogEventsComponent query={query} timeRange={savedSearchTimeRange} index={indexes.logs} /> | ||
| </div> | ||
| </ContentFrameworkSection> | ||
| ); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
...d/unified_doc_viewer/public/components/observability/traces/hooks/use_logs_query.test.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the "Elastic License | ||
| * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side | ||
| * Public License v 1"; you may not use this file except in compliance with, at | ||
| * your election, the "Elastic License 2.0", the "GNU Affero General Public | ||
| * License v3.0 only", or the "Server Side Public License, v 1". | ||
| */ | ||
|
|
||
| import React from 'react'; | ||
| import { render, screen } from '@testing-library/react'; | ||
| import { useLogsQuery } from './use_logs_query'; | ||
|
|
||
| function TestComponent({ | ||
| traceId, | ||
| spanId, | ||
| transactionId, | ||
| }: { | ||
| traceId: string; | ||
| transactionId?: string; | ||
| spanId?: string; | ||
| }) { | ||
| const query = useLogsQuery({ traceId, spanId, transactionId }); | ||
| return <div data-test-subj="query">{query.query}</div>; | ||
| } | ||
|
|
||
| describe('useLogsQuery', () => { | ||
| it('builds query for traceId ', () => { | ||
| render(<TestComponent traceId="trace123" />); | ||
| const div = screen.getByTestId('query'); | ||
| expect(div.textContent).toBe(`(trace.id:"trace123" OR (not trace.id:* AND "trace123"))`); | ||
| }); | ||
|
|
||
| it('builds query for traceId, transactionId and spanId', () => { | ||
| render(<TestComponent traceId="trace123" spanId="span456" transactionId="transaction123" />); | ||
| const div = screen.getByTestId('query'); | ||
| expect(div.textContent).toBe( | ||
| `(trace.id:"trace123" OR (not trace.id:* AND "trace123")) AND ` + | ||
| `(transaction.id:"transaction123" OR (not transaction.id:* AND "transaction123")) AND ` + | ||
| `(span.id:"span456" OR (not span.id:* AND "span456"))` | ||
| ); | ||
| }); | ||
| }); |
41 changes: 41 additions & 0 deletions
41
.../shared/unified_doc_viewer/public/components/observability/traces/hooks/use_logs_query.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the "Elastic License | ||
| * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side | ||
| * Public License v 1"; you may not use this file except in compliance with, at | ||
| * your election, the "Elastic License 2.0", the "GNU Affero General Public | ||
| * License v3.0 only", or the "Server Side Public License, v 1". | ||
| */ | ||
|
|
||
| import { useMemo } from 'react'; | ||
| import { SPAN_ID_FIELD, TRACE_ID_FIELD, TRANSACTION_ID_FIELD } from '@kbn/discover-utils'; | ||
| export interface GetLogsQueryParams { | ||
| traceId: string; | ||
| transactionId?: string; | ||
| spanId?: string; | ||
| } | ||
|
|
||
| export function useLogsQuery({ traceId, spanId, transactionId }: GetLogsQueryParams) { | ||
| return useMemo(() => { | ||
| const queryStrings = [ | ||
| `(${TRACE_ID_FIELD}:"${traceId}" OR (not ${TRACE_ID_FIELD}:* AND "${traceId}"))`, | ||
| ]; | ||
|
|
||
| if (transactionId) { | ||
| queryStrings.push( | ||
| `(${TRANSACTION_ID_FIELD}:"${transactionId}" OR (not ${TRANSACTION_ID_FIELD}:* AND "${transactionId}"))` | ||
| ); | ||
| } | ||
|
|
||
| if (spanId) { | ||
| queryStrings.push( | ||
| `(${SPAN_ID_FIELD}:"${spanId}" OR (not ${SPAN_ID_FIELD}:* AND "${spanId}"))` | ||
| ); | ||
| } | ||
|
|
||
| return { | ||
| language: 'kuery', | ||
| query: queryStrings.join(' AND '), | ||
| }; | ||
| }, [traceId, spanId, transactionId]); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.