字段类型与[input.tail]插件冲突

时间:2019-08-14 20:16:32

标签: influxdb telegraf telegraf-inputs-plugin telegraf-plugins

我正在尝试使用Telegraf的input.tail插件将csv文件中的数据导入InfluxDB。

我能够导入数据而无需明确字段的类型。问题是我想将csv中的数据合并到已经存在浮点类型的现有measurement中。我发现我们可以通过在尾部插件中使用csv_column_types来显式更改类型,但不要缺少。

telegraf.conf

[[inputs.tail]]

## files to tail.
 ## These accept standard unix glob matching rules, but with the addition of
 ## ** as a "super asterisk". ie:
 ##   "/var/log/**.log"  -> recursively find all .log files in /var/log
 ##   "/var/log/*/*.log" -> find all .log files with a parent dir in /var/log
 ##   "/var/log/apache.log" -> just tail the apache log file
 ##
 ## See https://github.com/gobwas/glob for more examples
 ##
 files = ["test.csv"]

## Read file from beginning.
 from_beginning = true
 ## Whether file is a named pipe
 pipe = false

 ## Method used to watch for file updates.  Can be either "inotify" or "poll".
 # watch_method = "inotify"

 ## 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 = "csv"
 csv_header_row_count = 1

 #csv_column_names = ["time","sentBytes","success"]
 csv_column_types =["float","float", "string"]
test.csv
"time","sentBytes","success"
"1564763737220","4345","true"

我也尝试过[processors.converter.tags]-不缺少。

错误消息是when writing to [http://localhost:8086]: received error partial write: field type conflict: input field "sentBytes" on measurement "tail" is type float, already exists as type integer dropped=5000; discarding points

telegraf --version Telegraf 1.11.0 (git: HEAD c9d8f7b0)

有人可以澄清我在做什么吗?

1 个答案:

答案 0 :(得分:0)

据我了解,tail插件使用InfluxDB线路协议,该协议发送|measurement|,tag_set| |field_set| |timestamp|,在此基础上,我添加了csv_tag_columns=["success"]并将csv_column_types更改为 csv_column_types=["string","float"]现在可以正常工作