多个Telegraf守护程序试图写入InfluxDB中的同一数据库

时间:2019-06-17 18:15:55

标签: apache-kafka influxdb telegraf telegraf-inputs-plugin telegraf-output-plugins

我正在运行两个telegraf守护程序。

守护进程1:输入= kafka主题:sample_topic,输出= InfluxDb:DB = Telegraf,测量= KI1
守护进程2:输入= kafka主题:sample_topic2,输出= InfluxDb:数据库= telegraf,测量= KI2

两个守护程序读取不同的kafka主题,并在InfluxDB数据库“ telegraf”中写入两个不同的度量值

我观察到的是测量KI1和KI2并非同时创建。仅创建一个度量。当我杀死已经创建度量的守护程序时,另一个守护程序将在数据库中创建另一个度量。

InfluxDb是否允许同时写入不同的度量?

我什至通过写入两个不同的InfluxDb数据库(telegraf和telegraf2)来尝试相同的操作。我观察到相同的行为。

还可以仅使用一个守护程序来完成所有这一切吗?在哪里,我有多个输入插件可读取不同的kafka主题,并有不同的输出插件可在需要时编写。

守护进程1:

[tags]
    topic = "sample_topic"


# OUTPUTS
[outputs]
[outputs.influxdb]
    # The full HTTP endpoint URL for your InfluxDB instance
    url = "http://localhost:8086" # EDIT THIS LINE
    # The target database for metrics. This database must already exist
    database = "telegraf" # required.
    skip_database_creation = true
    database_tag = "KI1"

#INPUTS
# Read metrics from Kafka topic(s)
[[inputs.kafka_consumer_legacy]]

    name_override = "KI1"
    ## topic(s) to consume
    topics = ["sample_topic"]
    ## an array of Zookeeper connection strings
    zookeeper_peers = ["localhost:2181"]
    ## Zookeeper Chroot
    zookeeper_chroot = ""
    ## the name of the consumer group
    consumer_group = "sample"
    ## Offset (must be either "oldest" or "newest")
    offset = "oldest"
    ## Data format to consume.
    ## Each data format has its own unique set of configuration options, read
    ## more about them here:
    ## https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_INPUT.md
    data_format = "value"
    data_type = "string"
    ## Maximum length of a message to consume, in bytes (default 0/unlimited);
    ## larger messages are dropped
    max_message_len = 65536

守护进程2:

[tags]
    topic = "sample_topic2"

# OUTPUTS
[outputs]
[outputs.influxdb]
    # The full HTTP endpoint URL for your InfluxDB instance
    url = "http://localhost:8086" # EDIT THIS LINE
    # The target database for metrics. This database must already exist
    database = "telegraf" # required.
    skip_database_creation = true
    database_tag = "KI2"


#INPUTS
# Read metrics from Kafka topic(s)
[[inputs.kafka_consumer_legacy]]

    name_override = "KI2"
    ## topic(s) to consume
    topics = ["sample_topic2"]
    ## an array of Zookeeper connection strings
    zookeeper_peers = ["localhost:2181"]
    ## Zookeeper Chroot
    zookeeper_chroot = ""
    ## the name of the consumer group
    consumer_group = "sample"
    ## Offset (must be either "oldest" or "newest")
    offset = "oldest"
    ## Data format to consume.
    ## Each data format has its own unique set of configuration options, read
    ## more about them here:
    ## https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_INPUT.md
    data_format = "value"
    data_type = "string"
    ## Maximum length of a message to consume, in bytes (default 0/unlimited);
    ## larger messages are dropped
    max_message_len = 65536

1 个答案:

答案 0 :(得分:0)

  

我观察到的是测量KI1和KI2都不   同时创建。仅创建一个度量。当我杀死   已经创建测量的守护程序,然后另一个   测量由另一个守护程序在数据库中创建。

我不知道您是如何验证的。但是这种异常的机会很少。

  

InfluxDb是否允许同时写入不同的测量值?

是的