Any functions to put sequence number on file names?


#1

I'm looking for the function for putting sequence number on output file name.
(I'm not sure that Logstash has this function though.. let me know if it doesn't exist..)

Thanks & Regards,
Sho


(Staale) #2

You could probably use some ruby code to implement it. Would be much more helpful if you explain what you are trying to achieve.


#3

Thank you for your reply.

I'm trying to create a server for gathering logs from multiple windows/linux servers.
Also, it contains software logs such as tomcat, apache, oracle databases, and so on.

As there are so much logs to gather, I wanted to divide them day by day or by size.
However, I didn't have any idea how to do this with logstash function itself.
That's why I asked here how I can put sequence numbers on file names.

Thanks, and Regards,
Sho


#4

Let me add to my own reply.
I'm NOT trying to gather multiple softwares' logs to one file.
I just wanted to divide by day or by size on each software logs.


(Staale) #5

Sorry, I forgot to come back to you.
Its easy to divide day by day.
you can use %{+YYYYMMDD} as part of the filename:

file {
path => " /output/directory/filename-%{YYYYMMdd}.log"
}

#6

Thank you for remembering me. :stuck_out_tongue:
I appreciate for your reply. Are there any documentation or web page that is wrote about this?


(Staale) #7

It is listed in the documentation on the file output plugin: https://www.elastic.co/guide/en/logstash/current/plugins-outputs-file.html
Look at the path option.


#8

Thank you again, I could find that. :slight_smile:

Can I have one more question?
Now, I understood that I can do dividing files day by day.
Is it able to delete old log files?
If I can do this, we will able to say that we can rotate logs then..

Thanks & Regards,
Sho


(Staale) #9

Depending on what OS you are running on i would just add a scheduled task to clean out old files.
There are a lot of articles to be found on logfile management. Logstash does not have a builtin cleanup for your output files. At least not that I've bothered looking for as a script does the job.


#10

Thank you very much for your replies.
I understood that it is much easier to use scheduled tasks to clean out old files.

As I'm going to use Logstash on linux OS, we will create one shell script for that.
Again, thank you very much for your advices.

Regards,
Sho