Binary data with Telegraf

Hi

I want to use Telegraf with MQTT data. I have this mqtt topic “ice87/control/measure”
and the data sent to the MQTT server is packed like this
PAYLOAD=0x12
now = datetime.now().timestamp()
timespec_tv_sec = int( now )
timespec_tv_nsec = int((now - int(now))*100000000)
data = pack( “lli”, timespec_tv_sec, timespec_tv_nsec, PAYLOAD)
client.publish( TOPIC + “/mesure”, data … )

Is it possible to configure Telegraf to use such data to put in influxdb ?

Thanks
John

Probably.

However does that one byte represent one thing , or is it a vector of different flags/bits?

If the first, the take a look at the enum processor - telegraf/README.md at master · influxdata/telegraf · GitHub

1 Like

It is made of long/long/float
long/long for the time of the measure => should be the time of the measure in influxdb
float for the value of the measure

oh I thought this was code to send data into influx , not the the mqtt protocol generating data.

You should be able to just use this plugin instead.

Write your data into a temporary bucket first. Saves a lot of hassle if the data types for your columns are wrong to begin with - you can just blow away the bucket and recreate it again until your happy with what you’re getting inside influxdb

1 Like