diff --git a/x-pack/plugins/observability_solution/infra/public/components/asset_details/tabs/overview/alerts/alerts.tsx b/x-pack/plugins/observability_solution/infra/public/components/asset_details/tabs/overview/alerts/alerts.tsx index f33fa9bca6bdf..61c39ad461eee 100644 --- a/x-pack/plugins/observability_solution/infra/public/components/asset_details/tabs/overview/alerts/alerts.tsx +++ b/x-pack/plugins/observability_solution/infra/public/components/asset_details/tabs/overview/alerts/alerts.tsx @@ -21,6 +21,8 @@ import { type AlertsCount } from '../../../../../hooks/use_alerts_count'; import { AlertsOverview } from '../../../../shared/alerts/alerts_overview'; import { CreateAlertRuleButton } from '../../../../shared/alerts/links/create_alert_rule_button'; import { LinkToAlertsPage } from '../../../../shared/alerts/links/link_to_alerts_page'; +import { useIntegrationCheck } from '../../../hooks/use_integration_check'; +import { INTEGRATIONS } from '../../../constants'; export const AlertsSummaryContent = ({ assetId, @@ -47,6 +49,10 @@ export const AlertsSummaryContent = ({ }; const assetIdField = findInventoryFields(assetType).id; + const isDockerContainer = useIntegrationCheck({ dependsOn: INTEGRATIONS.docker }); + const showCreateRuleFeature = + featureFlags.inventoryThresholdAlertRuleEnabled && + (assetType !== 'container' || isDockerContainer); return ( <> @@ -59,7 +65,7 @@ export const AlertsSummaryContent = ({ initialTriggerValue={collapsibleStatus} extraAction={ - {featureFlags.inventoryThresholdAlertRuleEnabled && ( + {showCreateRuleFeature && ( } > - + - {featureFlags.inventoryThresholdAlertRuleEnabled && ( + {showCreateRuleFeature && ( { error: fetchMetadataError, } = useMetadataStateContext(); const { metrics } = useDataViewsContext(); - const isFullPageView = renderMode.mode === 'page'; const state = useIntersectingState(ref, { dateRange }); @@ -61,7 +60,7 @@ export const Overview = () => { {fetchMetadataError && !metadataLoading ? : metadataSummarySection} - {asset.type === 'host' ? ( + {asset.type === 'host' || asset.type === 'container' ? ( void; onRangeSelection?: HostsStateUpdater; + assetType?: InventoryItemType; } const alertFeatureIds = [...infraAlertFeatureIds, AlertConsumers.OBSERVABILITY]; @@ -33,6 +35,7 @@ export const AlertsOverview = ({ dateRange, onLoaded, onRangeSelection, + assetType, }: AlertsOverviewProps) => { const { services } = useKibanaContextForPlugin(); const [urlState, setUrlState] = useAssetDetailsUrlState(); @@ -56,8 +59,9 @@ export const AlertsOverview = ({ dateRange, assetIds: [assetId], status: alertStatus, + assetType, }), - [assetId, dateRange, alertStatus] + [dateRange, assetId, alertStatus, assetType] ); const alertsEsQuery = useMemo( @@ -66,8 +70,9 @@ export const AlertsOverview = ({ dateRange, assetIds: [assetId], status: ALERT_STATUS_ALL, + assetType, }), - [assetId, dateRange] + [assetId, assetType, dateRange] ); const summaryTimeRange = useSummaryTimeRange(dateRange); diff --git a/x-pack/plugins/observability_solution/infra/public/utils/filters/create_alerts_es_query.ts b/x-pack/plugins/observability_solution/infra/public/utils/filters/create_alerts_es_query.ts index e80ac2cdf9ac0..5184151619e67 100644 --- a/x-pack/plugins/observability_solution/infra/public/utils/filters/create_alerts_es_query.ts +++ b/x-pack/plugins/observability_solution/infra/public/utils/filters/create_alerts_es_query.ts @@ -8,7 +8,10 @@ import { getTime } from '@kbn/data-plugin/common'; import { ALERT_TIME_RANGE } from '@kbn/rule-data-utils'; import { BoolQuery, buildEsQuery, Filter, type TimeRange } from '@kbn/es-query'; import type { AlertStatus } from '@kbn/observability-plugin/common/typings'; -import { findInventoryFields } from '@kbn/metrics-data-access-plugin/common'; +import { + findInventoryFields, + type InventoryItemType, +} from '@kbn/metrics-data-access-plugin/common'; import { buildCombinedAssetFilter } from './build'; import { ALERT_STATUS_QUERY } from '../../components/shared/alerts/constants'; @@ -20,16 +23,18 @@ export const createAlertsEsQuery = ({ dateRange, assetIds, status, + assetType, }: { dateRange: TimeRange; assetIds: string[]; status?: AlertStatus; + assetType?: InventoryItemType; }): AlertsEsQuery => { const alertStatusFilter = createAlertStatusFilter(status); const dateFilter = createDateFilter(dateRange); const hostsFilter = buildCombinedAssetFilter({ - field: findInventoryFields('host').id, + field: findInventoryFields(assetType ?? 'host').id, values: assetIds, });