Anomaly Detection
Tags: opengauss
Published: 2023-04-13 07:18:46

**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/ldzk8dpvbu423mn2uw6d.png)

View a metric on all nodes from timestamps1 to timestamps2:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qheaetx0j4gq47j62dfo.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/7h6noa7zw1jh1c362cze.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/li1khvxp934cmgp0pzr0.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/8uuqehxcrzkajt2m0m1z.png)

The following information is displayed:

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

**Command Reference**
Table 1 Command line parameters

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/i0eyz2wz0xv3qp57r2pq.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.