Anomaly Detection
Tags: opengauss
Published: 2023-04-14 08:32:37

**Overview**

The anomaly detection module implements time series data based on statistics methods to detect possible exceptions in the data. The framework of this module is decoupled to flexibly replace different anomaly detection algorithms. In addition, this module can automatically select algorithms based on different features of time series data. It supports anomaly value detection, threshold detection, box plot detection, gradient detection, growth rate detection, fluctuation rate detection, and status conversion detection.

**Usage Guide**
Assume that the metric collection system is running properly and the configuration file directory confpath has been initialized. You can run the following command to implement this feature:

Enable only the anomaly detection function:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pumu3acvomd23g2ko8lv.png)

View a metric on all nodes from timestamps1 to timestamps2:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nzjr98dn5emwf6r1bvxp.png)

View a metric on a specific node from timestamps1 to timestamps2:

gs_dbmind component anomaly_detection --conf confpath --action overview --metric metric_name --start-time timestamps1 --end-time timestamps2 --host ip_address --anomaly anomaly_type

View a metric on all nodes from timestamps1 to timestamps2 in a specific anomaly detection mode:

gs_dbmind component anomaly_detection --conf confpath --action overview --metric metric_name --start-time timestamps1 --end-time timestamps2 --anomaly anomaly_type

View a metric on a specific node from timestamps1 to timestamps2 in a specific anomaly detection mode:

gs_dbmind component anomaly_detection --conf confpath --action overview --metric metric_name --start-time timestamps1 --end-time timestamps2 --host ip_address --anomaly anomaly_type

Visualize a metric on all nodes from timestamps1 to timestamps2 in a specific anomaly detection mode:

gs_dbmind component anomaly_detection --conf confpath --action plot --metric metric_name --start-time timestamps1 --end-time timestamps2 --host ip_address --anomaly anomaly_type

Stop the started service:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sh754erqh34r3yl5ypxp.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lt09b6l2zlyu5ek37839.png)

**Obtaining Help Information**
You can run the **–help** command to obtain the help information. For example:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kx4k6durcu8a8yk4rmwn.png)

The following information is displayed:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/k1updfwlz3105gph5v9r.png)

**Command Reference**
Table 1 Command line parameters

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3kgwblmd71zalien0ukb.png)

**Troubleshooting**
**·** Overview scenario failure: Check whether the configuration file path is correct and whether the configuration file information is complete. Check whether the metric name is correct, whether the host IP address is correct, whether the anomaly detection type is correct, and whether the metric data exists in the start time and end time.
**·** Visualization scenario failure: Check whether the configuration file path is correct and whether the configuration file information is complete. Check whether the metric name is correct, whether the host IP address is correct, whether the anomaly detection type is correct, and whether the metric data exists in the start time and end time.