In Indonesia, adopting the Internet of Things (IoT) platform, which employs the Message Queuing Telemetry Transport (MQTT) protocol as a communication system, is growing. Most IoT systems lack adequate security mechanisms, and MQTT is vulnerable to various attack scenarios. Despite these security mechanisms being inefficient for low-power devices, MQTT's standard security is SSL/TLS. DoS attacks, which are a sort of MQTT protocol attack, have the potential to damage the entire IoT infrastructure. This attack can cause serious effects, such as data transmission interruptions, server inaccessibility, and tool monitoring in realtime. Based on data from attacks on IoT systems in Indonesian oil services organizations and data from prior studies, this research aims to find the most accurate machine learning system. This method assumes that a stack of machine learning algorithms can efficiently detect DoS attacks. According to the findings, the stacked ensemble approach has a 99.6489 percent accuracy rate in identifying attacks. We present a systematic approach for detecting attacks on IoT platforms in this study. This paper's approach is intended to serve as a standard for detecting DoS in MQTT-based IoT systems.