diff --git a/x-pack/plugins/observability/public/pages/slo_edit/components/common/index_field_selector.tsx b/x-pack/plugins/observability/public/pages/slo_edit/components/common/index_field_selector.tsx
index 6bb6996f95b2a..ef9121e871bbd 100644
--- a/x-pack/plugins/observability/public/pages/slo_edit/components/common/index_field_selector.tsx
+++ b/x-pack/plugins/observability/public/pages/slo_edit/components/common/index_field_selector.tsx
@@ -6,7 +6,6 @@
*/
import { EuiComboBox, EuiComboBoxOptionOption, EuiFlexItem, EuiFormRow } from '@elastic/eui';
-import { ALL_VALUE } from '@kbn/slo-schema';
import React, { useEffect, useState } from 'react';
import { Controller, useFormContext } from 'react-hook-form';
import { Field } from '../../../../hooks/slo/use_fetch_index_pattern_fields';
@@ -42,7 +41,7 @@ export function IndexFieldSelector({
{
diff --git a/x-pack/plugins/observability/public/pages/slo_edit/components/custom_metric/custom_metric_type_form.tsx b/x-pack/plugins/observability/public/pages/slo_edit/components/custom_metric/custom_metric_type_form.tsx
index c7fe7999f9be4..45870dcd68bd0 100644
--- a/x-pack/plugins/observability/public/pages/slo_edit/components/custom_metric/custom_metric_type_form.tsx
+++ b/x-pack/plugins/observability/public/pages/slo_edit/components/custom_metric/custom_metric_type_form.tsx
@@ -27,6 +27,8 @@ import { MetricIndicator } from './metric_indicator';
export { NEW_CUSTOM_METRIC } from './metric_indicator';
+const SUPPORTED_METRIC_FIELD_TYPES = ['number', 'histogram'];
+
export function CustomMetricIndicatorTypeForm() {
const { watch } = useFormContext();
const index = watch('indicator.params.index');
@@ -34,6 +36,9 @@ export function CustomMetricIndicatorTypeForm() {
useFetchIndexPatternFields(index);
const timestampFields = indexFields.filter((field) => field.type === 'date');
const partitionByFields = indexFields.filter((field) => field.aggregatable);
+ const metricFields = indexFields.filter((field) =>
+ SUPPORTED_METRIC_FIELD_TYPES.includes(field.type)
+ );
return (
<>
@@ -115,7 +120,7 @@ export function CustomMetricIndicatorTypeForm() {
@@ -136,7 +141,7 @@ export function CustomMetricIndicatorTypeForm() {
diff --git a/x-pack/plugins/observability/public/pages/slo_edit/components/custom_metric/metric_indicator.tsx b/x-pack/plugins/observability/public/pages/slo_edit/components/custom_metric/metric_indicator.tsx
index a333a353f97d9..0c1fbce49d64e 100644
--- a/x-pack/plugins/observability/public/pages/slo_edit/components/custom_metric/metric_indicator.tsx
+++ b/x-pack/plugins/observability/public/pages/slo_edit/components/custom_metric/metric_indicator.tsx
@@ -19,16 +19,16 @@ import {
import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n-react';
import { first, range, xor } from 'lodash';
-import React from 'react';
+import React, { useEffect, useState } from 'react';
import { Controller, useFieldArray, useFormContext } from 'react-hook-form';
import { Field } from '../../../../hooks/slo/use_fetch_index_pattern_fields';
-import { createOptionsFromFields } from '../../helpers/create_options';
+import { createOptionsFromFields, Option } from '../../helpers/create_options';
import { CreateSLOForm } from '../../types';
import { QueryBuilder } from '../common/query_builder';
interface MetricIndicatorProps {
type: 'good' | 'total';
- indexFields: Field[];
+ metricFields: Field[];
isLoadingIndex: boolean;
}
@@ -47,51 +47,52 @@ function createEquationFromMetric(names: string[]) {
return names.join(' + ');
}
-const SUPPORTED_FIELD_TYPES = ['number', 'histogram'];
+const metricLabel = i18n.translate(
+ 'xpack.observability.slo.sloEdit.sliType.customMetric.metricLabel',
+ { defaultMessage: 'Metric' }
+);
-export function MetricIndicator({ type, indexFields, isLoadingIndex }: MetricIndicatorProps) {
- const metricLabel = i18n.translate(
- 'xpack.observability.slo.sloEdit.sliType.customMetric.metricLabel',
- { defaultMessage: 'Metric' }
- );
+const filterLabel = i18n.translate(
+ 'xpack.observability.slo.sloEdit.sliType.customMetric.filterLabel',
+ { defaultMessage: 'Filter' }
+);
- const filterLabel = i18n.translate(
- 'xpack.observability.slo.sloEdit.sliType.customMetric.filterLabel',
- { defaultMessage: 'Filter' }
- );
+const metricTooltip = (
+
+);
- const metricTooltip = (
-
- );
+const equationLabel = i18n.translate(
+ 'xpack.observability.slo.sloEdit.sliType.customMetric.equationLabel',
+ { defaultMessage: 'Equation' }
+);
- const equationLabel = i18n.translate(
- 'xpack.observability.slo.sloEdit.sliType.customMetric.equationLabel',
- { defaultMessage: 'Equation' }
- );
+const equationTooltip = (
+
+);
- const equationTooltip = (
-
- );
+export function MetricIndicator({ type, metricFields, isLoadingIndex }: MetricIndicatorProps) {
+ const { control, watch, setValue, register, getFieldState } = useFormContext();
+ const [options, setOptions] = useState