In the modern era of digital transformation, the evolution of the fifth-generation (5G) wireless network 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. An IoT system based on cloud and fog computing is a highly efficacious solution but often faces concept drift challenges in real-time data processing, due to the dynamic and imbalanced nature of IoT environments, leading to performance degradation. In this study, we introduce a novel framework for drift-adaptive ensemble called the Adaptive Exponentially Weighted Average Ensemble (AEWAE), consisting of three stages: IoT data preprocessing, base model learning, and online ensembling. It integrates four advanced online learning methods with an ensemble approach. The crucial parameter of the AEWAE method is fine-tuned using the Hyperparameter Optimization (HPO) method. Experimental results on two public IoT datasets exhibit that AEWAE-based anomaly detection significantly detects concept drift and effectively identifies anomalies in imbalanced IoT data streams, compared with other baseline methods in terms of accuracy, F1 score, latency, and throughput.