-
Notifications
You must be signed in to change notification settings - Fork 8.6k
[Streams] Use TS instead of FROM for TSDB mode in Discover links #250554
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
11 commits
Select commit
Hold shift + click to select a range
9dfbb72
[Streams] Use TS instead of FROM for TSDB mode in Discover links
flash1293 222b14b
[Streams] Use data_stream.index_mode from listing API for TSDB mode
flash1293 2b74894
[Streams] Use index_mode from API response instead of useStreamTSDBMo…
flash1293 ef7ebc5
Update tsdb_discover_links.spec.ts
flash1293 3c118eb
Remove redundant isTSDBMode prop from DiscoverBadgeButton
flash1293 66bc64e
Changes from yarn openapi:bundle
kibanamachine 990a70d
Fix TypeScript import error for Streams
flash1293 9addbaf
Fix linting errors in TSDB Discover links test
flash1293 c0d16b0
Merge branch 'main' into ralph/issue-1
flash1293 4dca2c9
Address review comments: type assertion, dead code, and centralize ut…
flash1293 07230a1
Inline isTSDBMode into getDiscoverEsqlQuery
flash1293 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
63 changes: 63 additions & 0 deletions
63
x-pack/platform/packages/shared/kbn-streams-schema/src/helpers/get_discover_esql_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,63 @@ | ||
| /* | ||
| * 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; you may not use this file except in compliance with the Elastic License | ||
| * 2.0. | ||
| */ | ||
|
|
||
| import type { IngestStreamIndexMode } from '../models/ingest/base'; | ||
| import type { Streams } from '../models/streams'; | ||
| import { getIndexPatternsForStream } from './hierarchy_helpers'; | ||
|
|
||
| export interface GetDiscoverEsqlQueryOptions { | ||
| /** | ||
| * The stream definition to generate the query for | ||
| */ | ||
| definition: Streams.all.Definition; | ||
| /** | ||
| * The index mode of the stream (from API response) | ||
| */ | ||
| indexMode?: IngestStreamIndexMode; | ||
| /** | ||
| * Whether to include METADATA _source (typically for wired streams) | ||
| */ | ||
| includeMetadata?: boolean; | ||
| } | ||
|
|
||
| /** | ||
| * Generates a base ES|QL query for Discover from a stream definition. | ||
| * | ||
| * Uses 'TS' source command for TSDB mode streams, 'FROM' otherwise. | ||
| * Optionally includes METADATA _source for wired streams. | ||
| * | ||
| * @param options - Configuration options for query generation | ||
| * @returns The ES|QL query string, or undefined if index patterns cannot be determined | ||
| * | ||
| * @example | ||
| * // Basic usage | ||
| * getDiscoverEsqlQuery({ definition, indexMode }) | ||
| * // Returns: "FROM logs,logs.*" | ||
| * | ||
| * @example | ||
| * // With TSDB mode | ||
| * getDiscoverEsqlQuery({ definition, indexMode: 'time_series' }) | ||
| * // Returns: "TS logs,logs.*" | ||
| * | ||
| * @example | ||
| * // With metadata for wired streams | ||
| * getDiscoverEsqlQuery({ definition, indexMode, includeMetadata: true }) | ||
| * // Returns: "FROM logs,logs.* METADATA _source" | ||
| */ | ||
| export function getDiscoverEsqlQuery(options: GetDiscoverEsqlQueryOptions): string | undefined { | ||
| const { definition, indexMode, includeMetadata = false } = options; | ||
|
|
||
| const indexPatterns = getIndexPatternsForStream(definition); | ||
| if (!indexPatterns) { | ||
| return undefined; | ||
| } | ||
|
|
||
| const sourceCommand = indexMode === 'time_series' ? 'TS' : 'FROM'; | ||
| const metadataSuffix = includeMetadata ? ' METADATA _source' : ''; | ||
|
|
||
| return `${sourceCommand} ${indexPatterns.join(', ')}${metadataSuffix}`; | ||
| } |
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
Oops, something went wrong.
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.