diff --git a/x-pack/plugins/observability_solution/observability_onboarding/public/application/quickstart_flows/auto_detect/auto_detect_panel.tsx b/x-pack/plugins/observability_solution/observability_onboarding/public/application/quickstart_flows/auto_detect/auto_detect_panel.tsx index 5d62f1060b50e..d12f0cae583f4 100644 --- a/x-pack/plugins/observability_solution/observability_onboarding/public/application/quickstart_flows/auto_detect/auto_detect_panel.tsx +++ b/x-pack/plugins/observability_solution/observability_onboarding/public/application/quickstart_flows/auto_detect/auto_detect_panel.tsx @@ -23,6 +23,7 @@ import { } from '@kbn/deeplinks-observability/locators'; import { useKibana } from '@kbn/kibana-react-plugin/public'; import { DASHBOARD_APP_LOCATOR } from '@kbn/deeplinks-analytics'; +import { ASSET_DETAILS_LOCATOR_ID } from '@kbn/observability-shared-plugin/common'; import { getAutoDetectCommand } from './get_auto_detect_command'; import { DASHBOARDS, useOnboardingFlow } from './use_onboarding_flow'; import { ProgressIndicator } from '../shared/progress_indicator'; @@ -66,6 +67,7 @@ export const AutoDetectPanel: FunctionComponent = () => { (integration) => integration.installSource === 'custom' ); const dashboardLocator = share.url.locators.get(DASHBOARD_APP_LOCATOR); + const assetDetailsLocator = share.url.locators.get(ASSET_DETAILS_LOCATOR_ID); return ( @@ -147,88 +149,133 @@ export const AutoDetectPanel: FunctionComponent = () => { installedIntegrations.length > 0 ? ( <> - {registryIntegrations.map((integration) => ( - - ) : ( - - ) - } - title={i18n.translate( - 'xpack.observability_onboarding.autoDetectPanel.h3.getStartedWithNginxLabel', - { - defaultMessage: 'Get started with {title}', - values: { title: integration.title }, - } - )} - isDisabled={status !== 'dataReceived'} - initialIsOpen - > - asset.type === 'dashboard') - .map((asset) => { - const dashboard = DASHBOARDS[asset.id as keyof typeof DASHBOARDS]; - const href = - dashboardLocator?.getRedirectUrl({ - dashboardId: asset.id, - }) ?? ''; + {registryIntegrations + .slice() + /** + * System integration should always be on top + */ + .sort((a, b) => (a.pkgName === 'system' ? -1 : 0)) + .map((integration) => { + let actionLinks; - return { - id: asset.id, - title: - dashboard.type === 'metrics' - ? i18n.translate( - 'xpack.observability_onboarding.autoDetectPanel.exploreMetricsDataTitle', - { - defaultMessage: - 'Overview your metrics data with this pre-made dashboard', - } - ) - : i18n.translate( - 'xpack.observability_onboarding.autoDetectPanel.exploreLogsDataTitle', + switch (integration.pkgName) { + case 'system': + actionLinks = + assetDetailsLocator !== undefined + ? [ + { + id: 'inventory-host-details', + title: i18n.translate( + 'xpack.observability_onboarding.autoDetectPanel.systemOverviewTitle', { defaultMessage: - 'Overview your logs data with this pre-made dashboard', + 'Overview your system health within the Hosts Inventory', } ), - label: - dashboard.type === 'metrics' - ? i18n.translate( - 'xpack.observability_onboarding.autoDetectPanel.exploreMetricsDataLabel', + label: i18n.translate( + 'xpack.observability_onboarding.autoDetectPanel.systemOverviewLabel', { defaultMessage: 'Explore metrics data', } - ) - : i18n.translate( - 'xpack.observability_onboarding.autoDetectPanel.exploreLogsDataLabel', - { - defaultMessage: 'Explore logs data', - } ), - href, - }; - })} - /> - - ))} + href: assetDetailsLocator.getRedirectUrl({ + assetType: 'host', + assetId: integration.metadata?.hostname, + }), + }, + ] + : []; + break; + default: + actionLinks = + dashboardLocator !== undefined + ? integration.kibanaAssets + .filter((asset) => asset.type === 'dashboard') + .map((asset) => { + const dashboard = + DASHBOARDS[asset.id as keyof typeof DASHBOARDS]; + const href = dashboardLocator.getRedirectUrl({ + dashboardId: asset.id, + }); + + return { + id: asset.id, + title: + dashboard.type === 'metrics' + ? i18n.translate( + 'xpack.observability_onboarding.autoDetectPanel.exploreMetricsDataTitle', + { + defaultMessage: + 'Overview your metrics data with this pre-made dashboard', + } + ) + : i18n.translate( + 'xpack.observability_onboarding.autoDetectPanel.exploreLogsDataTitle', + { + defaultMessage: + 'Overview your logs data with this pre-made dashboard', + } + ), + label: + dashboard.type === 'metrics' + ? i18n.translate( + 'xpack.observability_onboarding.autoDetectPanel.exploreMetricsDataLabel', + { + defaultMessage: 'Explore metrics data', + } + ) + : i18n.translate( + 'xpack.observability_onboarding.autoDetectPanel.exploreLogsDataLabel', + { + defaultMessage: 'Explore logs data', + } + ), + href, + }; + }) + : []; + } + + return ( + + ) : ( + + ) + } + title={i18n.translate( + 'xpack.observability_onboarding.autoDetectPanel.h3.getStartedWithNginxLabel', + { + defaultMessage: 'Get started with {title}', + values: { title: integration.title }, + } + )} + isDisabled={status !== 'dataReceived'} + initialIsOpen + > + + + ); + })} {customIntegrations.length > 0 && ( ({ type, dataset })) ?? [], kibanaAssets: pkg.installed_kibana, + metadata: integration.metadata, }; } @@ -482,7 +490,8 @@ async function ensureInstalledIntegrations( * Example input: * * ```text - * system registry + * system registry hostname + * nginx registry * product_service custom /path/to/access.log * product_service custom /path/to/error.log * checkout_service custom /path/to/access.log @@ -495,42 +504,55 @@ function parseIntegrationsTSV(tsv: string) { .trim() .split('\n') .map((line) => line.split('\t', 3)) - .reduce>( - (acc, [pkgName, installSource, logFilePath]) => { - const key = `${pkgName}-${installSource}`; - if (installSource === 'registry') { - if (logFilePath) { - throw new Error(`Integration '${pkgName}' does not support a file path`); - } - acc[key] = { - pkgName, - installSource, - }; - return acc; - } else if (installSource === 'custom') { - if (!logFilePath) { - throw new Error(`Missing file path for integration: ${pkgName}`); - } - // Append file path if integration is already in the list - const existing = acc[key]; - if (existing && existing.installSource === 'custom') { - existing.logFilePaths.push(logFilePath); - return acc; - } - acc[key] = { - pkgName, - installSource, - logFilePaths: [logFilePath], - }; + .reduce>((acc, [pkgName, installSource, parameter]) => { + const key = `${pkgName}-${installSource}`; + if (installSource === 'registry') { + const metadata = parseRegistryIntegrationMetadata(pkgName, parameter); + + acc[key] = { + pkgName, + installSource, + metadata, + }; + return acc; + } else if (installSource === 'custom') { + if (!parameter) { + throw new Error(`Missing file path for integration: ${pkgName}`); + } + // Append file path if integration is already in the list + const existing = acc[key]; + if (existing && existing.installSource === 'custom') { + existing.logFilePaths.push(parameter); return acc; } - throw new Error(`Invalid install source: ${installSource}`); - }, - {} - ) + acc[key] = { + pkgName, + installSource, + logFilePaths: [parameter], + }; + return acc; + } + throw new Error(`Invalid install source: ${installSource}`); + }, {}) ); } +function parseRegistryIntegrationMetadata( + pkgName: string, + parameter: string +): RegistryIntegrationMetadata | undefined { + switch (pkgName) { + case 'system': + if (!parameter) { + throw new Error('Missing hostname for System integration'); + } + + return { hostname: parameter }; + default: + return undefined; + } +} + const generateAgentConfigTar = ({ elasticsearchUrl, installedIntegrations, diff --git a/x-pack/plugins/observability_solution/observability_onboarding/server/routes/types.ts b/x-pack/plugins/observability_solution/observability_onboarding/server/routes/types.ts index c9cded0805f65..4b35272eaa330 100644 --- a/x-pack/plugins/observability_solution/observability_onboarding/server/routes/types.ts +++ b/x-pack/plugins/observability_solution/observability_onboarding/server/routes/types.ts @@ -52,25 +52,30 @@ export interface ObservabilityOnboardingRouteCreateOptions { }; } -export const IntegrationRT = t.type({ - installSource: t.union([t.literal('registry'), t.literal('custom')]), - pkgName: t.string, - pkgVersion: t.string, - title: t.string, - config: t.string, - dataStreams: t.array( - t.type({ - type: t.string, - dataset: t.string, - }) - ), - kibanaAssets: t.array( - t.type({ - type: t.string, - id: t.string, - }) - ), -}); +export const IntegrationRT = t.intersection([ + t.type({ + installSource: t.union([t.literal('registry'), t.literal('custom')]), + pkgName: t.string, + pkgVersion: t.string, + title: t.string, + config: t.string, + dataStreams: t.array( + t.type({ + type: t.string, + dataset: t.string, + }) + ), + kibanaAssets: t.array( + t.type({ + type: t.string, + id: t.string, + }) + ), + }), + t.partial({ + metadata: t.type({ hostname: t.string }), + }), +]); export type InstalledIntegration = t.TypeOf; diff --git a/x-pack/plugins/observability_solution/observability_onboarding/server/saved_objects/observability_onboarding_status.ts b/x-pack/plugins/observability_solution/observability_onboarding/server/saved_objects/observability_onboarding_status.ts index c59bec0285266..03be370e6cf6b 100644 --- a/x-pack/plugins/observability_solution/observability_onboarding/server/saved_objects/observability_onboarding_status.ts +++ b/x-pack/plugins/observability_solution/observability_onboarding/server/saved_objects/observability_onboarding_status.ts @@ -75,6 +75,13 @@ export const InstallIntegrationsStepPayloadSchema = schema.arrayOf( id: schema.string(), }) ), + metadata: schema.maybe( + schema.oneOf([ + schema.object({ + hostname: schema.string(), + }), + ]) + ), }) ); diff --git a/x-pack/test_serverless/functional/test_suites/observability/onboarding/auto_detect.ts b/x-pack/test_serverless/functional/test_suites/observability/onboarding/auto_detect.ts index d8a0503fbb913..b8f47086e85c3 100644 --- a/x-pack/test_serverless/functional/test_suites/observability/onboarding/auto_detect.ts +++ b/x-pack/test_serverless/functional/test_suites/observability/onboarding/auto_detect.ts @@ -60,7 +60,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { .set('Content-Type', 'text/tab-separated-values') .set('x-elastic-internal-origin', 'Kibana') .set('kbn-xsrf', 'true') - .send('system\tregistry\n') + .send('system\tregistry\ttest-host\n') .expect(200); // Simulate bash script installing Elastic Agent