forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Inventory] Inventory plugin (elastic#191798)
## Description This PR adds an inventory plugin, which renders an inventory UI. Currently only data streams are rendered. This is part of the LogsAI initiative - basically we need a UI for tasks like structuring data, extracting entities, listing the results etc. This is mostly POC-level stuff. Eventually some of this code might be handed over to ECO but let's cross that bridge when we get to it. ## Notes for reviewers: @elastic/appex-ai-infra @elastic/security-generative-ai: added a `truncateList` utility function that takes the first n elements of an array and appends a `{l-n} more` string value if there are more values than n. Really simple but I expect will also be very often used because we cannot send a huge amount of items to the LLM. @elastic/kibana-core @elastic/kibana-operations: just boiler plate stuff for adding a new plugin (and thank you for enabling us to run `quick_checks` locally! @elastic/obs-knowledge-team: added support for streaming using an Observable. @elastic/obs-ux-management-team: added links to the Inventory UI in the Observability plugin @elastic/obs-entities: I've added an entity manager client to be able to fetch entity definitions on the server. Maybe there's a better way? LMK. @elastic/obs-ux-logs-team: added a deeplink to the Inventory UI. I've also moved CODEOWNERS for this package to @elastic/obs-ux-management-team as they own the Observability plugin where this is mostly used. --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
- Loading branch information
1 parent
4d5c253
commit 98aa1ab
Showing
110 changed files
with
3,070 additions
and
877 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
This file contains 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 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 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 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 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 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 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,5 +1,5 @@ | ||
{ | ||
"type": "shared-common", | ||
"id": "@kbn/deeplinks-observability", | ||
"owner": "@elastic/obs-ux-logs-team" | ||
"owner": "@elastic/obs-ux-management-team" | ||
} |
This file contains 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 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 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
76 changes: 76 additions & 0 deletions
76
packages/kbn-server-route-repository-client/src/create_observable_from_http_response.ts
This file contains 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,76 @@ | ||
/* | ||
* 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 { createParser } from 'eventsource-parser'; | ||
import { Observable, throwError } from 'rxjs'; | ||
|
||
export interface StreamedHttpResponse { | ||
response?: { body: ReadableStream<Uint8Array> | null | undefined }; | ||
} | ||
|
||
class NoReadableStreamError extends Error { | ||
constructor() { | ||
super(`No readable stream found in response`); | ||
} | ||
} | ||
|
||
export function isNoReadableStreamError(error: any): error is NoReadableStreamError { | ||
return error instanceof NoReadableStreamError; | ||
} | ||
|
||
export function createObservableFromHttpResponse( | ||
response: StreamedHttpResponse | ||
): Observable<string> { | ||
const rawResponse = response.response; | ||
|
||
const body = rawResponse?.body; | ||
if (!body) { | ||
return throwError(() => { | ||
throw new NoReadableStreamError(); | ||
}); | ||
} | ||
|
||
return new Observable<string>((subscriber) => { | ||
const parser = createParser((event) => { | ||
if (event.type === 'event') { | ||
subscriber.next(event.data); | ||
} | ||
}); | ||
|
||
const readStream = async () => { | ||
const reader = body.getReader(); | ||
const decoder = new TextDecoder(); | ||
|
||
// Function to process each chunk | ||
const processChunk = ({ | ||
done, | ||
value, | ||
}: ReadableStreamReadResult<Uint8Array>): Promise<void> => { | ||
if (done) { | ||
return Promise.resolve(); | ||
} | ||
|
||
parser.feed(decoder.decode(value, { stream: true })); | ||
|
||
return reader.read().then(processChunk); | ||
}; | ||
|
||
// Start reading the stream | ||
return reader.read().then(processChunk); | ||
}; | ||
|
||
readStream() | ||
.then(() => { | ||
subscriber.complete(); | ||
}) | ||
.catch((error) => { | ||
subscriber.error(error); | ||
}); | ||
}); | ||
} |
This file contains 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
14 changes: 14 additions & 0 deletions
14
packages/kbn-server-route-repository-client/src/is_request_aborted_error.ts
This file contains 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,14 @@ | ||
/* | ||
* 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 { get } from 'lodash'; | ||
|
||
export function isRequestAbortedError(error: unknown): error is Error { | ||
return get(error, 'name') === 'AbortError'; | ||
} |
This file contains 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.