Wireless Sensor Networks (WSNs) are increasingly the technology of choice due to their wide applicability in both military and civilian domains. The selective forwarding attack, one of the main attacks in WSNs, is the hardest denial-of- service attack to detect. The hostile nodes that initiate the selective forwarding attack will discard some or all of the data packets they receive. Numerous detection techniques for optional forwarding have been developed attacks are inaccurate or contain sophisticated algorithms, which is especially true when the attacker also uses other attacks like distributed denial of service, wormholes, and black holes to move through the network. To address these disadvantages, this research proposes a novel selective forwarding attack detection method based blue monkey-optimized ghost net (SAD-Ghost) method. To identify network threats, Blue Monkey optimization based on the hazard model is built in this case. A proposed technique to improve detection accuracy and minimize computation. The primary goal of the research is to develop a Selective Forwarding Attack Detection utilizing a blue Monkey optimized Ghost net to improve network lifetime. Initially, Blue Monkey optimization is used for optimal cluster head selection based on node degree and density. Moreover, cluster data are pre-processed using Tokenization, Normalization, and Reduction. The proposed method is utilized to detect intrusion in WSN and classify Normal, DDOS, Grey hole, and Blink litter. The experimental analysis demonstrates that the proposed method achieves a packet delivery rate of 97.6%, 95.3% and 90.50% and reduces energy consumption by 19.6%, 12.5% and 17.4% compared to existing clustering-based routing methods. Consequently, the proposed technique surpasses current methods in terms of network lifetime, energy efficiency, and packet delivery performance.