Abstract:Time series anomaly detection plays an important role in many real-world applications, such as monitoring key metrics (e.g., CPU and memory usage) in cloud-native database systems to detect system failures timely. Although many advanced time series anomaly detection algorithms have been proposed in recent years, it has been shown that different algorithms excel in different application scenarios in terms of anomaly detection accuracy, and there is no universally optimal method. Therefore, studying the problem of automatically selecting the most suitable time series anomaly detection algorithm based on the data characteristics of various scenarios is crucial to achieving higher detection accuracy. Existing studies typically address this problem using time series classification (TSC) techniques, training a classifier on data from historical tasks, where the input is a time series, and the output is the predicted most accurate anomaly detection algorithm for that time series. Although TSC-based solutions improve detection accuracy, existing standard TSC algorithms fail to fully utilize the knowledge from historical anomaly detection tasks. This study proposes a knowledge-enhanced time series anomaly detection framework. Specifically, in addition to training the TSC model with hard labels that represent the best detection algorithm for each historical time series, the accuracy of all candidate algorithms evaluated on historical data is used to estimate the class distribution of the input time series. The distribution is treated as a soft label, providing the algorithm selector (i.e., the TSC model) with more knowledge about the relationships between the anomaly detection algorithms. Meanwhile, a module is designed to flexibly integrate various types of external knowledge (e.g., descriptions of the domain, characteristics of time series, and anomalies) into the TSC model. The proposed method is designed as a plugin that can be seamlessly integrated into any TSC model to enhance its performance in anomaly detection algorithm selection, regardless of the model architecture. Extensive experiments on various types of time series datasets validate the effectiveness of this approach.