mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
# Backport This will backport the following commits from `main` to `8.x`: - [🌊 Enable streams in the UI for serverless observability (#215533)](https://github.com/elastic/kibana/pull/215533) <!--- Backport version: 9.6.6 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Joe Reuter","email":"johannes.reuter@elastic.co"},"sourceCommit":{"committedDate":"2025-04-11T16:53:10Z","message":"🌊 Enable streams in the UI for serverless observability (#215533)\n\n# Only merge this if you want streams to go public\n\nThis PR changes the logic for the client side \"status$\" observable for\nstreams to look for whether it's on serverless in an observability\nproject (because this is where we want to launch first).\n\nLater on, this logic can be adjusted as necessary for on-prem launches\netc.\n\nTo make this work locally, you need to add\n`xpack.cloud.serverless.project_id: \"project_id\"` to your\n`config/kibana.dev.yml`\n\nIt still shows the streams app if wired streams are enabled (basically\nit keeps the old behavior plus always defaulting to `enabled` if it's an\nobservability serverless project.\n\n---------\n\nCo-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>","sha":"77ff3c2f62b37b5590d06084f42d566907a70522","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","backport:version","Feature:Streams","v9.1.0","v8.19.0"],"title":"🌊 Enable streams in the UI for serverless observability","number":215533,"url":"https://github.com/elastic/kibana/pull/215533","mergeCommit":{"message":"🌊 Enable streams in the UI for serverless observability (#215533)\n\n# Only merge this if you want streams to go public\n\nThis PR changes the logic for the client side \"status$\" observable for\nstreams to look for whether it's on serverless in an observability\nproject (because this is where we want to launch first).\n\nLater on, this logic can be adjusted as necessary for on-prem launches\netc.\n\nTo make this work locally, you need to add\n`xpack.cloud.serverless.project_id: \"project_id\"` to your\n`config/kibana.dev.yml`\n\nIt still shows the streams app if wired streams are enabled (basically\nit keeps the old behavior plus always defaulting to `enabled` if it's an\nobservability serverless project.\n\n---------\n\nCo-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>","sha":"77ff3c2f62b37b5590d06084f42d566907a70522"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/215533","number":215533,"mergeCommit":{"message":"🌊 Enable streams in the UI for serverless observability (#215533)\n\n# Only merge this if you want streams to go public\n\nThis PR changes the logic for the client side \"status$\" observable for\nstreams to look for whether it's on serverless in an observability\nproject (because this is where we want to launch first).\n\nLater on, this logic can be adjusted as necessary for on-prem launches\netc.\n\nTo make this work locally, you need to add\n`xpack.cloud.serverless.project_id: \"project_id\"` to your\n`config/kibana.dev.yml`\n\nIt still shows the streams app if wired streams are enabled (basically\nit keeps the old behavior plus always defaulting to `enabled` if it's an\nobservability serverless project.\n\n---------\n\nCo-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>","sha":"77ff3c2f62b37b5590d06084f42d566907a70522"}},{"branch":"8.x","label":"v8.19.0","branchLabelMappingKey":"^v8.19.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> Co-authored-by: Joe Reuter <johannes.reuter@elastic.co>
This commit is contained in:
parent
df83efc556
commit
c6e3428a6d
3 changed files with 68 additions and 27 deletions
|
@ -9,10 +9,17 @@ import { CoreSetup, CoreStart, PluginInitializerContext } from '@kbn/core/public
|
|||
import { Logger } from '@kbn/logging';
|
||||
|
||||
import { createRepositoryClient } from '@kbn/server-route-repository-client';
|
||||
import { from, shareReplay, startWith } from 'rxjs';
|
||||
import { Observable, from, shareReplay, startWith } from 'rxjs';
|
||||
import { once } from 'lodash';
|
||||
import type { StreamsPublicConfig } from '../common/config';
|
||||
import { StreamsPluginClass, StreamsPluginSetup, StreamsPluginStart } from './types';
|
||||
import {
|
||||
StreamsPluginClass,
|
||||
StreamsPluginSetup,
|
||||
StreamsPluginSetupDependencies,
|
||||
StreamsPluginStart,
|
||||
StreamsPluginStartDependencies,
|
||||
StreamsStatus,
|
||||
} from './types';
|
||||
import { StreamsRepositoryClient } from './api';
|
||||
|
||||
export class Plugin implements StreamsPluginClass {
|
||||
|
@ -26,37 +33,52 @@ export class Plugin implements StreamsPluginClass {
|
|||
this.logger = context.logger.get();
|
||||
}
|
||||
|
||||
setup(core: CoreSetup<{}>, pluginSetup: {}): StreamsPluginSetup {
|
||||
setup(core: CoreSetup, pluginSetup: StreamsPluginSetupDependencies): StreamsPluginSetup {
|
||||
this.repositoryClient = createRepositoryClient(core);
|
||||
return {
|
||||
status$: createStatusObservable(this.logger, this.repositoryClient),
|
||||
status$: createStreamsStatusObservable(pluginSetup, this.repositoryClient, this.logger),
|
||||
};
|
||||
}
|
||||
|
||||
start(core: CoreStart, pluginsStart: {}): StreamsPluginStart {
|
||||
start(core: CoreStart, pluginsStart: StreamsPluginStartDependencies): StreamsPluginStart {
|
||||
return {
|
||||
streamsRepositoryClient: this.repositoryClient,
|
||||
status$: createStatusObservable(this.logger, this.repositoryClient),
|
||||
status$: createStreamsStatusObservable(pluginsStart, this.repositoryClient, this.logger),
|
||||
};
|
||||
}
|
||||
|
||||
stop() {}
|
||||
}
|
||||
|
||||
const createStatusObservable = once((logger: Logger, repositoryClient: StreamsRepositoryClient) => {
|
||||
return from(
|
||||
repositoryClient
|
||||
.fetch('GET /api/streams/_status', {
|
||||
signal: new AbortController().signal,
|
||||
})
|
||||
.then(
|
||||
(response) => ({
|
||||
status: response.enabled ? ('enabled' as const) : ('disabled' as const),
|
||||
}),
|
||||
(error) => {
|
||||
logger.error(error);
|
||||
return { status: 'unknown' as const };
|
||||
}
|
||||
)
|
||||
).pipe(startWith({ status: 'unknown' as const }), shareReplay(1));
|
||||
});
|
||||
const ENABLED_STATUS: StreamsStatus = { status: 'enabled' };
|
||||
const DISABLED_STATUS: StreamsStatus = { status: 'disabled' };
|
||||
const UNKNOWN_STATUS: StreamsStatus = { status: 'unknown' };
|
||||
|
||||
const createStreamsStatusObservable = once(
|
||||
(
|
||||
deps: StreamsPluginSetupDependencies | StreamsPluginStartDependencies,
|
||||
repositoryClient: StreamsRepositoryClient,
|
||||
logger: Logger
|
||||
): Observable<StreamsStatus> => {
|
||||
const isObservabilityServerless =
|
||||
deps.cloud?.isServerlessEnabled && deps.cloud?.serverless.projectType === 'observability';
|
||||
|
||||
if (isObservabilityServerless) {
|
||||
return from([ENABLED_STATUS]);
|
||||
}
|
||||
|
||||
return from(
|
||||
repositoryClient
|
||||
.fetch('GET /api/streams/_status', {
|
||||
signal: new AbortController().signal,
|
||||
})
|
||||
.then(
|
||||
(response) => (response.enabled ? ENABLED_STATUS : DISABLED_STATUS),
|
||||
(error) => {
|
||||
logger.error(error);
|
||||
return UNKNOWN_STATUS;
|
||||
}
|
||||
)
|
||||
).pipe(startWith(UNKNOWN_STATUS), shareReplay(1));
|
||||
}
|
||||
);
|
||||
|
|
|
@ -7,15 +7,33 @@
|
|||
|
||||
import type { Plugin as PluginClass } from '@kbn/core/public';
|
||||
import { Observable } from 'rxjs';
|
||||
import { CloudSetup, CloudStart } from '@kbn/cloud-plugin/public';
|
||||
import type { StreamsRepositoryClient } from './api';
|
||||
|
||||
export interface StreamsStatus {
|
||||
status: 'unknown' | 'enabled' | 'disabled';
|
||||
}
|
||||
|
||||
export interface StreamsPluginSetup {
|
||||
status$: Observable<{ status: 'unknown' | 'enabled' | 'disabled' }>;
|
||||
status$: Observable<StreamsStatus>;
|
||||
}
|
||||
|
||||
export interface StreamsPluginStart {
|
||||
streamsRepositoryClient: StreamsRepositoryClient;
|
||||
status$: Observable<{ status: 'unknown' | 'enabled' | 'disabled' }>;
|
||||
status$: Observable<StreamsStatus>;
|
||||
}
|
||||
|
||||
export type StreamsPluginClass = PluginClass<StreamsPluginSetup, StreamsPluginStart, {}, {}>;
|
||||
export interface StreamsPluginSetupDependencies {
|
||||
cloud?: CloudSetup;
|
||||
}
|
||||
|
||||
export interface StreamsPluginStartDependencies {
|
||||
cloud?: CloudStart;
|
||||
}
|
||||
|
||||
export type StreamsPluginClass = PluginClass<
|
||||
StreamsPluginSetup,
|
||||
StreamsPluginStart,
|
||||
StreamsPluginSetupDependencies,
|
||||
StreamsPluginStartDependencies
|
||||
>;
|
||||
|
|
|
@ -43,6 +43,7 @@
|
|||
"@kbn/utils",
|
||||
"@kbn/core-saved-objects-server-internal",
|
||||
"@kbn/core-analytics-server",
|
||||
"@kbn/es-types",
|
||||
"@kbn/cloud-plugin",
|
||||
"@kbn/es-types"
|
||||
]
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue