diff --git a/x-pack/plugins/observability_solution/slo/public/embeddable/slo/overview/group_view/slo_group_filters.tsx b/x-pack/plugins/observability_solution/slo/public/embeddable/slo/overview/group_view/slo_group_filters.tsx index 60f35ba810168..48b9df92c73a6 100644 --- a/x-pack/plugins/observability_solution/slo/public/embeddable/slo/overview/group_view/slo_group_filters.tsx +++ b/x-pack/plugins/observability_solution/slo/public/embeddable/slo/overview/group_view/slo_group_filters.tsx @@ -13,6 +13,8 @@ import { EuiFormRow, EuiComboBox, EuiSelect, EuiComboBoxOptionOption, EuiText } import { i18n } from '@kbn/i18n'; import { useFetchSloGroups } from '../../../../hooks/use_fetch_slo_groups'; +import { useGetSettings } from '../../../../pages/slo_settings/use_get_settings'; + import { SLI_OPTIONS } from '../../../../pages/slo_edit/constants'; import { useKibana } from '../../../../utils/kibana_react'; import { useCreateDataView } from '../../../../hooks/use_create_data_view'; @@ -24,27 +26,6 @@ interface Option { text: string; } -export const groupByOptions: Option[] = [ - { - text: i18n.translate('xpack.slo.sloGroupConfiguration.groupBy.tags', { - defaultMessage: 'Tags', - }), - value: 'slo.tags', - }, - { - text: i18n.translate('xpack.slo.sloGroupConfiguration.groupBy.status', { - defaultMessage: 'Status', - }), - value: 'status', - }, - { - text: i18n.translate('xpack.slo.sloGroupConfiguration.groupBy.sliType', { - defaultMessage: 'SLI type', - }), - value: 'slo.indicator.type', - }, -]; - interface Props { onSelected: (prop: string, value: string | Array | Filter[]) => void; selectedFilters: GroupFilters; @@ -70,6 +51,41 @@ export function SloGroupFilters({ selectedFilters, onSelected }: Props) { ui: { SearchBar }, }, } = useKibana().services; + const { data: settings } = useGetSettings(); + + const hasRemoteEnabled = + settings && (settings.useAllRemoteClusters || settings.selectedRemoteClusters.length > 0); + + const groupByOptions: Option[] = [ + { + text: i18n.translate('xpack.slo.sloGroupConfiguration.groupBy.tags', { + defaultMessage: 'Tags', + }), + value: 'slo.tags', + }, + { + text: i18n.translate('xpack.slo.sloGroupConfiguration.groupBy.status', { + defaultMessage: 'Status', + }), + value: 'status', + }, + { + text: i18n.translate('xpack.slo.sloGroupConfiguration.groupBy.sliType', { + defaultMessage: 'SLI type', + }), + value: 'slo.indicator.type', + }, + ...(hasRemoteEnabled + ? [ + { + text: i18n.translate('xpack.slo.sloGroupConfiguration.groupBy.remoteCluster', { + defaultMessage: 'Remote cluster', + }), + value: '_index', + }, + ] + : []), + ]; const { dataView } = useCreateDataView({ indexPatternString: SLO_SUMMARY_DESTINATION_INDEX_NAME, }); @@ -122,6 +138,12 @@ export function SloGroupFilters({ selectedFilters, onSelected }: Props) { defaultMessage: 'SLI type', }) ); + } else if (selectedGroupBy === '_index') { + setSelectedGroupByLabel( + i18n.translate('xpack.slo.sloGroupConfiguration.remoteClusterLabel', { + defaultMessage: 'Remote cluster', + }) + ); } }, [isLoading, data, selectedGroupBy]); diff --git a/x-pack/plugins/observability_solution/slo/public/pages/slos/components/grouped_slos/group_list_view.tsx b/x-pack/plugins/observability_solution/slo/public/pages/slos/components/grouped_slos/group_list_view.tsx index ba5f53f531e6a..92521823999f8 100644 --- a/x-pack/plugins/observability_solution/slo/public/pages/slos/components/grouped_slos/group_list_view.tsx +++ b/x-pack/plugins/observability_solution/slo/public/pages/slos/components/grouped_slos/group_list_view.tsx @@ -55,7 +55,7 @@ export function GroupListView({ filters, }: Props) { const groupQuery = `"${groupBy}": "${group}"`; - const query = kqlQuery ? `"${groupQuery}) and ${kqlQuery}` : groupQuery; + const query = kqlQuery ? `${groupQuery} and ${kqlQuery}` : groupQuery; let groupName = group.toLowerCase(); if (groupBy === 'slo.indicator.type') { groupName = SLI_OPTIONS.find((option) => option.value === group)?.text ?? group;