Skip to content
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ export const OBSERVABILITY_AI_ASSISTANT_SIMULATED_FUNCTION_CALLING =
export const OBSERVABILITY_AI_ASSISTANT_SEARCH_CONNECTOR_INDEX_PATTERN =
'observability:aiAssistantSearchConnectorIndexPattern';
export const OBSERVABILITY_SEARCH_EXCLUDED_DATA_TIERS = 'observability:searchExcludedDataTiers';
export const OBSERVABILITY_ENABLE_STREAMS_UI = 'observability:enableStreamsUI';

// Reporting settings
export const XPACK_REPORTING_CUSTOM_PDF_LOGO_ID = 'xpackReporting:customPdfLogo';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@ export const OBSERVABILITY_PROJECT_SETTINGS = [
settings.OBSERVABILITY_AI_ASSISTANT_SIMULATED_FUNCTION_CALLING,
settings.OBSERVABILITY_AI_ASSISTANT_SEARCH_CONNECTOR_INDEX_PATTERN,
settings.OBSERVABILITY_LOGS_DATA_ACCESS_LOG_SOURCES_ID,
settings.OBSERVABILITY_ENABLE_STREAMS_UI,
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Settings allow list for serverless

];
Original file line number Diff line number Diff line change
Expand Up @@ -656,4 +656,10 @@ export const stackManagementSchema: MakeSchemaFrom<UsageStats> = {
description: 'Enable the new logs overview component.',
},
},
'observability:enableStreamsUI': {
type: 'boolean',
_meta: {
description: 'Enable Streams UI.',
},
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -171,4 +171,5 @@ export interface UsageStats {
'securitySolution:excludedDataTiersForRuleExecution': string[];
'securitySolution:maxUnassociatedNotes': number;
'observability:searchExcludedDataTiers': string[];
'observability:enableStreamsUI': boolean;
}
Original file line number Diff line number Diff line change
Expand Up @@ -11537,6 +11537,12 @@
"_meta": {
"description": "Enable the new logs overview component."
}
},
"observability:enableStreamsUI": {
"type": "boolean",
"_meta": {
"description": "Enable Streams UI."
}
}
}
},
Expand Down
21 changes: 7 additions & 14 deletions x-pack/platform/plugins/shared/streams/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
* 2.0.
*/

import { ApplicationStart, CoreSetup, CoreStart, PluginInitializerContext } from '@kbn/core/public';
import { CoreSetup, CoreStart, PluginInitializerContext } from '@kbn/core/public';
import { Logger } from '@kbn/logging';

import { OBSERVABILITY_ENABLE_STREAMS_UI } from '@kbn/management-settings-ids';
import { createRepositoryClient } from '@kbn/server-route-repository-client';
import { Observable, from, shareReplay, startWith } from 'rxjs';
import { once } from 'lodash';
Expand Down Expand Up @@ -41,12 +41,7 @@ export class Plugin implements StreamsPluginClass {
start(core: CoreStart, pluginsStart: StreamsPluginStartDependencies): StreamsPluginStart {
return {
streamsRepositoryClient: this.repositoryClient,
status$: createStreamsStatusObservable(
pluginsStart,
core.application,
this.repositoryClient,
this.logger
),
status$: createStreamsStatusObservable(core, this.repositoryClient, this.logger),
};
}

Expand All @@ -59,21 +54,19 @@ const UNKNOWN_STATUS: StreamsStatus = { status: 'unknown' };

const createStreamsStatusObservable = once(
(
deps: StreamsPluginSetupDependencies | StreamsPluginStartDependencies,
application: ApplicationStart,
core: CoreStart,
repositoryClient: StreamsRepositoryClient,
logger: Logger
): Observable<StreamsStatus> => {
const isObservabilityServerless =
deps.cloud?.isServerlessEnabled && deps.cloud?.serverless.projectType === 'observability';

const { application, uiSettings } = core;
const hasCapabilities = application.capabilities?.streams?.show;
const isUIEnabled = uiSettings.get(OBSERVABILITY_ENABLE_STREAMS_UI);

if (!hasCapabilities) {
return from([DISABLED_STATUS]);
}

if (isObservabilityServerless) {
if (isUIEnabled) {
return from([ENABLED_STATUS]);
}

Expand Down
32 changes: 29 additions & 3 deletions x-pack/platform/plugins/shared/streams/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import { KibanaFeatureScope } from '@kbn/features-plugin/common';
import { i18n } from '@kbn/i18n';
import { STREAMS_RULE_TYPE_IDS } from '@kbn/rule-data-utils';
import { registerRoutes } from '@kbn/server-route-repository';
import { schema } from '@kbn/config-schema';
import { OBSERVABILITY_ENABLE_STREAMS_UI } from '@kbn/management-settings-ids';
import { StreamsConfig, configSchema, exposeToBrowserConfig } from '../common/config';
import {
STREAMS_API_PRIVILEGES,
Expand Down Expand Up @@ -63,7 +65,7 @@ export class StreamsPlugin
public logger: Logger;
public server?: StreamsServer;
private isDev: boolean;
private telemtryService = new StreamsTelemetryService();
private telemetryService = new StreamsTelemetryService();

constructor(context: PluginInitializerContext<StreamsConfig>) {
this.isDev = context.env.mode.dev;
Expand All @@ -80,7 +82,7 @@ export class StreamsPlugin
logger: this.logger,
} as StreamsServer;

this.telemtryService.setup(core.analytics);
this.telemetryService.setup(core.analytics);

const isSignificantEventsEnabled = this.config.experimental?.significantEventsEnabled === true;
const alertingFeatures = isSignificantEventsEnabled
Expand Down Expand Up @@ -157,7 +159,7 @@ export class StreamsPlugin
dependencies: {
assets: assetService,
server: this.server,
telemetry: this.telemtryService.getClient(),
telemetry: this.telemetryService.getClient(),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😌

getScopedClients: async ({
request,
}: {
Expand Down Expand Up @@ -200,6 +202,30 @@ export class StreamsPlugin
runDevModeChecks: this.isDev,
});

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: '{technicalPreviewLabel} Enable the {streamsLink}.',
values: {
technicalPreviewLabel: `<em>[${i18n.translate('xpack.streams.technicalPreviewLabel', {
defaultMessage: 'Technical Preview',
})}]</em>`,
streamsLink: `<a href="https://www.elastic.co/docs/solutions/observability/logs/streams/streams">Streams UI</href>`,
},
}),
type: 'boolean',
schema: schema.boolean(),
requiresPageReload: true,
solution: 'oblt',
},
});

return {};
}

Expand Down
2 changes: 2 additions & 0 deletions x-pack/platform/plugins/shared/streams/server/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import type {
TaskManagerSetupContract,
TaskManagerStartContract,
} from '@kbn/task-manager-plugin/server';
import type { CloudSetup } from '@kbn/cloud-plugin/server';
import type { StreamsConfig } from '../common/config';

export interface StreamsServer {
Expand All @@ -45,6 +46,7 @@ export interface StreamsPluginSetupDependencies {
alerting: AlertingServerSetup;
ruleRegistry: RuleRegistryPluginSetup;
features: FeaturesPluginSetup;
cloud?: CloudSetup;
}

export interface StreamsPluginStartDependencies {
Expand Down
3 changes: 2 additions & 1 deletion x-pack/platform/plugins/shared/streams/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
"@kbn/zod-helpers",
"@kbn/core-http-server-utils",
"@kbn/inference-common",
"@kbn/lock-manager"
"@kbn/lock-manager",
"@kbn/management-settings-ids"
]
}