Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport 2.x] Add ignore rules comparing actual and expected values #860

Merged
merged 1 commit into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions .github/workflows/remote-integ-tests-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,7 @@ jobs:

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

- name: Capture failure screenshots
Expand Down
6 changes: 5 additions & 1 deletion public/models/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ import { DETECTOR_STATE } from '../../server/utils/constants';
import { Duration } from 'moment';
import moment from 'moment';
import { MDSQueryParams } from '../../server/models/types';
import { ImputationOption } from './types';
import {
ImputationOption,
Rule
} from './types';

export type FieldInfo = {
label: string;
Expand Down Expand Up @@ -212,6 +215,7 @@ export type Detector = {
taskProgress?: number;
taskError?: string;
imputationOption?: ImputationOption;
rules?: Rule[];
};

export type DetectorListItem = {
Expand Down
84 changes: 84 additions & 0 deletions public/models/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,87 @@ export enum ImputationMethod {
PREVIOUS = 'PREVIOUS',
}

// Constants for field names
export const RULES_FIELD = "rules";
export const ACTION_FIELD = "action";
export const CONDITIONS_FIELD = "conditions";
export const FEATURE_NAME_FIELD = "feature_name";
export const THRESHOLD_TYPE_FIELD = "threshold_type";
export const OPERATOR_FIELD = "operator";
export const VALUE_FIELD = "value";

// Enums
export enum Action {
IGNORE_ANOMALY = "IGNORE_ANOMALY", // ignore anomaly if found
}

export enum ThresholdType {
/**
* Specifies a threshold for ignoring anomalies where the actual value
* exceeds the expected value by a certain margin.
*
* Assume a represents the actual value and b signifies the expected value.
* IGNORE_SIMILAR_FROM_ABOVE implies the anomaly should be disregarded if a-b
* is less than or equal to ignoreSimilarFromAbove.
*/
ACTUAL_OVER_EXPECTED_MARGIN = "ACTUAL_OVER_EXPECTED_MARGIN",

/**
* Specifies a threshold for ignoring anomalies where the actual value
* is below the expected value by a certain margin.
*
* Assume a represents the actual value and b signifies the expected value.
* Likewise, IGNORE_SIMILAR_FROM_BELOW
* implies the anomaly should be disregarded if b-a is less than or equal to
* ignoreSimilarFromBelow.
*/
EXPECTED_OVER_ACTUAL_MARGIN = "EXPECTED_OVER_ACTUAL_MARGIN",

/**
* Specifies a threshold for ignoring anomalies based on the ratio of
* the difference to the actual value when the actual value exceeds
* the expected value.
*
* Assume a represents the actual value and b signifies the expected value.
* The variable IGNORE_NEAR_EXPECTED_FROM_ABOVE_BY_RATIO presumably implies the
* anomaly should be disregarded if the ratio of the deviation from the actual
* to the expected (a-b)/|a| is less than or equal to IGNORE_NEAR_EXPECTED_FROM_ABOVE_BY_RATIO.
*/
ACTUAL_OVER_EXPECTED_RATIO = "ACTUAL_OVER_EXPECTED_RATIO",

/**
* Specifies a threshold for ignoring anomalies based on the ratio of
* the difference to the actual value when the actual value is below
* the expected value.
*
* Assume a represents the actual value and b signifies the expected value.
* Likewise, IGNORE_NEAR_EXPECTED_FROM_BELOW_BY_RATIO appears to indicate that the anomaly
* should be ignored if the ratio of the deviation from the expected to the actual
* (b-a)/|a| is less than or equal to ignoreNearExpectedFromBelowByRatio.
*/
EXPECTED_OVER_ACTUAL_RATIO = "EXPECTED_OVER_ACTUAL_RATIO",
}

// Method to get the description of ThresholdType
export function getThresholdTypeDescription(thresholdType: ThresholdType): string {
return thresholdType; // In TypeScript, the enum itself holds the description.
}

// Enums for Operators
export enum Operator {
LTE = "LTE",
}

// Interfaces for Rule and Condition
export interface Rule {
action: Action;
conditions: Condition[];
}

export interface Condition {
featureName: string;
thresholdType: ThresholdType;
operator: Operator;
value: number;
}

Loading
Loading