Use Case
Coreflux is a Strategic Partner of DigitalOcean. The integration of both companies' technologies is key to fast-forwarding the state of Industrial Digitalization around the globe.
João Schier is a Solutions Engineer at Coreflux. He prepared the following article for publication on DigitalOcean's website on September 2024. Here he is to tell you more:
With the increasing number of devices in tech, and today’s world being more data-driventhan ever before, we have to be able process billions of pieces of information at scale. AMQTT broker - Coreflux, paired with a scalable cloud platform like DigitalOcean can be theanswer to this problem of processing and analyzing IoT (Internet of Things) data.
In this guide, you will learn how to connect an MQTT broker with a managed OpenSearchservice on DigitalOcean. The end result of this is going to be a seamless setup that allowsfor real-time data collection and storage, making it easier to monitor, analyze, and visualizeyour IoT data.
DigitalOcean is a cloud infrastructure provider focused on delivering simplified, scalable computing solutions for developers, startups, and small to medium-sized businesses. Known for its user-friendly interface and transparent pricing, DigitalOcean offers a range of services, including virtual servers (Droplets), managed databases, object storage, and Kubernetes-based container orchestration.
With data centers worldwide, the platform provides reliable access and performance, allowing businesses to deploy, manage, and scale applications efficiently. DigitalOcean's emphasis on ease of use and affordability helps users focus on development and growth rather than managing cloud infrastructure.
Coreflux offers a lightweight MQTT broker designed to facilitate efficient, real-timecommunication between IoT devices and applications. Built for scalability and reliability,Coreflux is tailored for environments where low latency and high throughput are critical. Itsupports the MQTT (Message Queuing Telemetry Transport) protocol, which is widelyadopted in IoT ecosystems for its efficiency in bandwidth-constrained environments.
Whether you’re developing a small-scale IoT project or deploying a large-scale industrialmonitoring system, Coreflux provides the reliable messaging backbone needed to ensuresmooth data flow between devices.
Integrating Coreflux with DigitalOcean’s managed OpenSearch service offers numerousbenefits:
Before diving into the integration, make sure you have the following:
New to Python? Here’s a basic outline of what the Python script above does:
Ready to go? You can watch the Coreflux Tutorial on how to quickly start a Free Trial of theOnline MQTT Broker, and follow along this step-by-step guide:
Now that your Coreflux MQTT broker is set up and tested, it’s time to connect it to amanaged OpenSearch instance on DigitalOcean. Here’s how:
Before you start indexing data from your Coreflux MQTT broker into OpenSearch, you need to define the mapping for your index. Mapping is essentially the schema for your index, specifying the data types for each field in your documents. This step is crucial for ensuring that the data is stored correctly and can be searched effectively.
Here’s how to create and map an index in your OpenSearch instance:
{
"mappings": {
"properties": {
"timestamp": {
"type": "date"
},
"machine_id": {
"type": "keyword"
},
"temperature": {
"type": "float"
},
"status": {
"type": "keyword"
},
"error_code": {
"type": "integer"
}
}
}
}
{
"timestamp": "2024-08-23T10:30:00Z",
"machine_id": "MACHINE123",
"temperature": 75.5,
"status": "operational",
"error_code": 0
}
With both Coreflux and OpenSearch set up, it’s time to link them together using a Python script. This script will connect to the Coreflux broker, process published messages, and store them in OpenSearch.
MQTT_BROKER=your-coreflux-broker-url
MQTT_PORT=1883
MQTT_USERNAME=your-coreflux-username
MQTT_PASSWORD=your-coreflux-password
OPENSEARCH_HOST=your-opensearch-host
OPENSEARCH_USERNAME=your-opensearch-username
OPENSEARCH_PASSWORD=your-opensearch-password
pip install paho-mqtt opensearch-py python-dotenv
You can check here on how to get started with OpenSearch on DigitalOcean.
Get a free trial of the Coreflux Online MQTT Broker or learn more with the Coreflux Docs and Tutorials.
Coreflux is on a mission to #democratizeIIoT and empower each human being to extract the maximum potential from the technology they use in their industry.
Visit coreflux.org to power-up your IIoT project.