Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Infra] Provide troubleshooting information on the host details page #191104

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 @@ -111,6 +111,7 @@ const InfraMetadataRequiredRT = rt.type({

const InfraMetadataOptionalRT = rt.partial({
info: InfraMetadataInfoResponseRT,
hasSystemIntegration: rt.boolean,
});

export const InfraMetadataRT = rt.intersection([InfraMetadataRequiredRT, InfraMetadataOptionalRT]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,5 @@ export const INTEGRATIONS = {

export const DOCKER_METRIC_TYPES: DockerContainerMetrics[] = ['cpu', 'memory', 'network', 'disk'];
export const KUBERNETES_METRIC_TYPES: KubernetesContainerMetrics[] = ['cpu', 'memory'];

export const APM_HOST_TROUBLESHOOTING_LINK = 'https://ela.st/host-troubleshooting';
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,27 @@ import {
useEuiTheme,
useEuiMinBreakpoint,
type EuiPageHeaderProps,
EuiLoadingSpinner,
} from '@elastic/eui';
import { css } from '@emotion/react';
type Props = Pick<EuiPageHeaderProps, 'tabs' | 'title' | 'rightSideItems'>;
import type { InventoryItemType } from '@kbn/metrics-data-access-plugin/common/inventory_models/types';
import { PageTitleWithPopover } from './page_title_with_popover';
type Props = Pick<EuiPageHeaderProps, 'tabs' | 'title' | 'rightSideItems'> & {
hasSystemIntegration: boolean;
assetType: InventoryItemType;
metadataLoading: boolean;
loading: boolean;
};

export const FlyoutHeader = ({ title, tabs = [], rightSideItems = [] }: Props) => {
export const FlyoutHeader = ({
title,
tabs = [],
rightSideItems = [],
hasSystemIntegration,
assetType,
metadataLoading,
loading,
}: Props) => {
const { euiTheme } = useEuiTheme();

return (
Expand All @@ -39,7 +55,20 @@ export const FlyoutHeader = ({ title, tabs = [], rightSideItems = [] }: Props) =
`}
>
<EuiTitle size="xs">
<h4>{title}</h4>
{metadataLoading || loading ? (
<EuiLoadingSpinner size="m" />
) : (
<h4>
{assetType === 'host' ? (
<PageTitleWithPopover
hasSystemMetrics={hasSystemIntegration}
name={title ?? ''}
/>
) : (
title
)}
</h4>
)}
</EuiTitle>
</EuiFlexItem>
<EuiFlexItem
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import React from 'react';

import { EuiText, EuiLink, EuiFlexGroup, EuiFlexItem } from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n-react';
import { APM_HOST_TROUBLESHOOTING_LINK } from '../constants';
import { Popover } from '../tabs/common/popover';

export const PageTitleWithPopover = ({
hasSystemMetrics,
name,
}: {
hasSystemMetrics: boolean;
name: string;
}) => {
return !hasSystemMetrics ? (
<EuiFlexGroup gutterSize="xs" alignItems="center" responsive={false}>
<EuiFlexItem grow={false}>{name}</EuiFlexItem>
<EuiFlexItem grow={false}>
<Popover icon="questionInCircle" data-test-subj="assetDetailsTitleHasSystemMetricsPopover">
<EuiText size="xs">
<p>
<FormattedMessage
id="xpack.infra.assetDetails.title.tooltip.apmHostMessage"
defaultMessage="This host has been detected by {apm}"
values={{
apm: (
<EuiLink
data-test-subj="assetDetailsTitleTooltipApmDocumentationLink"
href=" https://www.elastic.co/guide/en/observability/current/apm.html"
target="_blank"
>
<FormattedMessage
id="xpack.infra.assetDetails.title.tooltip.apmHostMessage.apmDocumentationLink"
defaultMessage="APM"
/>
</EuiLink>
),
}}
/>
</p>
<p>
<EuiLink
data-test-subj="assetDetailsTitleHasSystemMetricsLearnMoreLink"
href={APM_HOST_TROUBLESHOOTING_LINK}
target="_blank"
>
<FormattedMessage
id="xpack.infra.assetDetails.title.tooltip.learnMoreLink"
defaultMessage="Learn more"
/>
</EuiLink>
</p>
</EuiText>
</Popover>
</EuiFlexItem>
</EuiFlexGroup>
) : (
<>{name}</>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ describe('#getAllFields', () => {
architecture: 'x86_64',
containerized: false,
hostname: 'host1',
hasSystemIntegration: true,
ip: [
'10.10.10.10',
'10.10.10.10',
Expand Down Expand Up @@ -63,6 +64,7 @@ describe('#getAllFields', () => {
const result: InfraMetadata = {
id: 'host1',
name: 'host1',
hasSystemIntegration: true,
features: [
{
name: 'system.core',
Expand All @@ -77,6 +79,7 @@ describe('#getAllFields', () => {
const result: InfraMetadata = {
id: 'host1',
name: 'host1',
hasSystemIntegration: true,
features: [
{
name: 'system.core',
Expand All @@ -96,6 +99,7 @@ describe('#getAllFields', () => {
const result: InfraMetadata = {
id: 'host1',
name: 'host1',
hasSystemIntegration: true,
features: [
{
name: 'system.core',
Expand All @@ -117,6 +121,7 @@ describe('#getAllFields', () => {
const result = {
id: 'host1',
name: 'host1',
hasSystemIntegration: true,
features: [
{
name: 'system.core',
Expand Down Expand Up @@ -163,6 +168,7 @@ describe('#getAllFields', () => {
const result: InfraMetadata = {
id: 'host1',
name: 'host1',
hasSystemIntegration: true,
features: [
{
name: 'system.core',
Expand Down Expand Up @@ -231,6 +237,7 @@ describe('#getAllFields', () => {
{ name: 'host.architecture', value: 'x86_64' },
{ name: 'host.containerized', value: 'false' },
{ name: 'host.hostname', value: 'host1' },
{ name: 'host.hasSystemIntegration', value: 'true' },
{
name: 'host.ip',
value: [
Expand Down Expand Up @@ -266,6 +273,7 @@ describe('#getAllFields', () => {
const result: InfraMetadata = {
id: 'host1',
name: 'host1',
hasSystemIntegration: true,
features: [
{
name: 'system.core',
Expand All @@ -282,6 +290,7 @@ describe('#getAllFields', () => {
{ name: 'host.architecture', value: 'x86_64' },
{ name: 'host.containerized', value: 'false' },
{ name: 'host.hostname', value: 'host1' },
{ name: 'host.hasSystemIntegration', value: 'true' },
{
name: 'host.ip',
value: [
Expand Down Expand Up @@ -349,6 +358,7 @@ describe('#getAllFields', () => {
const result: InfraMetadata = {
id: 'host1',
name: 'host1',
hasSystemIntegration: true,
features: [
{
name: 'system.core',
Expand All @@ -365,6 +375,7 @@ describe('#getAllFields', () => {
{ name: 'host.architecture', value: 'x86_64' },
{ name: 'host.containerized', value: 'false' },
{ name: 'host.hostname', value: 'host1' },
{ name: 'host.hasSystemIntegration', value: 'true' },
{
name: 'host.ip',
value: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@ import { Section } from '../../components/section';
import { ServicesSectionTitle } from './section_titles';
import { HOST_NAME_FIELD } from '../../../../../common/constants';
import { LinkToApmServices } from '../../links';
import { APM_HOST_FILTER_FIELD } from '../../constants';
import { APM_HOST_FILTER_FIELD, APM_HOST_TROUBLESHOOTING_LINK } from '../../constants';
import { LinkToApmService } from '../../links/link_to_apm_service';
import { useKibanaEnvironmentContext } from '../../../../hooks/use_kibana';
import { useRequestObservable } from '../../hooks/use_request_observable';
import { useTabSwitcherContext } from '../../hooks/use_tab_switcher';
import { useMetadataStateContext } from '../../hooks/use_metadata_state';

export const ServicesContent = ({
hostName,
Expand All @@ -33,6 +34,7 @@ export const ServicesContent = ({
const { isServerlessEnv } = useKibanaEnvironmentContext();
const { request$ } = useRequestObservable();
const { isActiveTab } = useTabSwitcherContext();
const { metadata, loading: metadataLoading } = useMetadataStateContext();

const linkProps = useLinkProps({
app: 'home',
Expand Down Expand Up @@ -92,7 +94,7 @@ export const ServicesContent = ({
defaultMessage: 'An error occurred while fetching services.',
})}
</EuiCallOut>
) : isPending(status) ? (
) : isPending(status) || metadataLoading ? (
<EuiLoadingSpinner size="m" />
) : hasServices ? (
<EuiFlexGroup
Expand All @@ -111,15 +113,15 @@ export const ServicesContent = ({
</EuiFlexItem>
))}
</EuiFlexGroup>
) : (
) : metadata?.hasSystemIntegration ? (
<p>
<FormattedMessage
id="xpack.infra.assetDetails.services.noServicesMsg"
defaultMessage="No services found on this host. Click {apmTutorialLink} to instrument your services with APM."
values={{
apmTutorialLink: (
<EuiLink
data-test-subj="assetDetailsTooltiAPMTutorialLink"
data-test-subj="assetDetailsTooltipAPMTutorialLink"
href={isServerlessEnv ? serverlessLinkProps.href : linkProps.href}
>
<FormattedMessage
Expand All @@ -129,7 +131,34 @@ export const ServicesContent = ({
</EuiLink>
),
}}
/>
/>{' '}
<EuiLink
data-test-subj="assetDetailsAPMTroubleshootingLink"
href={APM_HOST_TROUBLESHOOTING_LINK}
target="_blank"
>
<FormattedMessage
id="xpack.infra.assetDetails.table.services.noServices.troubleshootingLink"
defaultMessage="Troubleshooting"
/>
</EuiLink>
</p>
) : (
<p>
<FormattedMessage
id="xpack.infra.assetDetails.services.noServicesWithApmMessage"
defaultMessage="No services found on this host."
/>{' '}
<EuiLink
data-test-subj="assetDetailsAPMHostTroubleshootingLink"
href={APM_HOST_TROUBLESHOOTING_LINK}
target="_blank"
>
<FormattedMessage
id="xpack.infra.assetDetails.table.services.noServices.troubleshootingLink"
defaultMessage="Troubleshooting"
/>
</EuiLink>
</p>
)}
</Section>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@
*/

import { EuiFlyout, EuiFlyoutBody, EuiFlyoutHeader } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import React, { useCallback } from 'react';
import useEffectOnce from 'react-use/lib/useEffectOnce';
import { useKibanaContextForPlugin } from '../../../hooks/use_kibana';
import { InfraLoadingPanel } from '../../loading';
import { ASSET_DETAILS_FLYOUT_COMPONENT_NAME } from '../constants';
import { Content } from '../content/content';
import { FlyoutHeader } from '../header/flyout_header';
Expand All @@ -19,6 +17,7 @@ import { useAssetDetailsUrlState } from '../hooks/use_asset_details_url_state';
import { usePageHeader } from '../hooks/use_page_header';
import { useTabSwitcherContext } from '../hooks/use_tab_switcher';
import type { ContentTemplateProps } from '../types';
import { useMetadataStateContext } from '../hooks/use_metadata_state';

export const Flyout = ({
tabs = [],
Expand All @@ -32,6 +31,7 @@ export const Flyout = ({
const {
services: { telemetry },
} = useKibanaContextForPlugin();
const { metadata, loading: metadataLoading } = useMetadataStateContext();

useEffectOnce(() => {
telemetry.reportAssetDetailsFlyoutViewed({
Expand All @@ -53,24 +53,22 @@ export const Flyout = ({
data-component-name={ASSET_DETAILS_FLYOUT_COMPONENT_NAME}
data-asset-type={asset.type}
>
{loading ? (
<InfraLoadingPanel
height="100%"
width="auto"
text={i18n.translate('xpack.infra.waffle.loadingDataText', {
defaultMessage: 'Loading data',
})}
/>
) : (
<>
<EuiFlyoutHeader hasBorder>
<FlyoutHeader title={asset.name} tabs={tabEntries} rightSideItems={rightSideItems} />
</EuiFlyoutHeader>
<EuiFlyoutBody>
<Content />
</EuiFlyoutBody>
</>
)}
<>
<EuiFlyoutHeader hasBorder>
<FlyoutHeader
title={asset.name}
tabs={tabEntries}
rightSideItems={rightSideItems}
hasSystemIntegration={!!metadata?.hasSystemIntegration}
assetType={asset.type}
metadataLoading={metadataLoading}
loading={loading}
/>
</EuiFlyoutHeader>
<EuiFlyoutBody>
<Content />
</EuiFlyoutBody>
</>
</EuiFlyout>
);
};
Loading