Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ export const GEN_AI_SETTINGS_DEFAULT_AI_CONNECTOR_DEFAULT_ONLY =
export const AI_ASSISTANT_PREFERRED_AI_ASSISTANT_TYPE = 'aiAssistant:preferredAIAssistantType';
export const AI_ANONYMIZATION_SETTINGS = 'ai:anonymizationSettings';
export const OBSERVABILITY_SEARCH_EXCLUDED_DATA_TIERS = 'observability:searchExcludedDataTiers';
export const OBSERVABILITY_ENABLE_STREAMS_UI = 'observability:enableStreamsUI';
export const OBSERVABILITY_STREAMS_ENABLE_SIGNIFICANT_EVENTS =
'observability:streamsEnableSignificantEvents';
export const OBSERVABILITY_STREAMS_ENABLE_GROUP_STREAMS = 'observability:streamsEnableGroupStreams';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ export const OBSERVABILITY_PROJECT_SETTINGS = [
settings.OBSERVABILITY_APM_ENABLE_SERVICE_INVENTORY_TABLE_SEARCH_BAR,
settings.OBSERVABILITY_LOGS_SHARED_NEW_LOGS_OVERVIEW_ID,
settings.OBSERVABILITY_LOGS_DATA_ACCESS_LOG_SOURCES_ID,
settings.OBSERVABILITY_ENABLE_STREAMS_UI,
settings.OBSERVABILITY_ENABLE_DIAGNOSTIC_MODE,
settings.OBSERVABILITY_STREAMS_ENABLE_GROUP_STREAMS,
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -672,12 +672,6 @@ export const stackManagementSchema: MakeSchemaFrom<UsageStats> = {
description: 'Enable the new logs overview component.',
},
},
'observability:enableStreamsUI': {
type: 'boolean',
_meta: {
description: 'Enable Streams UI.',
},
},
'observability:streamsEnableSignificantEvents': {
type: 'boolean',
_meta: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,6 @@ export interface UsageStats {
'securitySolution:excludedDataTiersForRuleExecution': string[];
'securitySolution:maxUnassociatedNotes': number;
'observability:searchExcludedDataTiers': string[];
'observability:enableStreamsUI': boolean;
'observability:enableDiagnosticMode': boolean;
'observability:streamsEnableSignificantEvents': boolean;
'genAiSettings:defaultAIConnector': string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11048,12 +11048,6 @@
"description": "Enable the new logs overview component."
}
},
"observability:enableStreamsUI": {
"type": "boolean",
"_meta": {
"description": "Enable Streams UI."
}
},
"observability:streamsEnableSignificantEvents": {
"type": "boolean",
"_meta": {
Expand Down
42 changes: 18 additions & 24 deletions x-pack/platform/plugins/shared/streams/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,16 @@
* 2.0.
*/

import type { CoreSetup, CoreStart, PluginInitializerContext } from '@kbn/core/public';
import type {
ApplicationStart,
CoreSetup,
CoreStart,
PluginInitializerContext,
} from '@kbn/core/public';
import type { Logger } from '@kbn/logging';
import { OBSERVABILITY_ENABLE_STREAMS_UI } from '@kbn/management-settings-ids';
import { createRepositoryClient } from '@kbn/server-route-repository-client';
import type { Observable } from 'rxjs';
import { of, from, shareReplay, startWith } from 'rxjs';
import { of } from 'rxjs';
import { once } from 'lodash';
import type { StreamsPublicConfig } from '../common/config';
import type {
Expand Down Expand Up @@ -42,7 +46,7 @@ export class Plugin implements StreamsPluginClass {
start(core: CoreStart, pluginsStart: StreamsPluginStartDependencies): StreamsPluginStart {
return {
streamsRepositoryClient: this.repositoryClient,
status$: createStreamsStatusObservable(core, this.repositoryClient, this.logger),
status$: createStreamsStatusObservable(pluginsStart, core.application),
config$: of(this.config),
};
}
Expand All @@ -52,38 +56,28 @@ export class Plugin implements StreamsPluginClass {

const ENABLED_STATUS: StreamsStatus = { status: 'enabled' };
const DISABLED_STATUS: StreamsStatus = { status: 'disabled' };
const UNKNOWN_STATUS: StreamsStatus = { status: 'unknown' };

const createStreamsStatusObservable = once(
(
core: CoreStart,
repositoryClient: StreamsRepositoryClient,
logger: Logger
deps: StreamsPluginSetupDependencies | StreamsPluginStartDependencies,
application: ApplicationStart
): Observable<StreamsStatus> => {
const { application, uiSettings } = core;
const hasCapabilities = application.capabilities?.streams?.show;
const isUIEnabled = uiSettings.get(OBSERVABILITY_ENABLE_STREAMS_UI);
const isServerless = deps.cloud?.isServerlessEnabled;
const isObservability = deps.cloud?.serverless.projectType === 'observability';

if (!hasCapabilities) {
return of(DISABLED_STATUS);
}

if (isUIEnabled) {
if (!isServerless) {
return of(ENABLED_STATUS);
}

if (isServerless && isObservability) {
return of(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));
return of(DISABLED_STATUS);
}
);
26 changes: 1 addition & 25 deletions x-pack/platform/plugins/shared/streams/server/feature_flags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,14 @@ import { schema } from '@kbn/config-schema';
import type { CoreSetup, Logger } from '@kbn/core/server';
import { i18n } from '@kbn/i18n';
import {
OBSERVABILITY_ENABLE_STREAMS_UI,
OBSERVABILITY_STREAMS_ENABLE_SIGNIFICANT_EVENTS,
OBSERVABILITY_STREAMS_ENABLE_GROUP_STREAMS,
} from '@kbn/management-settings-ids';
import type { StreamsPluginSetupDependencies, StreamsPluginStartDependencies } from './types';
import type { StreamsPluginStartDependencies } from './types';
import { STREAMS_TIERED_SIGNIFICANT_EVENT_FEATURE } from '../common';

export function registerFeatureFlags(
core: CoreSetup<StreamsPluginStartDependencies>,
plugins: StreamsPluginSetupDependencies,
logger: Logger
) {
core.pricing
Expand Down Expand Up @@ -48,28 +46,6 @@ export function registerFeatureFlags(
logger.error(`Failed to register significant events ui settings: ${error}`);
});

const isObservabilityServerless =
plugins.cloud?.isServerlessEnabled && plugins.cloud?.serverless.projectType === 'observability';

core.uiSettings.register({
[OBSERVABILITY_ENABLE_STREAMS_UI]: {
category: ['observability'],
name: 'Streams UI',
value: isObservabilityServerless,
description: i18n.translate('xpack.streams.enableStreamsUIDescription', {
defaultMessage: 'Enable the {streamsLink}.',
values: {
streamsLink: `<a href="https://www.elastic.co/docs/solutions/observability/logs/streams/streams">Streams UI</href>`,
},
}),
type: 'boolean',
schema: schema.boolean(),
requiresPageReload: true,
solutionViews: ['classic', 'oblt'],
technicalPreview: true,
},
});

core.uiSettings.register({
[OBSERVABILITY_STREAMS_ENABLE_GROUP_STREAMS]: {
category: ['observability'],
Expand Down
2 changes: 1 addition & 1 deletion x-pack/platform/plugins/shared/streams/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ export class StreamsPlugin
runDevModeChecks: this.isDev,
});

registerFeatureFlags(core, plugins, this.logger);
registerFeatureFlags(core, this.logger);

if (plugins.globalSearch) {
plugins.globalSearch.registerResultProvider(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
*/

import {
OBSERVABILITY_ENABLE_STREAMS_UI,
OBSERVABILITY_STREAMS_ENABLE_GROUP_STREAMS,
OBSERVABILITY_STREAMS_ENABLE_SIGNIFICANT_EVENTS,
} from '@kbn/management-settings-ids';
Expand Down Expand Up @@ -52,8 +51,6 @@ export function useStreamsPrivileges(): StreamsPrivileges {

const license = useObservable(licensing.license$);

const uiEnabled = uiSettings.get<boolean>(OBSERVABILITY_ENABLE_STREAMS_UI);

const groupStreamsEnabled = uiSettings.get(OBSERVABILITY_STREAMS_ENABLE_GROUP_STREAMS, false);

const significantEventsEnabled = uiSettings.get<boolean>(
Expand All @@ -72,7 +69,7 @@ export function useStreamsPrivileges(): StreamsPrivileges {
},
features: {
ui: {
enabled: uiEnabled,
enabled: true,
},
significantEvents: license && {
enabled: significantEventsEnabled,
Expand Down