# Any functions to put sequence number on file names?

**URL:** <https://discuss.elastic.co/t/any-functions-to-put-sequence-number-on-file-names/156997>\
**Category:** Logstash\
**Created:** [November 16, 2018, 7:43am UTC](https://discuss.elastic.co/t/any-functions-to-put-sequence-number-on-file-names/156997 "2018-11-16T07:43:42Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![sho](https://avatars.discourse-cdn.com/v4/letter/s/a698b9/32.png) [@sho](https://discuss.elastic.co/u/sho)\
**Post date:** [November 16, 2018, 7:43am UTC](https://discuss.elastic.co/t/any-functions-to-put-sequence-number-on-file-names/156997/1 "2018-11-16T07:43:42Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![staodd](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/staodd/32/24509_2.png) [@staodd](https://discuss.elastic.co/u/staodd)\
**Post date:** [November 16, 2018, 11:22am UTC](https://discuss.elastic.co/t/any-functions-to-put-sequence-number-on-file-names/156997/2 "2018-11-16T11:22:43Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![sho](https://avatars.discourse-cdn.com/v4/letter/s/a698b9/32.png) [@sho](https://discuss.elastic.co/u/sho)\
**Post date:** [November 19, 2018, 3:48am UTC](https://discuss.elastic.co/t/any-functions-to-put-sequence-number-on-file-names/156997/3 "2018-11-19T03:48:59Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![sho](https://avatars.discourse-cdn.com/v4/letter/s/a698b9/32.png) [@sho](https://discuss.elastic.co/u/sho)\
**Post date:** [November 19, 2018, 5:32am UTC](https://discuss.elastic.co/t/any-functions-to-put-sequence-number-on-file-names/156997/4 "2018-11-19T05:32:15Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![staodd](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/staodd/32/24509_2.png) [@staodd](https://discuss.elastic.co/u/staodd)\
**Post date:** [November 20, 2018, 2:33pm UTC](https://discuss.elastic.co/t/any-functions-to-put-sequence-number-on-file-names/156997/5 "2018-11-20T14:33:29Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![sho](https://avatars.discourse-cdn.com/v4/letter/s/a698b9/32.png) [@sho](https://discuss.elastic.co/u/sho)\
**Post date:** [November 21, 2018, 12:55am UTC](https://discuss.elastic.co/t/any-functions-to-put-sequence-number-on-file-names/156997/6 "2018-11-21T00:55:23Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![staodd](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/staodd/32/24509_2.png) [@staodd](https://discuss.elastic.co/u/staodd)\
**Post date:** [November 21, 2018, 6:47am UTC](https://discuss.elastic.co/t/any-functions-to-put-sequence-number-on-file-names/156997/7 "2018-11-21T06:47:02Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![sho](https://avatars.discourse-cdn.com/v4/letter/s/a698b9/32.png) [@sho](https://discuss.elastic.co/u/sho)\
**Post date:** [November 22, 2018, 12:40am UTC](https://discuss.elastic.co/t/any-functions-to-put-sequence-number-on-file-names/156997/8 "2018-11-22T00:40:16Z")

</div>

Thank you again, I could find that. 🙂

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

---

<div class="post-metadata">

**Author:** ![staodd](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/staodd/32/24509_2.png) [@staodd](https://discuss.elastic.co/u/staodd)\
**Post date:** [November 23, 2018, 6:27am UTC](https://discuss.elastic.co/t/any-functions-to-put-sequence-number-on-file-names/156997/9 "2018-11-23T06:27:22Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![sho](https://avatars.discourse-cdn.com/v4/letter/s/a698b9/32.png) [@sho](https://discuss.elastic.co/u/sho)\
**Post date:** [November 26, 2018, 12:35am UTC](https://discuss.elastic.co/t/any-functions-to-put-sequence-number-on-file-names/156997/10 "2018-11-26T00:35:02Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [December 24, 2018, 12:35am UTC](https://discuss.elastic.co/t/any-functions-to-put-sequence-number-on-file-names/156997/11 "2018-12-24T00:35:13Z")

</div>

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