Logstash不读取文件输入

Sas*_*uri 3 logging file input elasticsearch logstash

我对Logstash有一个奇怪的问题.我提供了一个日志文件作为logstash的输入.配置如下:

input {
  file {
    type => "apache-access"
    path => ["C:\Users\spanguluri\Downloads\logstash\bin\test.log"]
  }
}
output {
  elasticsearch {
    protocol => "http"
    host => "10.35.143.93"
    port => "9200"
    index => "latestindex"
  }
}
Run Code Online (Sandbox Code Playgroud)

我正在运行elasticsearch服务器并验证是否正在使用curl查询接收数据.问题是,当输入是a时,没有数据被接收file.但是,如果我将输入更改stdin { }为如下,它将平滑地发送所有输入数据:

input {
  stdin{ }
}
output {
  elasticsearch {
    protocol => "http"
    host => "10.35.143.93"
    port => "9200"
    index => "latestindex"
  }
}
Run Code Online (Sandbox Code Playgroud)

我不知道我哪里错了.有人可以看一下吗?

Joh*_*one 8

您应该在文件部分下设置start_position:

start_position => "beginning"
Run Code Online (Sandbox Code Playgroud)

它默认为结束,因此不会读取文件中的任何现有行,只会读取新添加的行:

START_POSITION

Value can be any of: "beginning", "end"
Default value is "end"
Run Code Online (Sandbox Code Playgroud)

选择Logstash最初开始读取文件的位置:开头或结尾.默认行为将文件视为实时流,因此从最后开始.如果您要导入旧数据,请将其设置为"开始"

此选项仅修改文件是新的且之前未见过的"第一次联系"情况.如果之前已经看过某个文件,则此选项无效.


小智 5

除了提供的答案之外,我还必须将路径从 c:\my\path 更改为 c:/my/path 才能读取文件。