 This paper proposes a novel approach to detecting botnet attacks in IoT networks by combining three algorithms, exponential weighted moving average, EWMA, k-nearest neighbors, KNN, and cumulative sum algorithm, QZM. This combination of algorithms provides a more accurate detection of botnet attacks than existing approaches, resulting in a higher detection rate and lower false positive rates, FPRs. Additionally, the proposed approach utilizes fog computing to create an effective framework for implementing an anomaly mitigation strategy. The proposed module was tested on the bot IoT dataset and achieved a high accuracy, 99%, with a low FPR, 0.002%. This indicates that the proposed approach can be used to accurately identify botnet attacks in IoT networks. This article was authored by Rami J. Alzharani and Ahmed Alzharani.