Getting data into influx from a new C++ application

Hi all,

I’ve been using telegraf and influx to gather data from logfiles for a long time.
I am now creating a new C++ application for an IoT device with little storage capacity, so would like to get my data directly into influx without parsing log files. It could be directly or via telegraf if needed.

Are there plugins or libraries available for C++ to help me do this? I could not find any, but I would have thought that it would be a common use case. Perhaps a logging library exists that supports influx as standard?

Any help would will be much appreciated.

Craig

Hi @Craig_LD,

Given your requirements of C++ and trying to use as little space as possible, my suggestion would be to write the log parser in C++ and connect directly from the IoT device to InfluxDB.

You can use whatever libraries you can find to parse the dataformat of the logs or do it yourself in your app. To send the data to InfluxDB you can either make HTTP requests directly against the server or use a library like influxdb-cxx.

If you aren’t already familiar with line protocol, I would suggest reading up on that as well as that is the format of the data you would want to send to InfluxDB if you decide to do it with direct HTTP requests.

Hope that helps!

Are we talking about anything common e.g. based on Arduino, PlatformIO, ESP32…?

As has been mentioned, line protocol is the data interface you can use and it is text-based and simple to implement.
I would like to add that if you feel adding HTTP communication or influxdb-cxx to your project is too complicated, you could also use a simple UDP or TCP connection to Telegraf to send line protocol content:
Use telegraf/plugins/inputs/socket_listener in combination with telegraf/plugins/outputs/influxdb_v2

1 Like

Thanks all for your help.

@Franky1 I aim to be platform agnostic

Using the HTTP, TCP or UDP connections are all possible for me to do, but I expect that influxdb-cxx is going to provide what I need.
I don’t know if that library is robust to network outages but if not, I could extend it.

Thanks again!

Yes, but it depends on curl and boost libraries, which is a bit against:

That’s why I asked about the platform. If it’s only about linux os devices, then ok.

Thanks for this info, that’s very good to know before I start!

At a glance, it seems to offer similar functionality to the Arduino client library, so I wonder why it has these dependencies?