Reading from first


(NIloufar) #1

i use logstash for reading a log file .this file store my service log ,so added some logs during a hours. the point is each time that a log add in my log file , logstash read all log file from first and send it to elasticsearch . how can i fix this config that each time send just latest log to elasticsearch?


#2

Can you show us your logstash input configuration?


(Leandro Sampaio) #3

This isn't the normal mode of work from logstash... The logstash store position read from each file and case you kill a process, the same start in correct position


(praveen.vemuri) #4

Configure sincedb_path for the file input in logstash.

sincedb_path
Value type is string
There is no default value for this setting.
Path of the sincedb database file (keeps track of the current position of monitored log files) that will be written to disk. The default will write sincedb files to <path.data>/plugins/inputs/file NOTE: it must be a file path and not a directory path


(NIloufar) #5

input {
file {
path => "/home/adanic/alternatives.log"
type => "log"
}
}
filter {
}
output {
elasticsearch {
hosts => ["localhost:9200"]
index => "doc"
document_type => "%{type}"
}
}
it is my first config


(NIloufar) #6

i change my conf and set directly sincedb_path bud didn't work
hear my second conf
input {
file {
path => "/home/adanic/alternatives.log"
type => "log"
sincedb_path =>"/home/adanic/ee"
}
}
filter {
}
output {
elasticsearch {
hosts => ["localhost:9200"]
index => "doc"
document_type => "%{type}"
}
}


(Magnus Bäck) #7

Exactly how are you adding logs to the file? By appending to the file?


(NIloufar) #8

yes i append each log to end of the log file


(Magnus Bäck) #9

How, exactly?


(NIloufar) #10

well ,i open log file and paste one row of log that i copied and save


(Magnus Bäck) #11

In a text editor? Then you won't actually append to the file. The text editor will most likely create a new file, write the new data into that file, and rename it into place. To Logstash, this counts as a brand new file.

But the configuration you claim you have is inconsistent with the behavior you describe. Unless you set the file input's start_position option to "beginning" Logstash will under no circumstances read a file from the beginning (well, okay, unless the file is empty).


(NIloufar) #12

you mean i should set start_position => "end"?


(Magnus Bäck) #13

No, I mean that you shouldn't use a text editor to simulate appending to a log file, because it won't actually be an append operation.


(NIloufar) #14

but i test it in windows and it was ok in this way of adding log.
ok i test it with system log file .this file i think use append operation for add log


(system) #15

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.