使用 filebeat 传输 csv 文件

Transport csv file with filebeat

案例

将 csv 文件从客户端 PC 推送到服务器端的 elastic

elastic已经安装好了,很好。我可以从我的电脑访问它并使用演示数据。现在我想学习如何用我自己的数据推送它。我已经从 kaggle 准备了我的数据。

客户端

我已经在客户端下载了filebeat并解压了。 我已将 filebeat.yml 编辑为

filebeat.inputs:
- input_type: log
  paths:
    - C:\Users\Charles\Desktop\DATA\BrentOilPrices.csv
document_type: test_log_csv
output.logstash:
  hosts: ["10.64.2.246:5044"]

我也用

测试过
./filebeat test config

它 return : 配置正常

服务器端

编辑 logstash.conf 为

input {
beats {
port =>5044
}
}

filter {

if "test_log_csv" in [type]
{
csv {
columns=>["Date","Price"]
separator=>","
}
mutate{
convert => ["Price","integer"]
}
date{
match=>["Date","d/MMM/yy"]
}
}
}

output {
if "test_log_csv" in [type]
{
elasticsearch
{
hosts=>"127.0.0.1:9200"
index=>"test_log_csv%{+d/MM/yy}"
}
}

客户端

我运行

Start-Service filebeat

它return没什么。

我检查了我的 kibana,没有日志。 我错过了什么?

在客户端编辑filebeat.yml

filebeat.inputs:
- input_type: log
  paths:
    - 'C:\Users\Charles\Desktop\DATA\BrentOilPrices.csv'
fields:
document_type: test_log_csv
output.logstash:
  hosts: ["10.64.2.246:5044"]

document_type 选项已从版本 6.X 的 Filebeat 中删除,因此不再创建 type 字段,因为您的条件基于此字段,您的管道将无法工作.此外,即使在 windows.

上,您也应该尝试使用正斜杠 (/)

尝试更改下面的配置并再次测试。

filebeat.inputs:
- input_type: log
  paths:
    - 'C:/Users/Charles/Desktop/DATA/BrentOilPrices.csv'
fields:
  type: test_log_csv
fields_under_root: true
output.logstash:
  hosts: ["10.64.2.246:5044"]

选项 fields_under_root: true 将在文档的根目录中创建字段 type,如果您删除此选项,该字段将创建为 [fields][type],您将需要将您的条件更改为该字段。