0

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

我可以在不明确字段类型的情况下导入数据。问题是我想将数据从 csv 合并到已经存在的measurement,其中包含浮点类型。我发现我们可以通过使用csv_column_typesin tail 插件显式更改类型,但也不乏。

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)

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

4

1 回答 1

0

据我了解,tail 插件使用 InfluxDB 线路协议,它发送|measurement|,tag_set| |field_set| |timestamp|基于此我已添加csv_tag_columns=["success"]并更改csv_column_typescsv_column_types=["string","float"],现在它正在工作

于 2019-08-15T09:30:37.367 回答