Skip to content

Commit 3d8b449

Browse files
Merge branch '2.x' into revert2x
Signed-off-by: Jackie Han <jkhanjob@gmail.com>
2 parents f428c8e + 56b45b2 commit 3d8b449

File tree

25 files changed

+3902
-921
lines changed

25 files changed

+3902
-921
lines changed

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

+1-4
Original file line numberDiff line numberDiff line change
@@ -149,10 +149,7 @@ jobs:
149149

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

158155
- 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;
@@ -211,6 +214,7 @@ export type Detector = {
211214
taskProgress?: number;
212215
taskError?: string;
213216
imputationOption?: ImputationOption;
217+
rules?: Rule[];
214218
};
215219

216220
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)