diff --git a/src/plugins/discover/public/application/view_alert/view_alert_route.tsx b/src/plugins/discover/public/application/view_alert/view_alert_route.tsx index 8b0908b487bd2..fc6a674f8d823 100644 --- a/src/plugins/discover/public/application/view_alert/view_alert_route.tsx +++ b/src/plugins/discover/public/application/view_alert/view_alert_route.tsx @@ -21,20 +21,21 @@ type NonNullableEntry = { [K in keyof T]: NonNullable }; const getDataViewParamsChecksum = (dataViewSpec: DataViewSpec) => { const { title, timeFieldName, sourceFilters, runtimeFieldMap } = dataViewSpec; - return sha256 - .create() - .update(JSON.stringify({ title, timeFieldName, sourceFilters, runtimeFieldMap })) - .hex(); + const orderedParams = Object.values({ title, timeFieldName, sourceFilters, runtimeFieldMap }); + return sha256.create().update(JSON.stringify(orderedParams)).hex(); }; /** * Get rule params checksum skipping serialized data view object */ const getRuleParamsChecksum = (params: SearchThresholdAlertParams) => { + const orderedParams = Object.values(params); return sha256 .create() .update( - JSON.stringify(params, (key: string, value: string) => (key === 'index' ? undefined : value)) + JSON.stringify(orderedParams, (key: string, value: string) => + key === 'index' ? undefined : value + ) ) .hex(); }; diff --git a/x-pack/plugins/stack_alerts/server/rule_types/es_query/lib/fetch_search_source_query.ts b/x-pack/plugins/stack_alerts/server/rule_types/es_query/lib/fetch_search_source_query.ts index 494037c07bdae..f7c8323ca0899 100644 --- a/x-pack/plugins/stack_alerts/server/rule_types/es_query/lib/fetch_search_source_query.ts +++ b/x-pack/plugins/stack_alerts/server/rule_types/es_query/lib/fetch_search_source_query.ts @@ -110,20 +110,21 @@ function isTimeBasedDataView(index?: DataView) { function getDataViewChecksum(index: DataViewSpec) { const { title, timeFieldName, sourceFilters, runtimeFieldMap } = index; - return sha256 - .create() - .update(JSON.stringify({ title, timeFieldName, sourceFilters, runtimeFieldMap })) - .hex(); + const orderedParams = Object.values({ title, timeFieldName, sourceFilters, runtimeFieldMap }); + return sha256.create().update(JSON.stringify(orderedParams)).hex(); } /** * Get rule params checksum skipping serialized data view object */ function getRuleParamsChecksum(params: OnlySearchSourceRuleParams) { + const orderedParams = Object.values(params); return sha256 .create() .update( - JSON.stringify(params, (key: string, value: string) => (key === 'index' ? undefined : value)) + JSON.stringify(orderedParams, (key: string, value: string) => + key === 'index' ? undefined : value + ) ) .hex(); }