In the realm of cyber-physical systems, attackers pose a significant threat by exploiting vulnerabilities in the communication infrastructure between sensors, actuators, and control systems. This paper concerns early attack detection by using DBSCAN algorithm and determining the parameters of the DBSCAN algorithm automatically, with minimal system data in anomaly-free operation. The proposed semi-supervised algorithm involves determining two major parameters of DBSCAN. Then, the measurement residue is used to detect cyber attacks to the system through an online DBSCAN algorithm. The results demonstrate that the proposed method outperforms Kalman-based approach, indicating its potential for enhancing system security.