简体   繁体   English

Logstash不读取文件输入

[英]Logstash not reading file input

I have a strange problem with Logstash. 我对Logstash有一个奇怪的问题。 I am providing a log file as input to logstash. 我提供了一个日志文件作为logstash的输入。 The configuration is as follows: 配置如下:

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"
  }
}

I am running elasticsearch server already and verifying if the data is being received with curl queries. 我正在运行elasticsearch服务器并验证是否正在使用curl查询接收数据。 The problem is, no data is being received when the input is a file . 问题是,当输入是file时,没有数据被接收。 However, if I change input to stdin { } as follows, it sends all input data smoothly: 但是,如果我按如下方式将输入更改为stdin { } ,它会平滑地发送所有输入数据:

input {
  stdin{ }
}
output {
  elasticsearch {
    protocol => "http"
    host => "10.35.143.93"
    port => "9200"
    index => "latestindex"
  }
}

I don't get where I am going wrong. 我不知道我哪里错了。 Can someone please take a look at this? 有人可以看一下吗?

You should set start_position under your file section: 您应该在文件部分下设置start_position:

start_position => "beginning"

It defaults to end and so won't read any existing lines in your file, only newly added ones: 它默认为结束,因此不会读取文件中的任何现有行,只会读取新添加的行:

start_position START_POSITION

 Value can be any of: "beginning", "end" Default value is "end" 

Choose where Logstash starts initially reading files: at the beginning or at the end. 选择Logstash最初开始读取文件的位置:开头或结尾。 The default behavior treats files like live streams and thus starts at the end. 默认行为将文件视为实时流,因此从最后开始。 If you have old data you want to import, set this to 'beginning' 如果您要导入旧数据,请将其设置为“开始”

This option only modifies “first contact” situations where a file is new and not seen before. 此选项仅修改文件是新的且之前未见过的“第一次联系”情况。 If a file has already been seen before, this option has no effect. 如果之前已经看过某个文件,则此选项无效。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM