居然是你

怎么配置把文件作为单个doc存入es中

Logstash | 作者 zbdbx | 发布于2018年10月16日 | 阅读数:2668

我想把文件夹内所有的.txt文件内容按pain内容分别存入以文件名为_id的es中,以下为我当前的配置,实现不了
 
 

input {
  file {
    path => ["D:/docs/*"]
    start_position => "beginning"
    sincedb_path => "NUL"
    #delimiter => "\0"  #分隔符好像不能用\0、中文、或者多个字符
  }
}
output {
  elasticsearch {
    hosts => ["http://elasticsearch:9200/"]
    index => "test-%{+YYYY.MM.dd}" #这里想用文件创建时间
    document_id => "%{path}"  #这里想存入文件名
    #user => "elastic"
    #password => "changeme"
  }
}
已邀请:

zbdbx

赞同来自:

其实想法就原封不动地把文件搬到es上去,并同步更新内容

rochy - rochy_he

赞同来自:

input {
file {
path => ["/home/txts/*"]
start_position => "beginning"
mode => "read"
delimiter => "EOF"
file_completed_action => "log"
file_completed_log_path => "/home/logs/file.log"
}
}
output {
elasticsearch {
hosts => ["http://192.168.3.214:9200/"]
index => "test-text"
document_id => "%{path}"
}
stdout {}
}

默认 file_completed_action 是 delete,也就是说文件读取完会被删除,你可以改为 log

改为 log 后 file_completed_log_path 这个文件必需设置,文件可以不存在,但是文件夹必需要存在,否则启动报错
 

要回复问题请先登录注册