InfluxDB Cloud Native Collectors, Enterprise and Industrial IoT Examples - Part 1
By Jay Clifford / Sep 07, 2022 / Iot, InfluxDB
Learn how to deploy InfluxDB Cloud’s Native Collectors with Kepware and The Things Network.
Did you hear about the new feature that just dropped to InfluxDB Cloud? Native Collectors! Starting with MQTT.
There will be plenty of content to get you started with Native Collectors. So this blog series covers connecting two popular IoT-based platforms to InfluxDB Cloud using native Collectors. One Enterprise use case and one industrial use case.
A quick reminder:
In short, Native Collectors allow users to spin up subscribers for well-known industry protocols which allow you to connect, ingest, and parse data into InfluxDB. The first native protocol released is MQTT!
The plan is to connect The Things Network (Enterprise) and Kepware (Industrial) to the same InfluxDB Cloud instance. This should look a little like this:
The great thing about these two platforms is that they give us the opportunity to explore different features within Native Collectors. Below I have created a table outlining the features we will be covering:
There is a lot to cover in one blog post, so we shall split the content into a two-part series:
|Kepware (Part 1)||The Things Network (Part 2)|
Lots to do, so let’s rock and roll!
Kepware - industrial example
Kepware provides one of the largest connectivity suites for automation devices such as PLC’s easing the bridge between the OT (Operation Technology) and IT (Information Technology) world. In the past, we have used Telegraf or InfluxDB API to send data from Kepware to InfluxDB Cloud (Check out this post to learn more). Native MQTT gives us a third option.
In this example, we will use a sample Kepware server project which you can find here. I will also make use of HiveMQ’s Public MQTT Broker to save us from hosting our own broker in the cloud. I DO NOT RECOMMEND USING A PUBLIC BROKER FOR ANY PRODUCTION / SYSTEMS WITH SENSITIVE DATA.
Let’s start by configuring Kepware to talk to the HiveMQ broker:
- Open KepwareServerEX Configuration.
- Create a new IoT Gateway agent. Select MQTT Client from the dropdown.
- Update the URL to point to your broker address, and if required, change the topic name. Note Kepware also gives you the option to choose Wide format or Narrow Format. This allows you to define how many machine tags are sent within a single MQTT payload. In our case, we will select Wide.
- Next you will be asked to provide your username and password credentials to connect with the broker. You may also define a ClientID at this point. Once completed, click Finish.
- Next we will update our MQTT payload format to support line protocol. To do this, right-click your newly created agent and select properties.
- Navigate to Message. Select Advanced Template from the Message Format dropdown.
- Update the Template to our line protocol template. Click Ok.
|#each VALUES|kepware,factory='INSERT' |TAGNAME|=|VALUE| |TIMESTAMP||#unless @last||LINEFEED||/unless||/each|
- Select Apply and Ok. You may now add some server tags to your agent.
We have now completed the Kepware Server side setup for Native Cloud ingest. Let’s now move over to InfluxDB Cloud and set up our MQTT ingester:
- Navigate to Native Collectors and select Create Subscription.
- Let’s first start by connecting to the broker. Define a subscription name and optionally a description. Next, provide your hostname / IP and port. In my case, it’s this:
TCP Port: 1883
- We are going to skip Security details in this example as we are connecting to a public broker. We will come back to this step when connecting The Things Network broker.
- Next, define the topic we want to subscribe to. In this case, we only defined one level to our topic in Kepware. All MQTT wildcard topics are permitted here, and we will use them within our Things Network example.
- Next, select or create a new bucket as your write destination.
- Lastly, we will define Line Protocol as our Data format with a Timestamp precision of milliseconds.
- Select Save Subscription.
Top trick: If you select your newly created Native Collector and click the button in the far right corner called View Data, you will be able to open a notebook which contains a view of your MQTT payload data as well as any subscription error data.
There you have it! In this example, we have covered connecting Kepware to an MQTT broker and modifying the payload template to line protocol. We also configured our Native MQTT collector to connect to the broker and ingest the line protocol directly into the Kepware bucket. Let’s now move on to our Enterprise IoT example, The Things Network.
That’s Part 1 of the two-part blog series completed. Make sure to stay tuned for Part 2 where we will cover connecting The Things Network using Native Collectors. We are currently looking for community feedback to help improve the MQTT subscriber as well as ideas for new protocol types you would like to see. To continue the conversation, come join us on Slack and the forums. Share your thoughts, I look forward to seeing you there!