How to write data to multiple buckets

Nils_Franke
Thu, 07 Aug 2025 15:58:08 +0000
Telegraf

Hi there!

I recieve different messages (jsonv2) from one sensor and would like to put different messages into different buckets.

This is my config at the moment:

[[outputs.influxdb_v2]]
  urls = ["http://127.0.0.1:8086"]
  token = "mytoken"
  organization = "myorg"
  bucket = "untouchedBucket"

##(1065)
  [[inputs.mqtt_consumer.json_v2]]
    name_override = "package_data"
    [[inputs.mqtt_consumer.json_v2.tag]]
      path = "msg_id"
      data_type = "int"
    [[inputs.mqtt_consumer.json_v2.tag]]
      rename = "device_id"
      path = "device_info.device_id"
    [[inputs.mqtt_consumer.json_v2.tag]]
      rename = "mac"
      path = "device_info.mac"
    [[inputs.mqtt_consumer.json_v2.field]]
      rename = "switch_state"
      path = "data.switch_state"
      data_type = "bool"
      optional = true
    [[inputs.mqtt_consumer.json_v2.field]]
      rename = "load_state"
      path = "data.load_state"
      data_type = "bool"
      optional = true
    [[inputs.mqtt_consumer.json_v2.field]]
      rename = "overload_state"
      path = "data.overload_state"
      data_type = "bool"
      optional = true
    [[inputs.mqtt_consumer.json_v2.field]]
      rename = "overcurrent_state"
      path = "data.overcurrent_state"
      data_type = "bool"
      optional = true
    [[inputs.mqtt_consumer.json_v2.field]]
      rename = "overvoltage_state"
      path = "data.overvoltage_state"
      data_type = "bool"
      optional = true
    [[inputs.mqtt_consumer.json_v2.field]]
      rename = "time_plug"
      path = "data.timestamp"
      data_type = "string"


##(1066)
  [[inputs.mqtt_consumer.json_v2]]
    name_override = "package_data"
    [[inputs.mqtt_consumer.json_v2.tag]]
      path = "msg_id"
      data_type = "int"
    [[inputs.mqtt_consumer.json_v2.tag]]
      rename = "device_id"
      path = "device_info.device_id"
    [[inputs.mqtt_consumer.json_v2.tag]]
      rename = "mac"
      path = "device_info.mac"
    [[inputs.mqtt_consumer.json_v2.field]]
      rename = "switch_state"
      path = "data.switch_state"
      data_type = "bool"
      optional = true
    [[inputs.mqtt_consumer.json_v2.field]]
      rename = "countdown"
      path = "data.countdown"
      data_type = "int"
      optional = true
    [[inputs.mqtt_consumer.json_v2.field]]
      rename = "time_plug"
      path = "data.timestamp"
      data_type = "string"

I would like to have message 1065 still being written to “untouchedbucket”, while message 1066 should go to “touchedbucket”.

How should my config look like?
Can somebody give me an example?
Do I have to run a second Telegraf instance to do this?

6 posts - 3 participants