Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Logstash not reading file input

I have a strange problem with Logstash. I am providing a log file as input to 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. The problem is, no data is being received when the input is a file. However, if I change input to stdin { } as follows, it sends all input data smoothly:

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?

like image 675
Sasanka Panguluri Avatar asked May 30 '14 20:05

Sasanka Panguluri


People also ask

What is Sincedb_path?

sincedb_path just needs to be a directory where logstash has write permission for the registry. sincedb_write_interval defines how often logstash should write the sincedb registry. A larger value puts you at risk in logstash were to crash.

Where is Sincedb?

By default, the sincedb database is stored in the directory $HOME, and have filenames starting with ". sincedb_".

Can logstash have multiple inputs?

I have included multiple inputs and outputs in my logstash conf file (without filter for now). I have also created different indexes for each input.

Can logstash pull logs?

Logstash supports a variety of inputs that pull in events from a multitude of common sources, all at the same time. Easily ingest from your logs, metrics, web applications, data stores, and various AWS services, all in continuous, streaming fashion.


2 Answers

You should set start_position under your file section:

start_position => "beginning"

It defaults to end and so won't read any existing lines in your file, only newly added ones:

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. 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.

like image 103
John Petrone Avatar answered Sep 28 '22 03:09

John Petrone


In addition to the provided answer, I had to change the path from c:\my\path to c:/my/path in order for it to read the files.

like image 29
sandlb Avatar answered Sep 28 '22 01:09

sandlb