同时写入 InfluxDB OSS 和 InfluxDB Cloud
如果您想在两个地方备份您的数据,或者如果您正在从OSS迁移到云,您可能想要设置双重写入。
使用Telegraf同时写入InfluxDB OSS和InfluxDB Cloud。
下面的示例配置使用:
- 将InfluxDB v2 输出插件使用两次:第一次指向 OSS 实例,然后指向云实例。
- 两个不同的令牌,一个用于OSS,一个用于云。您需要将这两个令牌配置为环境变量(参见 将您的令牌配置为环境变量)。
使用以下配置将您的数据同时写入OSS和Cloud实例。
示例配置
[[inputs.cpu]]
[[inputs.mem]]
## Any other inputs, processors, aggregators that you want to include in your configuration.
# Send data to InfluxDB OSS v2
[[outputs.influxdb_v2]]
## The URLs of the InfluxDB instance.
##
## Multiple URLs can be specified for a single cluster, only ONE of the
## urls will be written to each interval.
## urls exp: http://127.0.0.1:9999
urls = ["http://localhost:8086"]
## OSS token for authentication.
token = "$INFLUX_TOKEN_OSS"
## Organization is the name of the organization you want to write to. It must already exist.
organization = "influxdata"
## Destination bucket to write to.
bucket = "telegraf"
# Send data to InfluxDB Cloud - AWS West cloud instance
[[outputs.influxdb_v2]]
## The URLs of the InfluxDB Cloud instance.
urls = ["https://us-west-2-1.aws.cloud2.influxdata.com"]
## Cloud token for authentication.
token = "$INFLUX_TOKEN_CLOUD"
## Organization is the name of the organization you want to write to. It must already exist.
organization = "example@domain.com"
## Destination bucket to write into.
bucket = "telegraf"