In order to effectively detect and discover network threats in the initial stage, this study proposes an electricity network security intrusion detection method based on feature selection. A heuristic feature selection algorithm based on the bee colony algorithm is proposed to overcome the shortcomings of existing feature evaluation methods. The algorithm uses average mutual information to measure the importance of features and more truly reflects the relationship between the selected features, the selected features, and the classification labels. Aiming at the problem that the algorithm is easy to fall into local optimization, a heuristic random search algorithm is proposed, which iteratively optimizes to generate smaller feature subsets, and improves the speed and accuracy of intrusion detection. The experimental results show that compared with the traditional algorithm, the proposed method can effectively evaluate the risk of attack path on the selected experimental data set, and the gap between the generation strategy and the optimal strategy is reduced by 71.3%, which enhances the practicability of the attack graph analysis method in a large-scale network environment. Conclusion. This method has good scalability and can be applied to large-scale network environments. It can effectively obtain attack paths that are more in line with the real threat situation in an acceptable time, so as to effectively find the network threats.