Sonoff mqtt json parsing to influxdb

I am new to telegraf and json and I know this is easy but I was having difficulty figuring it out. I tried searching and it seems it is just too simple and I am not sure what I am missing (just experience with these systems). I have a sensor that is outputting json strings with some status formation but I dont know how to setup telegraf to output this info to influx. the json string is like this:


{“StatusTIM”:{“UTC”:“Mon Dec 18 16:06:23 2017”,“Local”:“Mon Dec 18 17:06:23 2017”,“StartDST”:“Sun Mar 26 02:00:00 2017”,“EndDST”:“Sun Oct 29 03:00:00 2017”,“Timezone”:1}}

I don’t need all this to be exported but i would like to potentially export any of the fields. Also I want to ignore the time and let influx use its own timestamp.
How should I configure telegraf.conf?

You need an input plugin that supports data_format = “json”

There’s a few, such as:

Example that explains data_format for exec:

In your case I guess you need to use mqtt_consumer and set data_format to json.

Thank you for pointing me in the right direction. I looked at those pages again (I did try to figure this out before I asked for help). I am still having some trouble.
How can I ignore the metrics I dont care about or need more than once.
How can I get telegraf to parse strings deep into the json code. for example in the following json I can not get the strings (i.e. SSId) even using tag_keys deignation because it is too deep (I think).


here is the mqtt part of my config:

# Read metrics from MQTT topic(s)
  name_override = "SensorTest1"
  servers = ["tcp://localhost:1883"]
  qos = 0
  connection_timeout = 30
  topics = [
  persistent_session = true
  client_id = "AbrahamL"

  data_format = "json"
  tag_keys = [

From what I could find, it looks like it’s not supported by the current json parser. It drops strings unless they are in the tag_keys and in the root level.

There’s an issue about it but it’s still open. Your options at this point are to wait or program a plugin yourself.

Related issue: