Getting Data from EMQX Cloud with InfluxDB Native Collector

Introduction

Four steps integration

  1. Create an MQTT broker on EMQX Cloud — 3 mins
  2. Create a bucket on InfluxDB Cloud — 3 mins
  3. Config the native collector — 2 mins
  4. Verification — 1 min

Step 1: Create an MQTT broker on EMQX Cloud

Get an account

Create an MQTT cluster

Create an MQTT instance on EMQX Cloud
This tutorial uses Standard Plan
Creating MQTT instance
Instance in running status

Get Connection Adress and Port

MQTT Broker Connection Details

Add Credentials for MQTT connection

Authentication Page
Add Credentials

Step 2: Create a bucket on InfluxDB Cloud

Create an InfluxDB Cloud account

Create a Bucket for data persistence

Go to the Buckets page
Create a new bucket

Step 3: Config the native collector

Go to the Native Subscriptions page

Go to the native subscriptions page

Create a Subscription

Create an MQTT subscription
  • Config Broker Details
  • Config Security Details
  • Subscribe to a Topic
  • Set write destination
  • Define data parsing rules.

Config Broker Connection

Config Broker Details
  1. Subscription Name: Name your subscription as desired. I use ‘EMQX’ in this example.
  2. Description: (Optional) Give this subscription a short description.
  3. Hostname or IP Address: The connect address you got from EMQX Cloud in Step 1.
  4. Port: The connect port you got from EMQX Cloud in Step 1.

Config Security Details

Add credentials for the MQTT connection

Subscribe to a Topic

Add a subscription topic

Set Write Destination

Select the write destination bucket

Define Data Parsing Rules

Define a data parsing rule
{
"temperature":25
}

TIMESTAMP:

MEASUREMENT:

FIELD:

Save Subscription

Save the subscription

Verify the subscription is running

Native subscription is running

Everything is settled

Step 4: Verification

Choose an MQTT client

Create New Connection

Connect to EMQX Cloud

Set Connection Details
  1. Name: The connection name. Use whatever name you want.
  2. Host: The MQTT broker connection address. Same as you used in InfluxDB Cloud setup.
  3. Port: MQTT broker connection port. Same as you used in InfluxDB Cloud setup.
  4. Username/Password: In the demo, I use the same credentials as in InfluxDB Cloud Configuration. You can add new credentials in EMQX Cloud if you want.

Send messages to EMQX Cloud

Send messages to EMQX Cloud
  1. Set payload format to “JSON”.
  2. Set the topic: influxdb (the topic of the InfluxDB subscription we just set up)
  3. JSON body:
{"temperature": 25}

Check the data on InfluxDB Cloud

Go to Data Explorer
Make a Query to Fetch the Data

Summary

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
EMQ Technologies

EMQ is an open-source IoT data infrastructure software provider, delivering the world’s leading open-source MQTT message broker and stream processing database.