diff --git a/public/models/interfaces.ts b/public/models/interfaces.ts index 4fb6d75b..c10cf764 100644 --- a/public/models/interfaces.ts +++ b/public/models/interfaces.ts @@ -190,6 +190,7 @@ export type Detector = { resultIndexMinAge?: number; resultIndexMinSize?: number; resultIndexTtl?: number; + flattenCustomResultIndex?: boolean; filterQuery: { [key: string]: any }; featureAttributes: FeatureAttributes[]; windowDelay: { period: Schedule }; diff --git a/public/pages/DefineDetector/components/CustomResultIndex/CustomResultIndex.tsx b/public/pages/DefineDetector/components/CustomResultIndex/CustomResultIndex.tsx index f804ef30..e6874bc3 100644 --- a/public/pages/DefineDetector/components/CustomResultIndex/CustomResultIndex.tsx +++ b/public/pages/DefineDetector/components/CustomResultIndex/CustomResultIndex.tsx @@ -66,6 +66,16 @@ function CustomResultIndex(props: CustomResultIndexProps) { } },[customResultIndexConditionsEnabled]) + const hintTextStyle = { + color: '#69707d', + fontSize: '12px', + lineHeight: '16px', + fontWeight: 'normal', + fontFamily: 'Helvetica, sans-serif', + textAlign: 'left', + width: '400px', +}; + return ( ) : null} - - {enabled ? ( - - { - setCustomResultIndexConditionsEnabled(!customResultIndexConditionsEnabled); - }} - /> - - ) : null} )} + + + { enabled ? ( + + {({ field, form }: FieldProps) => ( + + + +

Flattening the custom result index will make it easier to query them on the dashboard. It also allows you to perform term aggregations on categorical fields.

+
+
+ )} +
) : null} +
+ + {enabled ? ( + + { + setCustomResultIndexConditionsEnabled(!customResultIndexConditionsEnabled); + }} + /> + + ) : null} + +
+ { (enabled && customResultIndexConditionsEnabled) ? ( { formikProps.setFieldTouched('resultIndexMinAge'); formikProps.setFieldTouched('resultIndexMinSize'); formikProps.setFieldTouched('resultIndexTtl'); + formikProps.setFieldTouched('flattenCustomResultIndex'); formikProps.validateForm().then((errors) => { if (isEmpty(errors)) { if (props.isEdit) { diff --git a/public/pages/DefineDetector/containers/__tests__/__snapshots__/DefineDetector.test.tsx.snap b/public/pages/DefineDetector/containers/__tests__/__snapshots__/DefineDetector.test.tsx.snap index 03db2f2e..411bc618 100644 --- a/public/pages/DefineDetector/containers/__tests__/__snapshots__/DefineDetector.test.tsx.snap +++ b/public/pages/DefineDetector/containers/__tests__/__snapshots__/DefineDetector.test.tsx.snap @@ -972,6 +972,16 @@ exports[` Full creating detector definition renders the compon +
+
+
+
@@ -1949,6 +1959,16 @@ exports[` empty creating detector definition renders the compo +
+
+
+
@@ -2959,6 +2979,16 @@ exports[` empty editing detector definition renders the compon +
+
+
+
diff --git a/public/pages/DefineDetector/models/interfaces.ts b/public/pages/DefineDetector/models/interfaces.ts index c13f5bcd..c10ac7cf 100644 --- a/public/pages/DefineDetector/models/interfaces.ts +++ b/public/pages/DefineDetector/models/interfaces.ts @@ -25,4 +25,5 @@ export interface DetectorDefinitionFormikValues { resultIndexMinAge?: number | string; resultIndexMinSize?: number | string; resultIndexTtl?:number | string; + flattenCustomResultIndex?: boolean; } diff --git a/public/pages/DefineDetector/utils/__tests__/helpers.test.tsx b/public/pages/DefineDetector/utils/__tests__/helpers.test.tsx index c461f2cc..e6385f7d 100644 --- a/public/pages/DefineDetector/utils/__tests__/helpers.test.tsx +++ b/public/pages/DefineDetector/utils/__tests__/helpers.test.tsx @@ -44,6 +44,7 @@ describe('detectorDefinitionToFormik', () => { resultIndexMinAge: randomDetector.resultIndexMinAge, resultIndexMinSize: randomDetector.resultIndexMinSize, resultIndexTtl: randomDetector.resultIndexTtl, + flattenCustomResultIndex: randomDetector.flattenCustomResultIndex, }); }); test('should return if detector does not have metadata', () => { @@ -64,6 +65,7 @@ describe('detectorDefinitionToFormik', () => { resultIndexMinAge: randomDetector.resultIndexMinAge, resultIndexMinSize: randomDetector.resultIndexMinSize, resultIndexTtl: randomDetector.resultIndexTtl, + flattenCustomResultIndex: randomDetector.flattenCustomResultIndex, }); }); test("upgrade old detector's filters to include filter type", () => { diff --git a/public/pages/DefineDetector/utils/constants.tsx b/public/pages/DefineDetector/utils/constants.tsx index 17ce70a9..d6ef4dff 100644 --- a/public/pages/DefineDetector/utils/constants.tsx +++ b/public/pages/DefineDetector/utils/constants.tsx @@ -47,4 +47,5 @@ export const INITIAL_DETECTOR_DEFINITION_VALUES: DetectorDefinitionFormikValues resultIndexMinAge: 7, resultIndexMinSize: 51200, resultIndexTtl: 60, + flattenCustomResultIndex: false, }; diff --git a/public/pages/DefineDetector/utils/helpers.ts b/public/pages/DefineDetector/utils/helpers.ts index ed3443b1..7ece3554 100644 --- a/public/pages/DefineDetector/utils/helpers.ts +++ b/public/pages/DefineDetector/utils/helpers.ts @@ -48,6 +48,7 @@ export function detectorDefinitionToFormik( resultIndexMinAge: get(ad, 'resultIndexMinAge', undefined), resultIndexMinSize:get(ad, 'resultIndexMinSize', undefined), resultIndexTtl: get(ad, 'resultIndexTtl', undefined), + flattenCustomResultIndex: get(ad, 'flattenCustomResultIndex', false), }; } @@ -125,6 +126,7 @@ export function formikToDetectorDefinition( resultIndexMinAge: values.resultIndexMinAge, resultIndexMinSize: values.resultIndexMinSize, resultIndexTtl: values.resultIndexTtl, + flattenCustomResultIndex: values.flattenCustomResultIndex, } as Detector; return detectorBody; diff --git a/public/pages/DetectorConfig/containers/__tests__/__snapshots__/DetectorConfig.test.tsx.snap b/public/pages/DetectorConfig/containers/__tests__/__snapshots__/DetectorConfig.test.tsx.snap index 98e4475c..ee2264d4 100644 --- a/public/pages/DetectorConfig/containers/__tests__/__snapshots__/DetectorConfig.test.tsx.snap +++ b/public/pages/DetectorConfig/containers/__tests__/__snapshots__/DetectorConfig.test.tsx.snap @@ -430,6 +430,40 @@ exports[` spec renders the component 1`] = ` +
+
+
+ +
+
+
+

+ Yes +

+
+
+
+
@@ -1706,6 +1740,40 @@ exports[` spec renders the component with 2 custom and 1 simpl
+
+
+
+ +
+
+
+

+ Yes +

+
+
+
+
diff --git a/public/pages/ReviewAndCreate/components/DetectorDefinitionFields/DetectorDefinitionFields.tsx b/public/pages/ReviewAndCreate/components/DetectorDefinitionFields/DetectorDefinitionFields.tsx index e4335116..f9b48772 100644 --- a/public/pages/ReviewAndCreate/components/DetectorDefinitionFields/DetectorDefinitionFields.tsx +++ b/public/pages/ReviewAndCreate/components/DetectorDefinitionFields/DetectorDefinitionFields.tsx @@ -137,7 +137,8 @@ export const DetectorDefinitionFields = ( const minSize = (minSizeValue === undefined) ? '-' : minSizeValue + " MB"; const ttlValue = get(props, 'detector.resultIndexTtl', undefined); const ttl = (ttlValue === undefined) ? '-' : ttlValue + " Days"; - + const flattenCustomResultIndex = get(props, 'detector.flattenCustomResultIndex', undefined); + const flatten = (flattenCustomResultIndex === undefined) ? '-' : flattenCustomResultIndex ? 'Yes' : 'No'; return ( + + + spec', () => { @@ -85,6 +86,7 @@ describe(' spec', () => { getByText('test-timefield'); getByText('1 Minutes'); getByText('opensearch-ad-plugin-result-test'); + getByText('Yes') getByText('7 Days'); getByText('51200 MB'); getByText('60 Days'); diff --git a/public/pages/ReviewAndCreate/components/__tests__/__snapshots__/DetectorDefinitionFields.test.tsx.snap b/public/pages/ReviewAndCreate/components/__tests__/__snapshots__/DetectorDefinitionFields.test.tsx.snap index 5597ffb1..2b6a4107 100644 --- a/public/pages/ReviewAndCreate/components/__tests__/__snapshots__/DetectorDefinitionFields.test.tsx.snap +++ b/public/pages/ReviewAndCreate/components/__tests__/__snapshots__/DetectorDefinitionFields.test.tsx.snap @@ -342,6 +342,40 @@ exports[` spec renders the component in create mode (no ID
+
+
+
+ +
+
+
+

+ Yes +

+
+
+
+
@@ -862,6 +896,40 @@ exports[` spec renders the component in edit mode (with ID
+
+
+
+ +
+
+
+

+ Yes +

+
+
+
+
diff --git a/public/pages/ReviewAndCreate/containers/__tests__/__snapshots__/ReviewAndCreate.test.tsx.snap b/public/pages/ReviewAndCreate/containers/__tests__/__snapshots__/ReviewAndCreate.test.tsx.snap index b723fc9b..f5dd0c1b 100644 --- a/public/pages/ReviewAndCreate/containers/__tests__/__snapshots__/ReviewAndCreate.test.tsx.snap +++ b/public/pages/ReviewAndCreate/containers/__tests__/__snapshots__/ReviewAndCreate.test.tsx.snap @@ -396,6 +396,40 @@ exports[` spec renders the component, validation loading 1`]
+
+
+
+ +
+
+
+

+ - +

+
+
+
+
@@ -1490,6 +1524,40 @@ exports[`issue in detector validation issues in feature query 1`] = `
+
+
+
+ +
+
+
+

+ - +

+
+
+
+
diff --git a/public/pages/ReviewAndCreate/utils/helpers.ts b/public/pages/ReviewAndCreate/utils/helpers.ts index eb0671d6..6f1a15bd 100644 --- a/public/pages/ReviewAndCreate/utils/helpers.ts +++ b/public/pages/ReviewAndCreate/utils/helpers.ts @@ -62,6 +62,7 @@ export function formikToDetector(values: CreateDetectorFormikValues): Detector { resultIndexMinAge: resultIndex && resultIndex.trim().length > 0 ? values.resultIndexMinAge : undefined, resultIndexMinSize: resultIndex && resultIndex.trim().length > 0 ? values.resultIndexMinSize : undefined, resultIndexTtl: resultIndex && resultIndex.trim().length > 0 ? values.resultIndexTtl : undefined, + flattenCustomResultIndex: resultIndex && resultIndex.trim().length > 0 ? values.flattenCustomResultIndex : undefined, } as Detector; // Optionally add detection date range diff --git a/public/redux/reducers/__tests__/utils.ts b/public/redux/reducers/__tests__/utils.ts index 1b5502cf..7ebe84ce 100644 --- a/public/redux/reducers/__tests__/utils.ts +++ b/public/redux/reducers/__tests__/utils.ts @@ -123,6 +123,7 @@ export const getRandomDetector = ( resultIndexMinAge: 7, resultIndexMinSize: 51200, resultIndexTtl: 60, + flattenCustomResultIndex: true, }; };