Bucket_Tag to direct metrics to different buckets

Hello…

I’ve just setup an InfluxDB v2 server for some testing and I’m trying to configure Telegraf to default metrics to a default bucket or send specific metrics from inputs to a specific bucket. There seems to be absolutely no info on this in the Telegraf documentation. As an example, I have SNMP info I want to go to one bucket while Syslog info goes to another. I just can’t find how to setup the inputs for this or the Influxdb_v2 outputs. I see in the telegraf.conf file references this…

The value of this tag will be used to determine the bucket. If this

## tag is not set the ‘bucket’ option is used as the default.

# bucket_tag = “”

I created two instances of the InfluxDB_v2 outputs, one with this not set so that bucket identified is default. The other instance is set to a different bucket then I add the bucket_tag=“database” in my input, but that didn’t work.

Any info on how to take input sources and direct them to their own buckets would be greatly appreciated.

This is absolutely possible, go for measurement filtering

1 Like

Hi @Franky1 , thanks for the response. Is this supported for Influxdb_v2? The examples just show [[outputs.influxdb]], also I don’t see any references to the use of buckets. TIG stack is fairly new to me so still learning.

Yes of course.
But for InfluxDB 2.x.x you have to use the output plugin [[outputs.influxdb_v2]] :wink:

1 Like

@Franky1 I’m not having any luck with this, I even tried with info on this link…
(telegraf/CONFIGURATION.md at master · influxdata/telegraf · GitHub)

…which references the info on your link without any success. Anything I add fails to start the Telegraf service. I even found that just enabling input.syslog by uncommenting…

server = “tcp://:6514”

…and allow it to default to the default bucket doesn’t allow the Telegraf service to start.

Enable the debug option.
What ist the error message of the Telegraf log?

I uncommented the “debug = false” and changed it to “debug = true”. I had commented out all the tagging I’m trying to do as well as the syslog "server = “tcp://6514” and I am able to start the Telegraf service.

I then just uncommented the syslog entry and the Telegraf service won’t start, checking the logs has no information other then the last successful start.

Afaik you need at least one input and one output plugin in the telegraf conf to start the telegraf agent.

Please post your telegraf.conf file here in the forum in markdown format:

```toml
put your telegraf conf here
```

Hi @Franky1, really appreciate your help. You’re right a working input needs to be available for the Telegraf service to start. I also figured out why the Telegraf service wouldn’t start, I forgot to remove the comment before the [[inputs.syslog]]. At the moment I have inlfuxdb_v2, telegraf and rsyslog services running but I am not able to get any syslog info into influxdb. I don’t think there is any use trying to sort out the data redirection to the specific database until I can get some syslog data ingesting so I’ll work on that then respond back to this thread for that part.

For testing purposes i usually add these output plugin, that helps figuring out where the problems are:

[[outputs.file]] # only for debugging
  files = ["test.out"]
  influx_sort_fields = true

Ok, after messing around with it all day I finally figured out the changes I needed to get syslog messages into InfluxDB_v2. Since I have two outputs set, without successfully targeting the correct DBs I have duplicate data in the two DBs. Here are my Output Configs with some commented entries I’ve tried.

I’m trying to target basic metrics, like local CPU\Mem etc, into the InfluxDB_Server and the syslog data into the Syslog database. If I comment out “namepass = syslog” the Telegraf service won’t start.

  [[outputs.influxdb_v2]]

    urls = ["http://127.0.0.1:8086"]

#   ## Token for authentication.
    #token = "$INFLUX_TOKEN"
	#urls = "$INFLUX_HOST"
    #organization = "$INFLUX_ORG"
	token = "7u3yFyc2FQ7iplc48_yVdrnlNSGMIo8jHK-q8ohaeyIhIgqOZKFGIuJspQnnZceCnAgT9Pd1Nbiv8Xi2dbc4ag=="

#   ## Organization is the name of the organization you wish to write to; must exist.
    organization = "Test_Org"

#   ## Destination bucket to write into.
    
	#[outputs.influxdb_v2.tagdrop]
	#	influxdb_database = ["*"]
	bucket = "InfluxDB_Server"

  [[outputs.influxdb_v2]]

    urls = ["http://127.0.0.1:8086"]
 
    #token = "$INFLUX_TOKEN"
	#urls = "$INFLUX_HOST"
    #organization = "$INFLUX_ORG"
	token = "7u3yFyc2FQ7iplc48_yVdrnlNSGMIo8jHK-q8ohaeyIhIgqOZKFGIuJspQnnZceCnAgT9Pd1Nbiv8Xi2dbc4ag=="

    organization = "Test_Org"

    
	#tagexclude = ["influxdb_database"]
	#[outputs.influxdb_v2.tagpass]
	#influxdb_database = {"Syslog"]
	#namepass = syslog
	bucket = "Syslog"
	#user_agent = "telegraf"
	

	#bucket_tag = "Syslog"

	#exclude_bucket_tag = true

Yes, of course, wrong syntax.

namepass = ["syslog"]

I think I tried that before but had other issues going on at the time. I made that change and no error starting Telegraf but I’m still getting the syslog entries in both data bases.

Yes of course, because you did not exclude the measurement name on the other output plugin.
Add on the other output plugin:

namedrop = ["syslog"]

Seems so easy when you iron out other issues that were causing problems.

Really appreciate all your help on this, you’ve been incredibly helpful. Looks like everything is now working as expected…next, crash course on FLUX!

Thanks again.
Rob!