Telegraf: Mixed Data Types in a Topic folder

My data structure is the following:
grafik

My Telegraf configuration is:

## Hydrom ##
[[inputs.mqtt_consumer]]
  name_override = "Hydrom"
  servers = ["tcp://192.168.x.y:1883"]

  persistent_session = false
  ## If unset, a random client ID will be generated.
  client_id = ""
  ## Username and password to connect MQTT server.
  username = "xxx"
  password = "xxx"

  topics = [
    "Home/Brewhouse/Fermentation/#",
  ]

  data_format = "value"
  data_type = "float"
  tagexclude = ["host", "topic"]

  [[inputs.mqtt_consumer.topic_parsing]]
    topic = "Home/Brewhouse/Fermentation/+/+"
    tags = "_/_/_/HydromName/field"
  [[processors.pivot]]
  tag_key = "field"
  value_key = "value"
# /Hydrom ##

For the marked “temp_units” I will always get the following error:

 E! [inputs.mqtt_consumer] Error in plugin: strconv.ParseFloat: parsing "C": invalid syntax
  1. How can I treat this very Tag as a string and all others as float?
  2. Is is possible to bundle all tags in the Hydrom001/Hydrom002 Folder into one single line in Influx, instead of one line per value?
  1. How can I treat this very Tag as a string and all others as float?

Take a look at the topic parsing example, where a specific type is provided:

    [inputs.mqtt_consumer.topic_parsing.types]
      temp_units = "string"

edit: not 100% certain this is the way to handle this, but my question to you below is a bigger/better question:

Do you also want this to be a tag? To take a step back, I’m not sure why you would want to store this at all and instead would kick it out. As a tag it doesn’t help you filter your data if it is always in C?

  1. Is is possible to bundle all tags in the Hydrom001/Hydrom002 Folder into one single line in Influx, instead of one line per value?

What other tags are you referring to other than temp units? Recall tags are indexed, and usually things you want to filter on (e.g. hostname, url) and not variable data (e.g. floats).

1 Like

Hi jpowers, thanks for your answer.

I admit, question 2 was a little bit confusing, since (as a new user) I was not able to add a second screenshot to explain clearly what I want to archive…

This is how the data is received in Influx and it makes (of course) sense.

But I basically want to have only 2 lines, instead of these 16 entries: One for Hydrom001 and one for Hydrom002. Not sure if this is possible. The timestamp difference of a few milliseconds are not important for me. (If the Unit works as well, I will have 9 Entries per Device - the unit is theoretically, so depending on the device location it could be F or °C).