Get Telegraf to send to multiple InfluxDB hosts

I totally get that I can use Enterprise Influx to solve this issue and understand if that is the only way to get what I want out of the box.

I have two servers that I want to use as influxdb host and I want my servers which are running telegraf daemons to post to both servers. I know that if I setup urls = [“server1”,“server2”] in [[outputs.influxdb]] I get round robin sending not duplicate sending.

Is there anyway short of placing a multiplexer in the path of telegraf to get a single telegraf daemon to send to multiple influx servers.

Yes, you can define multiple outputs:

[[outputs.influxdb]]
  urls = ["http://server1:8086"]
  # ... other options ...

[[outputs.influxdb]]
  urls = ["http://server2:8086"]
  # ... other options ...

This works great - Thanks very much for the response!

Hello Mr.Daniel
I try as you said.
But I can’t start Telegraf.

I try:

[[outputs.influxdb]]
  urls = ["http://server1:8086", "http://server2:8086"]

But Telegraf send metrics to server1 during period. Then Telegraf send metrics to server2 during period. And repeat again.

Please help me to fix it.
Thanks.

Just update your config to use the pattern shown in my comment above, with two independent influxdb outputs.

you need 2 separate output.influxdb definitions that each specify a different host. Not one output.influxdb that specifies 2 hosts.

@daniel
@aspitzer
I try as you said.
But I can’t start Telegraf.

Hi , why can’t you start Telegraf ? Does it give an error ?

Hi
I can’t start telegraf. This is log debug.

systemd[1]: telegraf.service: Main process exited, code=exited, status=1/FAILURE
systemd[1]: telegraf.service: Unit entered failed state.
systemd[1]: telegraf.service: Failed with result 'exit-code'.
systemd[1]: telegraf.service: Service hold-off time over, scheduling restart.
systemd[1]: Stopped The plugin-driven server agent for reporting metrics into InfluxDB.
systemd[1]: telegraf.service: Start request repeated too quickly.
systemd[1]: Failed to start The plugin-driven server agent for reporting metrics into InfluxDB.

Then, I comment and use only 1 output.influxdb. I started it success.

Thanks , can you give the
[[ outputs.influxdb]]
Sections of your configfile?
Is there any logging in the Telegraf logfile ?
Example : /var/log/telegraf/telegraf.log

Can you try to start Telegraf without using systemctl ?
Best regards

1 Like

Thank you very much ^^
I try do it and success ^^

Quick update – for InfluxDB Cloud 2, you’d want to have two sections that start with:

[[outputs.influxdb_v2]] # For InfluxDB 2.0

So, for example (be sure to scroll to get all the config lines):

# Configuration for sending metrics to InfluxDB 2.0 Open Source

[[outputs.influxdb_v2]] # For InfluxDB 2.0

## The URLs of the InfluxDB cluster nodes.
urls = ["http://127.0.0.1:9999"]

## Token for authentication.
token = "your_token"

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

## Destination bucket to write into.
bucket = "you_bucket"

# Configuration for sending metrics to InfluxDB 2.0 Cloud
[[outputs.influxdb_v2]] # For InfluxDB 2.0

## The URLs of the InfluxDB cluster nodes.
urls = ["https://us-west-2-1.aws.cloud2.influxdata.com"]

## Token for authentication.
token = "your_token"

## Organization is the name of the organization you wish to write to; must exist.
organization = "your_org" # This is your InfluxDB Cloud 2.0 org

## Destination bucket to write into.
bucket = "your_bucket"

Hello!

How I can use 2 hosts.
[agent]
interval = “10s”
debug = false
hostname = “host1”
round_interval = true
flush_interval = “10s”
flush_jitter = “0s”
collection_jitter = “0s”
metric_batch_size = 1000
metric_buffer_limit = 10000
quiet = false
logfile = “/var/log/telegraf/jitsi.log”
omit_hostname = false

And, I need one more host “host2” in the same telegraf.conf. Becouse I have 2 [[inputs.http]] from different hosts. And when I use “host1” I did not see “host2” metrics in Grafana