False data injection attacks change the control effect of automatic generation control systems, which may cause a destructive impact on power systems. In this paper, the data from the regular operation of a system and the data from false data injection attacks in the historical data are studied and classified. The normal operating parameters and abnormal operation parameters under various attack scenarios are collected as samples for training the detection model based on time series. The random forest algorithm model is selected for detection through the comparison of detection effects, and various data training models are accumulated during the operation process to improve the model’s accuracy. Finally, Simulink simulation experiments verify the consistency of the detection results of the simulated attack algorithm. This detection method can realize real-time attack detection and synchronize the detection results to the database with high timeliness. It can be used in systems with rich data samples and has broad applicability.