From 9667162cb3a56b8f1f6bb863b87573a3af345f9c Mon Sep 17 00:00:00 2001 From: Joe Reuter Date: Tue, 10 Dec 2024 13:06:03 +0100 Subject: [PATCH 1/7] remove dependency on infra in monitoring plugin --- x-pack/plugins/monitoring/kibana.jsonc | 3 +-- x-pack/plugins/monitoring/public/components/logs/logs.js | 6 +++--- .../plugins/monitoring/public/components/logs/logs.test.js | 1 - x-pack/plugins/monitoring/public/legacy_shims.ts | 4 ---- x-pack/plugins/monitoring/public/plugin.ts | 2 -- x-pack/plugins/monitoring/public/types.ts | 2 -- .../monitoring/server/routes/api/v1/alerts/enable.ts | 7 ++----- x-pack/plugins/monitoring/server/types.ts | 3 --- x-pack/plugins/monitoring/tsconfig.json | 1 - 9 files changed, 6 insertions(+), 23 deletions(-) diff --git a/x-pack/plugins/monitoring/kibana.jsonc b/x-pack/plugins/monitoring/kibana.jsonc index 334ffd05890bc..46c55a73a2ec0 100644 --- a/x-pack/plugins/monitoring/kibana.jsonc +++ b/x-pack/plugins/monitoring/kibana.jsonc @@ -4,7 +4,7 @@ "owner": [ "@elastic/stack-monitoring" ], - "group": "observability", + "group": "platform", "visibility": "private", "plugin": { "id": "monitoring", @@ -25,7 +25,6 @@ "share" ], "optionalPlugins": [ - "infra", "usageCollection", "home", "cloud", diff --git a/x-pack/plugins/monitoring/public/components/logs/logs.js b/x-pack/plugins/monitoring/public/components/logs/logs.js index 82fdac6ea1f0d..a6acd6e74095c 100644 --- a/x-pack/plugins/monitoring/public/components/logs/logs.js +++ b/x-pack/plugins/monitoring/public/components/logs/logs.js @@ -175,7 +175,7 @@ export class LogsContent extends PureComponent { } renderCallout() { - const { capabilities: uiCapabilities, infra, kibanaServices } = Legacy.shims; + const { capabilities: uiCapabilities, kibanaServices } = Legacy.shims; const show = uiCapabilities.discover && uiCapabilities.discover.show; const { @@ -191,7 +191,7 @@ export class LogsContent extends PureComponent { return null; } - return infra ? ( + return ( - ) : null; + ); } render() { diff --git a/x-pack/plugins/monitoring/public/components/logs/logs.test.js b/x-pack/plugins/monitoring/public/components/logs/logs.test.js index 9d3f68c854505..f253445c1c94c 100644 --- a/x-pack/plugins/monitoring/public/components/logs/logs.test.js +++ b/x-pack/plugins/monitoring/public/components/logs/logs.test.js @@ -15,7 +15,6 @@ jest.mock('../../legacy_shims', () => ({ shims: { getBasePath: () => '', capabilities: { discover: { show: true } }, - infra: {}, }, }, })); diff --git a/x-pack/plugins/monitoring/public/legacy_shims.ts b/x-pack/plugins/monitoring/public/legacy_shims.ts index 32322a2b4f7ac..b2b5cafedfb69 100644 --- a/x-pack/plugins/monitoring/public/legacy_shims.ts +++ b/x-pack/plugins/monitoring/public/legacy_shims.ts @@ -22,7 +22,6 @@ import { TriggersAndActionsUIPublicPluginStart } from '@kbn/triggers-actions-ui- import { TypeRegistry } from '@kbn/triggers-actions-ui-plugin/public/application/type_registry'; import { ActionTypeModel, RuleTypeModel } from '@kbn/triggers-actions-ui-plugin/public/types'; import { UsageCollectionSetup } from '@kbn/usage-collection-plugin/public'; -import type { InfraClientStartExports } from '@kbn/infra-plugin/public'; import { MonitoringStartPluginDependencies, LegacyMonitoringStartPluginDependencies, @@ -74,7 +73,6 @@ export interface IShims { usageCollection: UsageCollectionSetup; kibanaServices: CoreStart & { usageCollection: UsageCollectionSetup }; appMountParameters: AppMountParameters; - infra?: InfraClientStartExports; } export class Legacy { @@ -87,7 +85,6 @@ export class Legacy { triggersActionsUi, usageCollection, appMountParameters, - infra, }: LegacyMonitoringStartPluginDependencies) { this._shims = { toastNotifications: core.notifications.toasts, @@ -146,7 +143,6 @@ export class Legacy { usageCollection, }, appMountParameters, - infra, }; } diff --git a/x-pack/plugins/monitoring/public/plugin.ts b/x-pack/plugins/monitoring/public/plugin.ts index 02033d839e1ae..b526a37ceb6de 100644 --- a/x-pack/plugins/monitoring/public/plugin.ts +++ b/x-pack/plugins/monitoring/public/plugin.ts @@ -111,7 +111,6 @@ export class MonitoringPlugin usageCollection: plugins.usageCollection, appMountParameters: params, dataViews: pluginsStart.dataViews, - infra: pluginsStart.infra, }; Legacy.init({ @@ -126,7 +125,6 @@ export class MonitoringPlugin usageCollection: deps.usageCollection, appMountParameters: deps.appMountParameters, dataViews: deps.dataViews, - infra: deps.infra, share: deps.share, }); diff --git a/x-pack/plugins/monitoring/public/types.ts b/x-pack/plugins/monitoring/public/types.ts index cd5314521f947..70476c14d61e3 100644 --- a/x-pack/plugins/monitoring/public/types.ts +++ b/x-pack/plugins/monitoring/public/types.ts @@ -15,7 +15,6 @@ export type { MLJobs } from '../server/lib/elasticsearch/get_ml_jobs'; import { DataViewsPublicPluginStart } from '@kbn/data-views-plugin/public'; import { DashboardStart } from '@kbn/dashboard-plugin/public'; import { FleetStart } from '@kbn/fleet-plugin/public'; -import type { InfraClientStartExports } from '@kbn/infra-plugin/public'; import { SharePluginStart } from '@kbn/share-plugin/public'; export interface MonitoringStartPluginDependencies { @@ -26,7 +25,6 @@ export interface MonitoringStartPluginDependencies { dataViews: DataViewsPublicPluginStart; dashboard?: DashboardStart; fleet?: FleetStart; - infra?: InfraClientStartExports; share: SharePluginStart; } diff --git a/x-pack/plugins/monitoring/server/routes/api/v1/alerts/enable.ts b/x-pack/plugins/monitoring/server/routes/api/v1/alerts/enable.ts index 593f3c9b2b4ab..61253d93dbebf 100644 --- a/x-pack/plugins/monitoring/server/routes/api/v1/alerts/enable.ts +++ b/x-pack/plugins/monitoring/server/routes/api/v1/alerts/enable.ts @@ -26,7 +26,6 @@ export function enableAlertsRoute(server: MonitoringCore, npRoute: RouteDependen async (context, request, response) => { try { const alertingContext = await context.alerting; - const infraContext = await context.infra; const actionContext = await context.actions; const alerts = RulesFactory.getAll(); @@ -39,7 +38,7 @@ export function enableAlertsRoute(server: MonitoringCore, npRoute: RouteDependen if (!isSufficientlySecure || !hasPermanentEncryptionKey) { server.log.info( - `Skipping rule creation for "${infraContext.spaceId}" space; Stack Monitoring rules require API keys to be enabled and an encryption key to be configured.` + `Skipping rule creation; Stack Monitoring rules require API keys to be enabled and an encryption key to be configured.` ); return response.ok({ body: { @@ -90,9 +89,7 @@ export function enableAlertsRoute(server: MonitoringCore, npRoute: RouteDependen alerts.map((alert) => alert.createIfDoesNotExist(rulesClient, actionsClient, actions)) ); - server.log.info( - `Created ${createdAlerts.length} alerts for "${infraContext.spaceId}" space` - ); + server.log.info(`Created ${createdAlerts.length} alerts`); return response.ok({ body: { createdAlerts } }); } catch (err) { diff --git a/x-pack/plugins/monitoring/server/types.ts b/x-pack/plugins/monitoring/server/types.ts index 14ef949b93949..ea15ce98117e5 100644 --- a/x-pack/plugins/monitoring/server/types.ts +++ b/x-pack/plugins/monitoring/server/types.ts @@ -25,7 +25,6 @@ import type { import type { AlertingApiRequestHandlerContext } from '@kbn/alerting-plugin/server'; import type { RacApiRequestHandlerContext } from '@kbn/rule-registry-plugin/server'; import { AlertingServerSetup, AlertingServerStart } from '@kbn/alerting-plugin/server'; -import { InfraPluginSetup, InfraRequestHandlerContext } from '@kbn/infra-plugin/server'; import { LicensingPluginStart } from '@kbn/licensing-plugin/server'; import { FeaturesPluginSetup } from '@kbn/features-plugin/server'; import { EncryptedSavedObjectsPluginSetup } from '@kbn/encrypted-saved-objects-plugin/server'; @@ -51,14 +50,12 @@ export interface PluginsSetup { usageCollection?: UsageCollectionSetup; features: FeaturesPluginSetup; alerting?: AlertingServerSetup; - infra: InfraPluginSetup; cloud?: CloudSetup; } export type RequestHandlerContextMonitoringPlugin = CustomRequestHandlerContext<{ actions?: ActionsApiRequestHandlerContext; alerting?: AlertingApiRequestHandlerContext; - infra: InfraRequestHandlerContext; ruleRegistry?: RacApiRequestHandlerContext; }>; diff --git a/x-pack/plugins/monitoring/tsconfig.json b/x-pack/plugins/monitoring/tsconfig.json index 6be14087cc11d..af126afa8a2cd 100644 --- a/x-pack/plugins/monitoring/tsconfig.json +++ b/x-pack/plugins/monitoring/tsconfig.json @@ -17,7 +17,6 @@ "@kbn/cloud-plugin", "@kbn/encrypted-saved-objects-plugin", "@kbn/features-plugin", - "@kbn/infra-plugin", "@kbn/licensing-plugin", "@kbn/triggers-actions-ui-plugin", "@kbn/expect", From 33b24542a56eb52f85b0420c92363f5d3fa0624e Mon Sep 17 00:00:00 2001 From: Joe Reuter Date: Tue, 10 Dec 2024 13:12:03 +0100 Subject: [PATCH 2/7] fix some stugf --- .../monitoring/public/components/logs/logs.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/x-pack/plugins/monitoring/public/components/logs/logs.js b/x-pack/plugins/monitoring/public/components/logs/logs.js index a6acd6e74095c..ab897423ff056 100644 --- a/x-pack/plugins/monitoring/public/components/logs/logs.js +++ b/x-pack/plugins/monitoring/public/components/logs/logs.js @@ -111,7 +111,7 @@ const clusterColumns = [ }, ]; -function getLogsUiLink(clusterUuid, nodeId, indexUuid, sharePlugin, logsIndices) { +function getDiscoverLink(clusterUuid, nodeId, indexUuid, sharePlugin, logsIndices) { const params = []; if (clusterUuid) { params.push(`elasticsearch.cluster.uuid:${clusterUuid}`); @@ -126,6 +126,10 @@ function getLogsUiLink(clusterUuid, nodeId, indexUuid, sharePlugin, logsIndices) const filter = params.join(' and '); const discoverLocator = sharePlugin.url.locators.get('DISCOVER_APP_LOCATOR'); + if (!discoverLocator) { + return; + } + const base = discoverLocator.getRedirectUrl({ dataViewSpec: { id: logsIndices, @@ -190,8 +194,9 @@ export class LogsContent extends PureComponent { if (!enabled || !show) { return null; } + const discoverLink = getDiscoverLink(clusterUuid, nodeId, indexUuid, sharePlugin, logsIndices); - return ( + return discoverLink ? ( + {i18n.translate('xpack.monitoring.logs.listing.calloutLinkText', { defaultMessage: 'Discover', })} @@ -217,7 +220,7 @@ export class LogsContent extends PureComponent { /> - ); + ) : null; } render() { From b6de1ee635b46c143b376c959a78cb790f9bdb13 Mon Sep 17 00:00:00 2001 From: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Date: Tue, 10 Dec 2024 12:26:41 +0000 Subject: [PATCH 3/7] [CI] Auto-commit changed files from 'node scripts/lint_ts_projects --fix' --- x-pack/plugins/monitoring/tsconfig.json | 1 + 1 file changed, 1 insertion(+) diff --git a/x-pack/plugins/monitoring/tsconfig.json b/x-pack/plugins/monitoring/tsconfig.json index af126afa8a2cd..de27688ecf95f 100644 --- a/x-pack/plugins/monitoring/tsconfig.json +++ b/x-pack/plugins/monitoring/tsconfig.json @@ -47,6 +47,7 @@ "@kbn/ui-theme", "@kbn/core-elasticsearch-server", "@kbn/share-plugin", + "@kbn/infra-plugin", ], "exclude": [ "target/**/*", From d8292b7c3ac05da0e150ea2efbd945e905e9e795 Mon Sep 17 00:00:00 2001 From: Joe Reuter Date: Tue, 10 Dec 2024 14:45:59 +0100 Subject: [PATCH 4/7] fix --- x-pack/plugins/monitoring/kibana.jsonc | 2 +- .../server/lib/setup/collection/get_collection_status.test.ts | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/x-pack/plugins/monitoring/kibana.jsonc b/x-pack/plugins/monitoring/kibana.jsonc index 46c55a73a2ec0..4b61bf27788a8 100644 --- a/x-pack/plugins/monitoring/kibana.jsonc +++ b/x-pack/plugins/monitoring/kibana.jsonc @@ -4,7 +4,7 @@ "owner": [ "@elastic/stack-monitoring" ], - "group": "platform", + "group": "observability", "visibility": "private", "plugin": { "id": "monitoring", diff --git a/x-pack/plugins/monitoring/server/lib/setup/collection/get_collection_status.test.ts b/x-pack/plugins/monitoring/server/lib/setup/collection/get_collection_status.test.ts index ce03cc5aecf3b..efdcde6d1f937 100644 --- a/x-pack/plugins/monitoring/server/lib/setup/collection/get_collection_status.test.ts +++ b/x-pack/plugins/monitoring/server/lib/setup/collection/get_collection_status.test.ts @@ -6,7 +6,6 @@ */ import { featuresPluginMock } from '@kbn/features-plugin/server/mocks'; -import { infraPluginMock } from '@kbn/infra-plugin/server/mocks'; import { loggerMock } from '@kbn/logging-mocks'; import { usageCollectionPluginMock } from '@kbn/usage-collection-plugin/server/mocks'; import { configSchema, createConfig } from '../../../config'; @@ -37,7 +36,6 @@ const mockReq = ( plugins: { usageCollection: usageCollectionSetup, features: featuresPluginMock.createSetup(), - infra: infraPluginMock.createSetupContract(), }, }, }, From fd270cbb89167386363c5890ab4f84a8adc66c74 Mon Sep 17 00:00:00 2001 From: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Date: Tue, 10 Dec 2024 13:56:57 +0000 Subject: [PATCH 5/7] [CI] Auto-commit changed files from 'node scripts/lint_ts_projects --fix' --- x-pack/plugins/monitoring/tsconfig.json | 1 - 1 file changed, 1 deletion(-) diff --git a/x-pack/plugins/monitoring/tsconfig.json b/x-pack/plugins/monitoring/tsconfig.json index de27688ecf95f..af126afa8a2cd 100644 --- a/x-pack/plugins/monitoring/tsconfig.json +++ b/x-pack/plugins/monitoring/tsconfig.json @@ -47,7 +47,6 @@ "@kbn/ui-theme", "@kbn/core-elasticsearch-server", "@kbn/share-plugin", - "@kbn/infra-plugin", ], "exclude": [ "target/**/*", From 714bd9167be7a1f8976cf5bfcdd9be5e66ed7712 Mon Sep 17 00:00:00 2001 From: Joe Reuter Date: Tue, 10 Dec 2024 15:04:08 +0100 Subject: [PATCH 6/7] everything goes to platform --- x-pack/plugins/logstash/kibana.jsonc | 2 +- x-pack/plugins/monitoring/kibana.jsonc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/x-pack/plugins/logstash/kibana.jsonc b/x-pack/plugins/logstash/kibana.jsonc index 83665c1ed344e..2242e6254fffc 100644 --- a/x-pack/plugins/logstash/kibana.jsonc +++ b/x-pack/plugins/logstash/kibana.jsonc @@ -4,7 +4,7 @@ "owner": [ "@elastic/logstash" ], - "group": "observability", + "group": "platform", "visibility": "private", "plugin": { "id": "logstash", diff --git a/x-pack/plugins/monitoring/kibana.jsonc b/x-pack/plugins/monitoring/kibana.jsonc index 4b61bf27788a8..46c55a73a2ec0 100644 --- a/x-pack/plugins/monitoring/kibana.jsonc +++ b/x-pack/plugins/monitoring/kibana.jsonc @@ -4,7 +4,7 @@ "owner": [ "@elastic/stack-monitoring" ], - "group": "observability", + "group": "platform", "visibility": "private", "plugin": { "id": "monitoring", From eb5d104caa757af4cfe6f698008c0a5fecb77a40 Mon Sep 17 00:00:00 2001 From: Joe Reuter Date: Wed, 11 Dec 2024 11:30:13 +0100 Subject: [PATCH 7/7] fix test --- .../logs/__snapshots__/logs.test.js.snap | 16 ++++++++++++---- .../public/components/logs/logs.test.js | 4 +++- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/x-pack/plugins/monitoring/public/components/logs/__snapshots__/logs.test.js.snap b/x-pack/plugins/monitoring/public/components/logs/__snapshots__/logs.test.js.snap index 91b3dea5ab049..36ebe98fb014d 100644 --- a/x-pack/plugins/monitoring/public/components/logs/__snapshots__/logs.test.js.snap +++ b/x-pack/plugins/monitoring/public/components/logs/__snapshots__/logs.test.js.snap @@ -12,7 +12,9 @@ exports[`Logs should render a link to filter by cluster uuid 1`] = ` id="xpack.monitoring.logs.listing.linkText" values={ Object { - "link": + "link": Discover , } @@ -34,7 +36,9 @@ exports[`Logs should render a link to filter by cluster uuid and index uuid 1`] id="xpack.monitoring.logs.listing.linkText" values={ Object { - "link": + "link": Discover , } @@ -56,7 +60,9 @@ exports[`Logs should render a link to filter by cluster uuid and node uuid 1`] = id="xpack.monitoring.logs.listing.linkText" values={ Object { - "link": + "link": Discover , } @@ -284,7 +290,9 @@ exports[`Logs should render normally 1`] = ` id="xpack.monitoring.logs.listing.linkText" values={ Object { - "link": + "link": Discover , } diff --git a/x-pack/plugins/monitoring/public/components/logs/logs.test.js b/x-pack/plugins/monitoring/public/components/logs/logs.test.js index f253445c1c94c..50e850400cc06 100644 --- a/x-pack/plugins/monitoring/public/components/logs/logs.test.js +++ b/x-pack/plugins/monitoring/public/components/logs/logs.test.js @@ -23,7 +23,9 @@ const sharePlugin = { url: { locators: { get: () => { - return sharePluginMock.createLocator(); + const locatorMock = sharePluginMock.createLocator(); + locatorMock.getRedirectUrl.mockReturnValue('http://localhost:5601/app/discover'); + return locatorMock; }, }, },