@@ -425,31 +448,33 @@ export const AnomaliesTable = (props: Props) => {
-
-
-
-
-
-
-
-
+ {!hostName && (
+
+
+
+
+
+
+
+
+ )}
diff --git a/x-pack/plugins/infra/public/pages/metrics/inventory_view/components/node_details/overlay.tsx b/x-pack/plugins/infra/public/pages/metrics/inventory_view/components/node_details/overlay.tsx
index f21a9d1e1f591..eb5a3f3f9fee1 100644
--- a/x-pack/plugins/infra/public/pages/metrics/inventory_view/components/node_details/overlay.tsx
+++ b/x-pack/plugins/infra/public/pages/metrics/inventory_view/components/node_details/overlay.tsx
@@ -19,6 +19,7 @@ import { MetricsTab } from './tabs/metrics/metrics';
import { LogsTab } from './tabs/logs';
import { ProcessesTab } from './tabs/processes';
import { PropertiesTab } from './tabs/properties/index';
+import { AnomaliesTab } from './tabs/anomalies/anomalies';
import { OVERLAY_Y_START, OVERLAY_BOTTOM_MARGIN } from './tabs/shared';
import { useLinkProps } from '../../../../../hooks/use_link_props';
import { getNodeDetailUrl } from '../../../../link_to';
@@ -44,7 +45,7 @@ export const NodeContextPopover = ({
openAlertFlyout,
}: Props) => {
// eslint-disable-next-line react-hooks/exhaustive-deps
- const tabConfigs = [MetricsTab, LogsTab, ProcessesTab, PropertiesTab];
+ const tabConfigs = [MetricsTab, LogsTab, ProcessesTab, PropertiesTab, AnomaliesTab];
const inventoryModel = findInventoryModel(nodeType);
const nodeDetailFrom = currentTime - inventoryModel.metrics.defaultTimeRangeInSeconds * 1000;
const uiCapabilities = useKibana().services.application?.capabilities;
@@ -58,11 +59,17 @@ export const NodeContextPopover = ({
return {
...m,
content: (
-
+
),
};
});
- }, [tabConfigs, node, nodeType, currentTime, options]);
+ }, [tabConfigs, node, nodeType, currentTime, onClose, options]);
const [selectedTab, setSelectedTab] = useState(0);
diff --git a/x-pack/plugins/infra/public/pages/metrics/inventory_view/components/node_details/tabs/anomalies/anomalies.tsx b/x-pack/plugins/infra/public/pages/metrics/inventory_view/components/node_details/tabs/anomalies/anomalies.tsx
new file mode 100644
index 0000000000000..40dad03f73366
--- /dev/null
+++ b/x-pack/plugins/infra/public/pages/metrics/inventory_view/components/node_details/tabs/anomalies/anomalies.tsx
@@ -0,0 +1,29 @@
+/*
+ * 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 { i18n } from '@kbn/i18n';
+import React from 'react';
+import { AnomaliesTable } from '../../../ml/anomaly_detection/anomalies_table/anomalies_table';
+import { TabContent, TabProps } from '../shared';
+
+const TabComponent = (props: TabProps) => {
+ const { node, onClose } = props;
+
+ return (
+
+
+
+ );
+};
+
+export const AnomaliesTab = {
+ id: 'anomalies',
+ name: i18n.translate('xpack.infra.nodeDetails.tabs.anomalies', {
+ defaultMessage: 'Anomalies',
+ }),
+ content: TabComponent,
+};
diff --git a/x-pack/plugins/infra/public/pages/metrics/inventory_view/components/node_details/tabs/shared.tsx b/x-pack/plugins/infra/public/pages/metrics/inventory_view/components/node_details/tabs/shared.tsx
index 979048ca685f8..f011f91a2e9df 100644
--- a/x-pack/plugins/infra/public/pages/metrics/inventory_view/components/node_details/tabs/shared.tsx
+++ b/x-pack/plugins/infra/public/pages/metrics/inventory_view/components/node_details/tabs/shared.tsx
@@ -14,6 +14,7 @@ export interface TabProps {
currentTime: number;
node: InfraWaffleMapNode;
nodeType: InventoryItemType;
+ onClose(): void;
}
export const OVERLAY_Y_START = 266;
diff --git a/x-pack/plugins/infra/public/pages/metrics/inventory_view/hooks/use_metrics_hosts_anomalies.ts b/x-pack/plugins/infra/public/pages/metrics/inventory_view/hooks/use_metrics_hosts_anomalies.ts
index 5ef6c9429c4b3..b1401f268dc51 100644
--- a/x-pack/plugins/infra/public/pages/metrics/inventory_view/hooks/use_metrics_hosts_anomalies.ts
+++ b/x-pack/plugins/infra/public/pages/metrics/inventory_view/hooks/use_metrics_hosts_anomalies.ts
@@ -174,7 +174,7 @@ export const useMetricsHostsAnomaliesResults = ({
const [getMetricsHostsAnomaliesRequest, getMetricsHostsAnomalies] = useTrackedPromise(
{
cancelPreviousOn: 'creation',
- createPromise: async (metric?: Metric, query?: string) => {
+ createPromise: async (metric?: Metric, query?: string, hostName?: string) => {
const {
timeRange: { start: queryStartTime, end: queryEndTime },
sortOptions,
@@ -195,6 +195,7 @@ export const useMetricsHostsAnomaliesResults = ({
...paginationOptions,
cursor: paginationCursor,
},
+ hostName,
},
services.http.fetch
);
@@ -309,6 +310,7 @@ interface RequestArgs {
endTime: number;
metric?: Metric;
query?: string;
+ hostName?: string;
sort: Sort;
pagination: Pagination;
}
@@ -326,6 +328,7 @@ export const callGetMetricHostsAnomaliesAPI = async (
sort,
pagination,
query,
+ hostName,
} = requestArgs;
const response = await fetch(INFA_ML_GET_METRICS_HOSTS_ANOMALIES_PATH, {
method: 'POST',
@@ -342,6 +345,7 @@ export const callGetMetricHostsAnomaliesAPI = async (
metric,
sort,
pagination,
+ hostName,
},
})
),
diff --git a/x-pack/plugins/infra/server/routes/infra_ml/results/metrics_hosts_anomalies.ts b/x-pack/plugins/infra/server/routes/infra_ml/results/metrics_hosts_anomalies.ts
index 15ff6c0834a75..1b5ed62a006be 100644
--- a/x-pack/plugins/infra/server/routes/infra_ml/results/metrics_hosts_anomalies.ts
+++ b/x-pack/plugins/infra/server/routes/infra_ml/results/metrics_hosts_anomalies.ts
@@ -40,6 +40,7 @@ export const initGetHostsAnomaliesRoute = ({ framework }: InfraBackendLibs) => {
pagination: paginationParam,
metric,
query,
+ hostName,
},
} = request.body;
@@ -63,6 +64,12 @@ export const initGetHostsAnomaliesRoute = ({ framework }: InfraBackendLibs) => {
query,
sort,
pagination,
+ influencerFilter: hostName
+ ? {
+ fieldName: 'host.name',
+ fieldValue: hostName,
+ }
+ : undefined,
});
return response.ok({