# Logstash Output File Rotate

**URL:** <https://discuss.elastic.co/t/logstash-output-file-rotate/76782>\
**Category:** Logstash\
**Created:** [February 28, 2017, 1:36pm UTC](https://discuss.elastic.co/t/logstash-output-file-rotate/76782 "2017-02-28T13:36:22Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![sdeshpande](https://avatars.discourse-cdn.com/v4/letter/s/7993a0/32.png) [@sdeshpande](https://discuss.elastic.co/u/sdeshpande)\
**Post date:** [February 28, 2017, 1:36pm UTC](https://discuss.elastic.co/t/logstash-output-file-rotate/76782/1 "2017-02-28T13:36:22Z")

</div>

Hi Guys,

Can someone please tell me if it is possible to rotate the Output File generated by Logstash output plugin ?  
In Logstash config I have following lines and was wondering if I can specify option to configure rotation.  
output {  
file {  
path =\> "/datacollection/lostash/output/packetbeat-%{+YYYY-MM-DD}.txt"  
gzip =\> true  
}  
}

Regards

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [February 28, 2017, 2:00pm UTC](https://discuss.elastic.co/t/logstash-output-file-rotate/76782/2 "2017-02-28T14:00:17Z")

</div>

What rotation options are you interested in?

---

<div class="post-metadata">

**Author:** ![sdeshpande](https://avatars.discourse-cdn.com/v4/letter/s/7993a0/32.png) [@sdeshpande](https://discuss.elastic.co/u/sdeshpande)\
**Post date:** [February 28, 2017, 2:05pm UTC](https://discuss.elastic.co/t/logstash-output-file-rotate/76782/3 "2017-02-28T14:05:17Z")

</div>

Looking for either per hour rotation or Size based rotation.

Regards

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [February 28, 2017, 2:08pm UTC](https://discuss.elastic.co/t/logstash-output-file-rotate/76782/4 "2017-02-28T14:08:35Z")

</div>

> Looking for either per hour rotation or

So change `%{+YYYY-MM-DD}` to e.g. `%{+YYYY-MM-DD-HH}` or whatever you like. But I'm pretty sure you should use YYYY-MM-dd instead of YYYY-MM-DD.

Note that the timestamp that's expanded in the expression above is `@timestamp`, which normally should be the event time rather than the current time.

> Size based rotation.

That's not supported (within Logstash itself anyway).

---

<div class="post-metadata">

**Author:** ![sdeshpande](https://avatars.discourse-cdn.com/v4/letter/s/7993a0/32.png) [@sdeshpande](https://discuss.elastic.co/u/sdeshpande)\
**Post date:** [February 28, 2017, 2:11pm UTC](https://discuss.elastic.co/t/logstash-output-file-rotate/76782/5 "2017-02-28T14:11:26Z")

</div>

Thank you. I will give this a try.

Regards

---

<div class="post-metadata">

**Author:** ![sdeshpande](https://avatars.discourse-cdn.com/v4/letter/s/7993a0/32.png) [@sdeshpande](https://discuss.elastic.co/u/sdeshpande)\
**Post date:** [February 28, 2017, 2:51pm UTC](https://discuss.elastic.co/t/logstash-output-file-rotate/76782/6 "2017-02-28T14:51:42Z")

</div>

Is there a way to convert the Hour in EST as opposed to UTC ?

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [February 28, 2017, 2:57pm UTC](https://discuss.elastic.co/t/logstash-output-file-rotate/76782/7 "2017-02-28T14:57:17Z")

</div>

Nope.

---

<div class="post-metadata">

**Author:** ![sdeshpande](https://avatars.discourse-cdn.com/v4/letter/s/7993a0/32.png) [@sdeshpande](https://discuss.elastic.co/u/sdeshpande)\
**Post date:** [February 28, 2017, 3:00pm UTC](https://discuss.elastic.co/t/logstash-output-file-rotate/76782/8 "2017-02-28T15:00:16Z")

</div>

So when presenting this data to analytics engine we will have to make the adjustment based on our timezone, is that correct ?

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [February 28, 2017, 3:08pm UTC](https://discuss.elastic.co/t/logstash-output-file-rotate/76782/9 "2017-02-28T15:08:03Z")

</div>

I don't know anything about your analytics engine and what it expects, but the `@timestamp` field and everything based on it is UTC.

---

<div class="post-metadata">

**Author:** ![sdeshpande](https://avatars.discourse-cdn.com/v4/letter/s/7993a0/32.png) [@sdeshpande](https://discuss.elastic.co/u/sdeshpande)\
**Post date:** [February 28, 2017, 3:11pm UTC](https://discuss.elastic.co/t/logstash-output-file-rotate/76782/10 "2017-02-28T15:11:09Z")

</div>

Thank you for the quick response.

---

<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:** [March 28, 2017, 3:12pm UTC](https://discuss.elastic.co/t/logstash-output-file-rotate/76782/11 "2017-03-28T15:12:04Z")

</div>

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