Skip to content

Commit fa61512

Browse files
authored
Merge pull request #84 from NirBenor/configurable-stale-cleanup-interval
made stale_cleanup_interval configurable
2 parents 7e41ff8 + ffca3e3 commit fa61512

File tree

4 files changed

+20
-5
lines changed

4 files changed

+20
-5
lines changed

CHANGELOG.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
## Unreleased
1+
## 4.3.0
2+
- Made `stale_cleanup_interval` configurable [#84](https://github.com/logstash-plugins/logstash-output-file/pull/84)
23
- CI: upgrade testing [#83](https://github.com/logstash-plugins/logstash-output-file/pull/83)
34

45
## 4.2.6

docs/index.asciidoc

+12-2
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ This plugin supports the following configuration options plus the <<plugins-{typ
4949
| <<plugins-{type}s-{plugin}-flush_interval>> |<<number,number>>|No
5050
| <<plugins-{type}s-{plugin}-gzip>> |<<boolean,boolean>>|No
5151
| <<plugins-{type}s-{plugin}-path>> |<<string,string>>|Yes
52+
| <<plugins-{type}s-{plugin}-stale_cleanup_interval>> |<<number,number>>|No
5253
| <<plugins-{type}s-{plugin}-write_behavior>> |<<string,string>>|No
5354
|=======================================================================
5455

@@ -132,6 +133,15 @@ E.g.: `path => "./test-%{+YYYY-MM-dd}.txt"` to create
132133
If you use an absolute path you cannot start with a dynamic string.
133134
E.g: `/%{myfield}/`, `/test-%{myfield}/` are not valid paths
134135

136+
[id="plugins-{type}s-{plugin}-stale_cleanup_interval"]
137+
===== `stale_cleanup_interval`
138+
139+
* Value type is <<number,number>>
140+
* Default value is `10`
141+
142+
Defines the interval, in seconds, between the stale files cleanup runs.
143+
The stale files cleanup cycle closes inactive files (i.e files not written to since the last cycle).
144+
135145
[id="plugins-{type}s-{plugin}-write_behavior"]
136146
===== `write_behavior`
137147

@@ -140,8 +150,8 @@ E.g: `/%{myfield}/`, `/test-%{myfield}/` are not valid paths
140150

141151
If `append`, the file will be opened for appending and each new event will be written at the end of the file.
142152
If `overwrite`, the file will be truncated before writing and only the most recent event will appear in the file.
143-
144153
[id="plugins-{type}s-{plugin}-common-options"]
154+
145155
include::{include_path}/{type}.asciidoc[]
146156

147-
:default_codec!:
157+
:default_codec!:

lib/logstash/outputs/file.rb

+5-1
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,11 @@ class LogStash::Outputs::File < LogStash::Outputs::Base
7373
# If `overwrite`, the file will be truncated before writing and only the most
7474
# recent event will appear in the file.
7575
config :write_behavior, :validate => [ "overwrite", "append" ], :default => "append"
76+
77+
# How often should the stale files cleanup cycle run (in seconds).
78+
# The stale files cleanup cycle closes inactive files (i.e files not written to since the last cycle).
79+
config :stale_cleanup_interval, :validate => :number, :default => 10
80+
7681

7782
default :codec, "json_lines"
7883

@@ -99,7 +104,6 @@ def register
99104
end
100105

101106
@last_stale_cleanup_cycle = Time.now
102-
@stale_cleanup_interval = 10
103107
end
104108

105109
def multi_receive_encoded(events_and_encoded)

logstash-output-file.gemspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Gem::Specification.new do |s|
22

33
s.name = 'logstash-output-file'
4-
s.version = '4.2.6'
4+
s.version = '4.3.0'
55
s.licenses = ['Apache License (2.0)']
66
s.summary = "Writes events to files on disk"
77
s.description = "This gem is a Logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/logstash-plugin install gemname. This gem is not a stand-alone program"

0 commit comments

Comments
 (0)