Why Logstash reloading duplicate data from file in Linux? - linux

I am using logstash, elasticsearch and kibana.
My logstash configuration file is as follows.
input {
file {
path => "/home/rocky/Logging/logFiles/test1.txt"
start_position => "end"
sincedb_path => "test.db"
}
}
output {
stdout { codec => rubydebug }
elasticsearch { host => localhost }
}
When I am running Logstash in windows environment it is working fine, but when I am using same configuration in my virtual Linux OS (Fedora) it is creating a problem.
In fedora when i am inserting anything at the end of the log file when logstash is running. Sometimes it is sending all data of the file from beginning, sometimes half data. But it should only load new data appended to that log file. also sincedb file is storing data correctly. Still it is nor giving proper data in Fedora. Please help.

I had a similar problem on my LinuxMint machine using the official logstash docker image.
I was using a text editor (Geany) to add new lines to the file. After playing around a bit more, I figured out that it must have been related to what my text editor (Geany) was doing when saving the file after I added new lines.
When I added new lines using a simple echo command instead, things worked fine:
echo "some new line" >> my_file.log
I know this thread is old, but this was the only thing that came up at all when I googled for this, so hopefully this will help someone else...

Related

logstash not reading the current file after log rotation happens

I read input from log file and write to kafka. even after log rotation, inode doesnt change. after log rotation, still reads rotated log file(xx.log.2020-xx-xx) instead of pointing to main file(xx.log).
Below is my config file setting for input file.
Do I need to add any other config to ignore reading old files.
input {
file {
path => "C:/Users/xx.log"
}
}
it's the same issue as this one. Logstash handles pretty well file rotation by default.
All you need to do is to make sure to use a glob pattern (e.g. ...log*) that identifies all of your log files and Logstash will keep track of them:
input {
file {
path => "C:/Users/xx.log*"
}
}

Talend 7.1 tFileOutputExcel corrupt file

I'm trying to output an excel file from Talend 7.1. I've tried a few different setups and both xls and xlsx formats but they all result in the output file being corrupt and not being able to open it.
What am I doing wrong? I am loading an xlsx file into a database and this part works fine but outputting to excel I just can't figure it out! I was writing from the tMap directly to the tFileOutputExcel and it wasn't working (corrupt) so I changed it to write to a csv file first and then write that csv to the tFileOutputExcel but it is still corrupt.
This is my job detail:
And this is the settings in the tFileOutputExcel
I got this working by changing the transfer mode in the FTP component from 'ascii' to 'binary'. Such a simple thing but if this helps anyone else with this issue who is a newb like me :)

How to input multiple csv files in logstash (Elasicsearch). please give one simple example.

How to input multiple csv files in logstash (Elasicsearch). please give one simple example.
if I have five csv files in one folder & still new files may get created in same location so how can I process all new files also in logstash.
change in file path only. ( path => "/home/mahadev/data/*.csv)
So now we can able to read all csv files inside the data folder. if any new csv comes then it will get reflect into logstash.
Please note: the above file path we need to put in logstash's conf file. if you are new then please read about logstash configration file then read this.

File input not picking up copied or moved files Logstash

I'm successfully using logstash to parse json formated events and send them to elasticsearch. Each event is created in a seprate file. One event per file with .json extension.
Logstash is correctly picking up a file when i create it using "vi mydoc.json", paste in the content and save. However it does not pick up if I cp or mv a file.
The objective is to automatically copy files to a directory and then parse them by logstash.
Each file has a different name and size. I tried looking at logstash code to figure out what attribute it uses but couldnt find relevant code. I also tried deleting the .sincedb files but didn't help either.
The input config is as follows:
input {
file {
path => "/opt/rp/*.json"
type => "tp"
start_position => "beginning"
stat_interval => 1
}
}
How can I have logstash pick up copied files? What file stat attribute does it use to check if a file is new?
Thanks
You can switch from Logstash to Apache Flume: Flume has a Spooling-Directory-Source (Logstash's input {}) and a Elasticsearch-Sink (Logstash's output {}).
The Spooling-Directory-Source is exactly what you are looking for, afaics.
If you don't want to rewrite your Logstash-filter{} you can use Flume to collect the files and sink them into one file (see File-Roll-Sink) and let Logstash consume the events from it.
Be aware, that the file operations in Flume's spooling dir have to be atomic. Don't change a processed file or append to it.

itk ImageFileReader exception reading if I add VTK Imagewriter object creation

That's it:
I read successfully a DICOM file with itk::ImageFileReader.
Now I want to export an image.
I use vtkJPEGWriter.
When I add the line
vtkJPEGWriter* writer = vtkJPEGWriter::New();
even if that code doesn't run at the beginning of execution... I can't read the file. I comment the line, then I read the file again.
But the writer is not connected with the file reader. I don't get it. It has nothing to do at that moment!!
I'm wasting so much time, just trying to figure out what's the problem.
The problem is in the file. I don't know why it works with that file without that line. Really weird.
I just don't get it.
I will try with other files.
These lines are worked for me:
vtkSmartPointer<vtkJPEGWriter> JPEGWriter = vtkSmartPointer<vtkJPEGWriter>::New();
JPEGWriter->SetFileName("d:\\Tempx\\Pacienttest3\\Sagital.bmp");
JPEGWriter->SetInputConnection(m_pColor->GetOutputPort());
JPEGWriter->Write();
where m_pColor is kind of vtkImageMapToColors type ...

Resources