Hi Grant, thank you for your reply.
I think you’re directing me to the influxdb webpage, but unfortunately that doesn’t work on a Raspberry Pi running the still advised 32-bit operating system, so I can’t use that for any level of transparency.
I’ll probably have to post up here or some place what I have - config file wise so that people can point me out the error of my ways.
Until I’m in a position to do this, what I can do right now, is explain what I’m trying to do…
I’ve written a Python 3 script which takes in a bunch of variables independently of one another. They are all floats.
I’m of the understanding that they need to be converted into JSON for transmitting to Telegraf, so I do this. When i look at the “type” of the variable after conversion using this command within Python:
convertedfloatvariable = json.dumps(floatvariablename) - they display as <class ‘str’>. The first thing I have a question about is this. Is this correct? Is a JSON variable a string?
Then I’m MQTT publishing the converted JSON variable with an attached TOPIC name out of Python and on to my home network.
Here is an example of one of a complete command for this (I’ve chosen my outside temperature variable to demonstrate here):
topic chosen is ‘HMI/Outside/Temperature’ (This is a string format)
Outside Temperature variable name is ‘OS_Temp’ (This is in JSON format - shows up as “str”)
command written in Python as an example based on the above insertions:
client.publish(topic, OS_Temp, 0)
I know that this is going out because I can subscribe to this topic on my mobile phone using the MQTTool app.
This is where it gets tricky for me because depending on the changes I make to my Telegraf config file (found here on my Raspberry Pi: /etc/telegraf/telegraf.conf) I get different results.
I’ve had the following results:
(1)
[inputs.mqtt_consumer] Error in plugin: metric parse error: expected tag at 1:4: “9.6” (where 9.6 was actually the value I was sending to Telegraf on MQTT)
[outputs.influxdb] Buffer fullness: 0 / 10000 metrics
(2)
[outputs.influxdb] Wrote batch of 1 metrics in 17.743206ms
[outputs.influxdb] Buffer fullness: 0 / 10000 metrics
(3)
I dont have a photograph of this one, but I’ve also had a result where only 1 line is given, which I think was the same as the second line from (1) & (2), but not a first line. It was just silent.
I’ve done that much faffing over weeks and weeks that I’ve had some resemblance of “success” when i look at Influxdb because when I query it with the commands I get some results which look familiar sometimes, but I don’t understand them really:
use homevars (this is the name of my database)
show series
key
mqtt_consumer,HMI=HMI/OS_Temp,host=raspberrypi,influxdb_database=homevars,password=password,username=username
mqtt_consumer,HMI/Outside/Temperature=HMI/Outside/Temperature,host=chrispi
mqtt_consumer,host=chrispi,topic=HMI/Outside/Temperature
etc etc
show measurements
name: measurements
name
mqtt_consumer
tagkey
HMI
HMI/Outside/Temperature
host
influxdb_database
password
topic
username
show field keys
name: mqtt_consumer
fieldKey fieldType
value float
To me, all of this is a bit of jumble, and I’m not sure exactly at what point each of these entities (is entities an acceptable descriptor when you don’t know what you’re talking about?) was created and stored within influxdb.
The only other things I can tell right now, are some of the commands I have set in my Telegraf config file (from some photos on my phone here, so not a complete or exhaustive list by any means)
urls = [“http://127.0.0.1:8086”] (I believe this is the description of my Influxdb instance)
database = “homevars” (this is what I have called my database, which I first created within Influxdb - rightly or wrongly)
I’ve been using these here as these have been providing me the most positive results in the live telegraf logs when i watch them. I’d have expected to have used “json” for data_type but it doesn’t like that at all!?
data_type = “float”
data_format = “value”
precision = “”
debug = true
quiet = false
[inputs.mqtt_consumer]]
servers = [“tcp://192.168.0.51:1883”] (This is my MQTT broker address)
topics = [“HMI/Outside/Temperature”]
I’ve configured nothing in influxdb config file, and the only thing I ever see within Grafana is a reference to “mqtt_consumer” and “value”.
I can of course copy and paste my complete Telegraf config file when I get home from work to show you it complete.
I REALLY need help with this. I don’t have long enough to live to continue to try and fumble about in the dark trying to figure this out by myself. I’ve proven that fact to myself over the past month or so.
Can you help?