Best practice on telegraf to multiple influxdb v2 buckets

What I want:

system related data > default bucket
telegraf input1 > bucket 1
telegraf input2 > bucket 2
telegraf input3 > bucket 3 etc…

to keep everything clean with separate retention times.

My problem with this is that i need to know upfront to what fields are inserted in to the bucket to make use of namedrop and namepass

My result: bucket with data that is not related with each other. > mess

Is there a better way to do this: keep data separated based on telegraf input plugin?

1 Like

I got it to work with by tagging the input and adding tagpass in the output

[[outputs.influxdb_v2]]
urls = [“ipport”]
token = “tkn”
organization = “org”
bucket = “bkt”
tagexclude =[“tag1”]
[outputs.influxdb_v2.tagpass]
tag1 = [“foo”]

[[inputs.socket_listener]]
service_address = “tcp://:2003”
data_format = “graphite”
templates = [
.app env.service.resource.measurement",
"servers.
.host.resource.measurement.field*”,
]
[inputs.socket_listener.tags]
tag1 = “foo”

You can also use the name_override and namepass to filter measurements.
name_override - changes a measurement name for the inputs, useful for self-owned scripts.
namepass - filters the measurements to send to influx, defined in the outputs.

An example can be:

[[outputs.influxdb_v2]]	
  urls = ["http://localhost:8086"]
  token = "sadojpqrq9we894e6461e4614d6a46gwajg4g=="
  organization = "awesome_org"
  bucket = "system_data"
  namepass = ["mem", "processes"]

[[inputs.processes]]

[[inputs.mem]]

or

[[outputs.influxdb_v2]]	
  urls = ["http://localhost:8086"]
  token = "sadojpqrq9we894e6461e4614d6a46gwajg4g=="
  organization = "awesome_org"
  bucket = "system_data"
  namepass = ["kernel"]

[[inputs.exec]]
  name_override = "kernel"
  commands = [
    "/etc/telegraf/kernel.bash"
  ]
  interval = "1m"
  timeout = "5s"
  data_format = "logfmt"

Where /etc/telegraf/kernel.bash is a script that outputs data in logfmt format.

1 Like