Skip to content

Commit 9874c48

Browse files
authored
Add Suppression Anomaly Rules in Advanced Settings (opensearch-project#859)
This PR introduces suppression anomaly rules under the Advanced Settings section, enabling users to suppress anomalies based on the difference between expected and actual values, either as an absolute value or a relative percentage. Testing: * Added unit tests to verify the suppression rules functionality. * Conducted manual end-to-end (e2e) tests to validate the implementation. Signed-off-by: Kaituo Li <kaituo@amazon.com>
1 parent 3ed0058 commit 9874c48

File tree

25 files changed

+3901
-920
lines changed

25 files changed

+3901
-920
lines changed

.github/workflows/remote-integ-tests-workflow.yml

+1-4
Original file line numberDiff line numberDiff line change
@@ -151,10 +151,7 @@ jobs:
151151

152152
- name: Run spec files from output
153153
run: |
154-
for i in $FILELIST; do
155-
yarn cypress:run-without-security --browser electron --spec "${i}"
156-
sleep 60
157-
done
154+
env CYPRESS_NO_COMMAND_LOG=1 yarn cypress:run-without-security --browser chromium --spec 'cypress/integration/plugins/anomaly-detection-dashboards-plugin/*'
158155
working-directory: opensearch-dashboards-functional-test
159156

160157
- name: Capture failure screenshots

public/models/interfaces.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@ import { DETECTOR_STATE } from '../../server/utils/constants';
1515
import { Duration } from 'moment';
1616
import moment from 'moment';
1717
import { MDSQueryParams } from '../../server/models/types';
18-
import { ImputationOption } from './types';
18+
import {
19+
ImputationOption,
20+
Rule
21+
} from './types';
1922

2023
export type FieldInfo = {
2124
label: string;
@@ -212,6 +215,7 @@ export type Detector = {
212215
taskProgress?: number;
213216
taskError?: string;
214217
imputationOption?: ImputationOption;
218+
rules?: Rule[];
215219
};
216220

217221
export type DetectorListItem = {

public/models/types.ts

+84
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,87 @@ export enum ImputationMethod {
3333
PREVIOUS = 'PREVIOUS',
3434
}
3535

36+
// Constants for field names
37+
export const RULES_FIELD = "rules";
38+
export const ACTION_FIELD = "action";
39+
export const CONDITIONS_FIELD = "conditions";
40+
export const FEATURE_NAME_FIELD = "feature_name";
41+
export const THRESHOLD_TYPE_FIELD = "threshold_type";
42+
export const OPERATOR_FIELD = "operator";
43+
export const VALUE_FIELD = "value";
44+
45+
// Enums
46+
export enum Action {
47+
IGNORE_ANOMALY = "IGNORE_ANOMALY", // ignore anomaly if found
48+
}
49+
50+
export enum ThresholdType {
51+
/**
52+
* Specifies a threshold for ignoring anomalies where the actual value
53+
* exceeds the expected value by a certain margin.
54+
*
55+
* Assume a represents the actual value and b signifies the expected value.
56+
* IGNORE_SIMILAR_FROM_ABOVE implies the anomaly should be disregarded if a-b
57+
* is less than or equal to ignoreSimilarFromAbove.
58+
*/
59+
ACTUAL_OVER_EXPECTED_MARGIN = "ACTUAL_OVER_EXPECTED_MARGIN",
60+
61+
/**
62+
* Specifies a threshold for ignoring anomalies where the actual value
63+
* is below the expected value by a certain margin.
64+
*
65+
* Assume a represents the actual value and b signifies the expected value.
66+
* Likewise, IGNORE_SIMILAR_FROM_BELOW
67+
* implies the anomaly should be disregarded if b-a is less than or equal to
68+
* ignoreSimilarFromBelow.
69+
*/
70+
EXPECTED_OVER_ACTUAL_MARGIN = "EXPECTED_OVER_ACTUAL_MARGIN",
71+
72+
/**
73+
* Specifies a threshold for ignoring anomalies based on the ratio of
74+
* the difference to the actual value when the actual value exceeds
75+
* the expected value.
76+
*
77+
* Assume a represents the actual value and b signifies the expected value.
78+
* The variable IGNORE_NEAR_EXPECTED_FROM_ABOVE_BY_RATIO presumably implies the
79+
* anomaly should be disregarded if the ratio of the deviation from the actual
80+
* to the expected (a-b)/|a| is less than or equal to IGNORE_NEAR_EXPECTED_FROM_ABOVE_BY_RATIO.
81+
*/
82+
ACTUAL_OVER_EXPECTED_RATIO = "ACTUAL_OVER_EXPECTED_RATIO",
83+
84+
/**
85+
* Specifies a threshold for ignoring anomalies based on the ratio of
86+
* the difference to the actual value when the actual value is below
87+
* the expected value.
88+
*
89+
* Assume a represents the actual value and b signifies the expected value.
90+
* Likewise, IGNORE_NEAR_EXPECTED_FROM_BELOW_BY_RATIO appears to indicate that the anomaly
91+
* should be ignored if the ratio of the deviation from the expected to the actual
92+
* (b-a)/|a| is less than or equal to ignoreNearExpectedFromBelowByRatio.
93+
*/
94+
EXPECTED_OVER_ACTUAL_RATIO = "EXPECTED_OVER_ACTUAL_RATIO",
95+
}
96+
97+
// Method to get the description of ThresholdType
98+
export function getThresholdTypeDescription(thresholdType: ThresholdType): string {
99+
return thresholdType; // In TypeScript, the enum itself holds the description.
100+
}
101+
102+
// Enums for Operators
103+
export enum Operator {
104+
LTE = "LTE",
105+
}
106+
107+
// Interfaces for Rule and Condition
108+
export interface Rule {
109+
action: Action;
110+
conditions: Condition[];
111+
}
112+
113+
export interface Condition {
114+
featureName: string;
115+
thresholdType: ThresholdType;
116+
operator: Operator;
117+
value: number;
118+
}
119+

0 commit comments

Comments
 (0)