-
Notifications
You must be signed in to change notification settings - Fork 8.6k
[RCA] AI-assisted root cause analysis #197200
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
65 commits
Select commit
Hold shift + click to select a range
480a53b
[RCA] AI-assisted root cause analysis
dgieselaar 7c4d7e0
Add log pattern table
dgieselaar d5a55e8
Change points
dgieselaar 64d6557
Simplify SLO client
dgieselaar 1158a39
[CI] Auto-commit changed files from 'node scripts/build_plugin_list_d…
kibanamachine 113776f
[CI] Auto-commit changed files from 'node scripts/notice'
kibanamachine 9db7634
[CI] Auto-commit changed files from 'node scripts/yarn_deduplicate'
kibanamachine b34e36e
Merge branch 'llm-rca-kubecon' of github.com:dgieselaar/kibana into l…
dgieselaar 35438eb
Fix quick checks
dgieselaar 8b26417
Merge branch 'main' of github.com:elastic/kibana into llm-rca-kubecon
dgieselaar 9ba32f4
Include alerts without grouping fields
dgieselaar 04e2e96
Fix test config
maryam-saeidi f06779c
Merge branch 'main' into llm-rca-kubecon
maryam-saeidi ed0a10f
Fix test config
maryam-saeidi 888a8e4
lock timerange to be investigation time range
benakansara fd6d246
Improve process
dgieselaar ff93d69
Merge branch 'llm-rca-kubecon' of github.com:dgieselaar/kibana into l…
dgieselaar 44bc6d5
v2.1
dgieselaar 924d2c3
Remove console.logging
dgieselaar f147223
Make sure to log all events after finishing
dgieselaar e07334b
Partition related entity extraction
dgieselaar 96d938a
Order by score asc (lower is better)
dgieselaar f680c97
Include documents from knowledge base
dgieselaar 65ec3bd
Merge branch 'main' of github.com:elastic/kibana into llm-rca-kubecon
dgieselaar a9df5d7
Move to separate package
dgieselaar a6ea3a3
Title for observations & some UI cleanup
dgieselaar 64ab54d
Update CODEOWNERS
dgieselaar d58a50d
Fix references
dgieselaar 69f75a3
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine 88c36cf
Fix lint errors
dgieselaar 515bf33
Fix type errors
dgieselaar d5641b2
Merge branch 'llm-rca-kubecon' of github.com:dgieselaar/kibana into l…
dgieselaar 4269121
[CI] Auto-commit changed files from 'node scripts/yarn_deduplicate'
kibanamachine 029453a
Remove unused var, replace scan() with toArray()/map()
dgieselaar d2c7efc
Merge branch 'llm-rca-kubecon' of github.com:dgieselaar/kibana into l…
dgieselaar 286e54c
Complete in background
dgieselaar 325fc42
Merge branch 'main' of github.com:elastic/kibana into llm-rca-kubecon
dgieselaar 43d7d43
Fix conflicts
dgieselaar c3b37e3
Merge branch 'main' of github.com:elastic/kibana into llm-rca-kubecon
dgieselaar a9eeaf7
Merge branch 'main' of github.com:elastic/kibana into llm-rca-kubecon
dgieselaar 4372088
Type checks
dgieselaar cc7254a
Tests for observable_into_event_source_stream
dgieselaar 6c99e3d
Update tests
dgieselaar 609cf95
[CI] Auto-commit changed files from 'node scripts/capture_oas_snapsho…
kibanamachine 5d9b9c0
Merge branch 'main' of github.com:elastic/kibana into llm-rca-kubecon
dgieselaar 8fac3c2
Remove unused translations
dgieselaar d0c5f6e
Merge branch 'llm-rca-kubecon' of github.com:dgieselaar/kibana into l…
dgieselaar ed0518e
Clean up route handler
dgieselaar b76a428
Remove unused file
dgieselaar 68343a9
Use random_sampler
dgieselaar 9bd05c2
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine 5c91822
Fix references
dgieselaar 1f7a705
Merge branch 'llm-rca-kubecon' of github.com:dgieselaar/kibana into l…
dgieselaar 7bbfd78
Merge branch 'main' of github.com:elastic/kibana into llm-rca-kubecon
dgieselaar f3c9af2
Import categorizationAnalyzer directly
dgieselaar 5dfa41f
Don't export categorizationAnalyzer
dgieselaar 68cb38d
Add llmTasks to dependencies
dgieselaar b953c20
Merge branch 'main' of github.com:elastic/kibana into llm-rca-kubecon
dgieselaar 3f751ea
Fix tests
dgieselaar cbdb129
Reset limits for aiops
dgieselaar bd80cd3
Merge branch 'main' of github.com:elastic/kibana into llm-rca-kubecon
dgieselaar ba5d761
Delete unused files
dgieselaar b06d3f5
Re-skip tests in Obs AI Assistant
dgieselaar 62252d0
Add tests for retry.onValidationError
dgieselaar 75068c9
Clarify complexity
dgieselaar 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
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
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
198 changes: 198 additions & 0 deletions
198
packages/kbn-sse-utils-server/src/observable_into_event_source_stream.test.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,198 @@ | ||
| /* | ||
| * 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 { Logger } from '@kbn/logging'; | ||
| import { observableIntoEventSourceStream } from './observable_into_event_source_stream'; | ||
| import { PassThrough } from 'node:stream'; | ||
| import { Subject } from 'rxjs'; | ||
| import { ServerSentEvent, ServerSentEventType } from '@kbn/sse-utils/src/events'; | ||
| import { | ||
| ServerSentEventErrorCode, | ||
| createSSEInternalError, | ||
| createSSERequestError, | ||
| } from '@kbn/sse-utils/src/errors'; | ||
|
|
||
| describe('observableIntoEventSourceStream', () => { | ||
| let logger: jest.Mocked<Logger>; | ||
|
|
||
| let controller: AbortController; | ||
|
|
||
| let stream: PassThrough; | ||
| let source$: Subject<ServerSentEvent>; | ||
|
|
||
| let data: string[]; | ||
|
|
||
| beforeEach(() => { | ||
| jest.useFakeTimers(); | ||
| logger = { | ||
| debug: jest.fn(), | ||
| error: jest.fn(), | ||
| } as unknown as jest.Mocked<Logger>; | ||
|
|
||
| controller = new AbortController(); | ||
| source$ = new Subject(); | ||
| data = []; | ||
|
|
||
| stream = observableIntoEventSourceStream(source$, { logger, signal: controller.signal }); | ||
| stream.on('data', (chunk) => { | ||
| data.push(chunk.toString()); | ||
| }); | ||
| }); | ||
|
|
||
| afterEach(() => { | ||
| jest.clearAllTimers(); | ||
| }); | ||
|
|
||
| it('writes events into the stream in SSE format', () => { | ||
| source$.next({ type: ServerSentEventType.data, data: { foo: 'bar' } }); | ||
| source$.complete(); | ||
|
|
||
| jest.runAllTimers(); | ||
|
|
||
| expect(data).toEqual(['event: data\ndata: {"data":{"foo":"bar"}}\n\n']); | ||
| }); | ||
|
|
||
| it('handles SSE errors', () => { | ||
| const sseError = createSSEInternalError('Invalid input'); | ||
|
|
||
| source$.error(sseError); | ||
|
|
||
| jest.runAllTimers(); | ||
|
|
||
| expect(logger.error).toHaveBeenCalledWith(sseError); | ||
| expect(logger.debug).toHaveBeenCalled(); | ||
| const debugFn = logger.debug.mock.calls[0][0] as () => string; | ||
| const loggedError = JSON.parse(debugFn()); | ||
| expect(loggedError).toEqual({ | ||
| type: 'error', | ||
| error: { | ||
| code: ServerSentEventErrorCode.internalError, | ||
| message: 'Invalid input', | ||
| meta: {}, | ||
| }, | ||
| }); | ||
|
|
||
| expect(data).toEqual([ | ||
| `event: error\ndata: ${JSON.stringify({ | ||
| error: { | ||
| code: ServerSentEventErrorCode.internalError, | ||
| message: 'Invalid input', | ||
| meta: {}, | ||
| }, | ||
| })}\n\n`, | ||
| ]); | ||
| }); | ||
|
|
||
| it('handles SSE errors with metadata', () => { | ||
| const sseError = createSSERequestError('Invalid request', 400); | ||
|
|
||
| source$.error(sseError); | ||
|
|
||
| jest.runAllTimers(); | ||
|
|
||
| expect(logger.error).toHaveBeenCalledWith(sseError); | ||
| expect(logger.debug).toHaveBeenCalled(); | ||
| const debugFn = logger.debug.mock.calls[0][0] as () => string; | ||
| const loggedError = JSON.parse(debugFn()); | ||
| expect(loggedError).toEqual({ | ||
| type: 'error', | ||
| error: { | ||
| code: ServerSentEventErrorCode.requestError, | ||
| message: 'Invalid request', | ||
| meta: { | ||
| status: 400, | ||
| }, | ||
| }, | ||
| }); | ||
|
|
||
| expect(data).toEqual([ | ||
| `event: error\ndata: ${JSON.stringify({ | ||
| error: { | ||
| code: ServerSentEventErrorCode.requestError, | ||
| message: 'Invalid request', | ||
| meta: { | ||
| status: 400, | ||
| }, | ||
| }, | ||
| })}\n\n`, | ||
| ]); | ||
| }); | ||
|
|
||
| it('handles non-SSE errors', () => { | ||
| const error = new Error('Non-SSE Error'); | ||
|
|
||
| source$.error(error); | ||
|
|
||
| jest.runAllTimers(); | ||
|
|
||
| expect(logger.error).toHaveBeenCalledWith(error); | ||
| expect(data).toEqual([ | ||
| `event: error\ndata: ${JSON.stringify({ | ||
| error: { | ||
| code: ServerSentEventErrorCode.internalError, | ||
| message: 'Non-SSE Error', | ||
| }, | ||
| })}\n\n`, | ||
| ]); | ||
| }); | ||
|
|
||
| it('should send keep-alive comments every 10 seconds', () => { | ||
| jest.advanceTimersByTime(10000); | ||
| expect(data).toContain(': keep-alive'); | ||
|
|
||
| jest.advanceTimersByTime(10000); | ||
| expect(data.filter((d) => d === ': keep-alive')).toHaveLength(2); | ||
| }); | ||
|
|
||
| describe('without fake timers', () => { | ||
| beforeEach(() => { | ||
| jest.useFakeTimers({ doNotFake: ['nextTick'] }); | ||
| }); | ||
|
|
||
| it('should end the stream when the observable completes', async () => { | ||
| jest.useFakeTimers({ doNotFake: ['nextTick'] }); | ||
|
|
||
| const endSpy = jest.fn(); | ||
| stream.on('end', endSpy); | ||
|
|
||
| source$.complete(); | ||
|
|
||
| await new Promise((resolve) => process.nextTick(resolve)); | ||
|
|
||
| expect(endSpy).toHaveBeenCalled(); | ||
| }); | ||
|
|
||
| it('should end stream when signal is aborted', async () => { | ||
| const endSpy = jest.fn(); | ||
| stream.on('end', endSpy); | ||
|
|
||
| // Emit some data | ||
| source$.next({ type: ServerSentEventType.data, data: { initial: 'data' } }); | ||
|
|
||
| // Abort the signal | ||
| controller.abort(); | ||
|
|
||
| // Emit more data after abort | ||
| source$.next({ type: ServerSentEventType.data, data: { after: 'abort' } }); | ||
|
|
||
| await new Promise((resolve) => process.nextTick(resolve)); | ||
|
|
||
| expect(endSpy).toHaveBeenCalled(); | ||
|
|
||
| // Data after abort should not be received | ||
| expect(data).toEqual([ | ||
| `event: data\ndata: ${JSON.stringify({ data: { initial: 'data' } })}\n\n`, | ||
| ]); | ||
| }); | ||
|
|
||
| afterEach(() => { | ||
| jest.useFakeTimers(); | ||
| }); | ||
| }); | ||
| }); |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I'd love it if we could start highlighting that
bodyis deprecated:In any case, I think this is a good change... as we'll be able to progressively migrate consumers of each type.