In the modern era of digital transformation, the evolution of fifth-generation (5G) wireless networks has played a pivotal role in revolutionizing communication technology and accelerating the growth of smart technology applications. As an integral element of smart technology, the Internet of Things (IoT) grapples with the problem of limited hardware performance. Cloud and fog computing-based IoT systems offer an effective solution but often encounter concept drift issues in real-time data processing due to the dynamic and imbalanced nature of IoT environments, leading to performance degradation. In this study, we propose a novel framework for drift- adaptive ensemble learning called the Adaptive Exponentially Weighted Average Ensemble (AEWAE), which consists of three stages: IoT data preprocessing, base model learning, and online ensembling. It integrates four advanced online learning methods within an ensemble approach. The crucial parameter of the AEWAE method is fine-tuned using the Particle Swarm Optimization (PSO) technique. Experimental results on four public datasets demonstrate that AEWAE-based anomaly detection effectively detects concept drift and identifies anomalies in imbalanced IoT data streams, outperforming other baseline methods in terms of accuracy, F1 score, false alarm rate (FAR), and latency.