Skip to content

Commit 7c3aadb

Browse files
committed
Rename *_close to *_inactive
* Rename close_older to close_inactive * Rename clean_idle to clean_inactive
1 parent 04a0491 commit 7c3aadb

18 files changed

+104
-83
lines changed

CHANGELOG.asciidoc

+3-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ https://github.com/elastic/beats/compare/v5.0.0-alpha4...master[Check the HEAD d
2626
*Filebeat*
2727

2828
- Stop following symlink. Symlinks are now ignored: {pull}1686[1686]
29-
- Deprecate force_close_files option and replace it with close_removed and close_renamed {issue}1600[1600]
3029

3130
*Winlogbeat*
3231

@@ -85,6 +84,9 @@ https://github.com/elastic/beats/compare/v5.0.0-alpha4...master[Check the HEAD d
8584
*Topbeat*
8685

8786
*Filebeat*
87+
- Deprecate close_older option and replace it with close_inactive {issue}2051[2051]
88+
- Deprecate force_close_files option and replace it with close_removed and close_renamed {issue}1600[1600]
89+
8890

8991
*Winlogbeat*
9092

filebeat/docs/reference/configuration/filebeat-options.asciidoc

+15-15
Original file line numberDiff line numberDiff line change
@@ -180,28 +180,28 @@ For comparison, `ignore_older` relies on the modification time of the file. In c
180180

181181
`ignore_older` can be especially useful if you keep log files for a long time and you start filebeat, but only want to send the newest files to elasticsearch and the old files from the last week, but not all files.
182182

183-
To remove the state from the registry file for files which were harvested before, the `clean_idle` configuration option has to be used.
183+
To remove the state from the registry file for files which were harvested before, the `clean_inactive` configuration option has to be used.
184184

185185

186-
Requirement: ignore_older > close_idle
186+
Requirement: ignore_older > close_inactive
187187

188-
Before a file can be ignored by the prospector, it must be closed. To ensure a file is not harvested anymore when it is ignored, ignore_older must be set to a longer duration then `close_idle`. It can happen, that a file is still harvested but already falls under `ignore_older` as the harvester didn't finish yet. The harvester will finish reading and close it after `close_idle` is reached.
188+
Before a file can be ignored by the prospector, it must be closed. To ensure a file is not harvested anymore when it is ignored, ignore_older must be set to a longer duration then `close_inactive`. It can happen, that a file is still harvested but already falls under `ignore_older` as the harvester didn't finish yet. The harvester will finish reading and close it after `close_inactive` is reached.
189189

190190
[[close-options]]
191191
===== close_*
192192

193193
All `close_*` configuration options are used to close the harvester after a certain criteria or time. Closing the harvester means closing the file handler. In case a file is updated again after the harvester is closed, it will be picked up again after <<scan-frequency>>. It is important to understand, in case the file was moved away or deleted during this period, filebeat will not be able to pick up the file again and any data that the harvester didn't read so far is lost.
194194

195-
[[close-idle]]
196-
===== close_idle
195+
[[close-inactive]]
196+
===== close_inactive
197197

198-
After a file was not harvested for the duration of `close_idle`, the file handle will be closed. The counter for the defined period starts when the last log line was read by the harvester, it is not based on the modification time of the file. In case the closed file changes again, a new harvester is started again, latest after `scan_frequency`.
198+
After a file was not harvested for the duration of `close_inactive`, the file handle will be closed. The counter for the defined period starts when the last log line was read by the harvester, it is not based on the modification time of the file. In case the closed file changes again, a new harvester is started again, latest after `scan_frequency`.
199199

200-
It is recommended to set `close_idle` to a value that is larger then the least frequent updates to your log file. In case your log file gets updated every few seconds, you can safely set it to `1m`. If there are log files with very different update rates, multiple prospector configurations with different values can be used.
200+
It is recommended to set `close_inactive` to a value that is larger then the least frequent updates to your log file. In case your log file gets updated every few seconds, you can safely set it to `1m`. If there are log files with very different update rates, multiple prospector configurations with different values can be used.
201201

202-
Setting `close_idle` to a lower value means file handles are closed faster but has the side affect that new log lines are not sent in near real time in case the harvester was closed.
202+
Setting `close_inactive` to a lower value means file handles are closed faster but has the side affect that new log lines are not sent in near real time in case the harvester was closed.
203203

204-
The timestamp for closing a file does not depend on the modification time of the file but an internal timestamp that is update when the file was last harvested. If `close_idle` is set to 5 minutes, the countdown for the 5 minutes starts the last time the harvester read a line from the file.
204+
The timestamp for closing a file does not depend on the modification time of the file but an internal timestamp that is update when the file was last harvested. If `close_inactive` is set to 5 minutes, the countdown for the 5 minutes starts the last time the harvester read a line from the file.
205205

206206
You can use time strings like 2h (2 hours) and 5m (5 minutes). The default is 1h.
207207

@@ -218,7 +218,7 @@ WINDOWS: In case under windows your log rotation system shows errors because it
218218

219219
WARNING: Only use this options if you understand the potential side affects with potential data loss.
220220

221-
Close removed can be used to close a harvester directly when a file is removed. Normally a file should only be removed after it already falls under `close_idle`. In case files are removed early, without this option filebeat keeps the file open to make sure finishing is completed. In case the file handle should be released immediately after removal, this option can be used.
221+
Close removed can be used to close a harvester directly when a file is removed. Normally a file should only be removed after it already falls under `close_inactive`. In case files are removed early, without this option filebeat keeps the file open to make sure finishing is completed. In case the file handle should be released immediately after removal, this option can be used.
222222

223223

224224
WINDOWS: In case under windows your log rotation system shows error because it can't rotated the files, this is the option to enabled.
@@ -241,17 +241,17 @@ Close timeout gives every harvester a predefined lifetime. Independent of the lo
241241

242242
The `clean_*` variables are used to clean up the state entries. This helps to reduce the size of the registry file and can prevent a potential <<inode-reuse-issue>>. These options are disabled by default as wrong settings can lead to data duplicatin as complete log files are sent again.
243243

244-
===== clean_idle
244+
===== clean_inactive
245245

246246
WARNING: Only use this options if you understand the potential side affects with potential data loss.
247247

248-
`clean_idle` removes the state of the file after the given period. The state for files can only be removed if the file is already ignored by filebeat, means it's falling under `ignore_older`. The requirement for clean idle is `clean_idle > ignore_older + scan_frequency` to make sure no states are removed when a file is still harvested. Otherwise it could lead to resending the full content constantly as clean_idle removes state for files which are still detected by the prospector. In case a file is updated or appears again, the file is read from the beginning.
248+
`clean_inactive` removes the state of the file after the given period. The state for files can only be removed if the file is already ignored by filebeat, means it's falling under `ignore_older`. The requirement for clean idle is `clean_inactive > ignore_older + scan_frequency` to make sure no states are removed when a file is still harvested. Otherwise it could lead to resending the full content constantly as `clean_inactive` removes state for files which are still detected by the prospector. In case a file is updated or appears again, the file is read from the beginning.
249249

250-
The `clean_idle` configuration option is useful to reduce the size of the registry file, especially if a large amount of new files are generated every day.
250+
The `clean_inactive` configuration option is useful to reduce the size of the registry file, especially if a large amount of new files are generated every day.
251251

252252
In addition this config option is useful to prevent the <<inode-reuse-issue>>. If a file is deleted, the inode can be reused by a newly created file. If the inode is the same, filebeat assumes to know the file and continues at the old position. As this issues gets more probable over time, it is good to cleanup the old states to make sure filebeat does not assume it already knows the file.
253253

254-
NOTE: Every time a file is renamed, the file state will be updated and the counter for `clean_idle` will start at 0 again.
254+
NOTE: Every time a file is renamed, the file state will be updated and the counter for `clean_inactive` will start at 0 again.
255255

256256
===== clean_removed
257257

@@ -270,7 +270,7 @@ directory is scanned for files using the frequency specified by
270270
`scan_frequency`. Specify 1s to scan the directory as frequently as possible
271271
without causing Filebeat to scan too frequently. We do not recommend to set this value `<1s`.
272272

273-
If you require log lines to be sent in near real time do not use a very low `scan_frequency` but adjust `close_idle` so the file handler stays open and constantly polls your files.
273+
If you require log lines to be sent in near real time do not use a very low `scan_frequency` but adjust `close_inactive` so the file handler stays open and constantly polls your files.
274274

275275
The default setting is 10s.
276276

filebeat/docs/troubleshooting.asciidoc

+4-4
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ include::../../libbeat/docs/getting-help.asciidoc[]
1515

1616
== Reduce open file handlers
1717

18-
Filebeat keeps the file handler open in case it reaches the end of a file to read new log lines in near real time. If filebeat is harvesting a large number of files, the number of open files can be become an issue. In most environments, the number of files which are actively updated is low. The configuration `close_idle` should be set accordingly to close files which are not active any more.
18+
Filebeat keeps the file handler open in case it reaches the end of a file to read new log lines in near real time. If filebeat is harvesting a large number of files, the number of open files can be become an issue. In most environments, the number of files which are actively updated is low. The configuration `close_inactive` should be set accordingly to close files which are not active any more.
1919

2020
There are 4 more configuration options which can be used to close file handlers, but all of them should be used carefully as they can side affects. The options are:
2121

@@ -32,16 +32,16 @@ Before using any of these variables, make sure to study the documentation on eac
3232
[[reduce-registry-size]]
3333
== Reduce Registry File Size
3434

35-
Filebeat keeps all states of the files and persists the states on disk in the `registry_file`. The states are used to continue file reading at a previous position in case filebeat is restarted. In case every day a large amount of new files is constantly produced, the registry file grows over time. To reduce the size of the registry file, there are two configuration variables: `clean_removed` and `clean_idle`.
35+
Filebeat keeps all states of the files and persists the states on disk in the `registry_file`. The states are used to continue file reading at a previous position in case filebeat is restarted. In case every day a large amount of new files is constantly produced, the registry file grows over time. To reduce the size of the registry file, there are two configuration variables: `clean_removed` and `close_inactive`.
3636

37-
In case old files are not touched anymore and fall under `ignore_older`, it is recommended to use `clean_idle`. If on the other size old files get removed from disk `clean_removed` can be used.
37+
In case old files are not touched anymore and fall under `ignore_older`, it is recommended to use `clean_inactive`. If on the other size old files get removed from disk `clean_removed` can be used.
3838

3939
[[inode-reuse-issue]]
4040
== Inode Reuse Issue
4141

4242
Filebeat uses under linux inode and device to identify files. In case a file is removed from disk, the inode can again be assigned to a new file. In the case of file rotation where and old file is removed and a new one is directly created afterwards, it can happen that the new files has the exact same inode. In this case, Filebeat assumes that the new file is the same as the old and tries to continue reading at the old position which is not correct.
4343

44-
By default states are never removed from the registry file. In case of inode reuse issue it is recommended to use the `clean_*` options, especially `clean_idle`. In case your files get rotated every 24 hours and the rotated files rotated files are not updated anymore, `ignore_older` could be set to 48 hours and `clean_idle` 72 hours.
44+
By default states are never removed from the registry file. In case of inode reuse issue it is recommended to use the `clean_*` options, especially `clean_inactive`. In case your files get rotated every 24 hours and the rotated files rotated files are not updated anymore, `ignore_older` could be set to 48 hours and `clean_inactive` 72 hours.
4545

4646
`clean_removed` can be used for files that are removed from disk. Be aware that `clean_removed` also applies if during one scan a file cannot be found anymore. In case the file shows up at a later stage again, it will be sent again from scratch.
4747

filebeat/etc/beat.full.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -163,10 +163,10 @@ filebeat.prospectors:
163163

164164
### Harvester closing options
165165

166-
# Close idle closes the file handler after the predefined period.
166+
# Close inactive closes the file handler after the predefined period.
167167
# The period starts when the last line of the file was, not the file ModTime.
168168
# Time strings like 2h (2 hours), 5m (5 minutes) can be used.
169-
#close_idle: 1h
169+
#close_inactive: 1h
170170

171171
# Close renamed closes a file handler when the file is renamed or rotated.
172172
# Note: Potential data loss. Make sure to read and understand the docs for this option.
@@ -191,9 +191,9 @@ filebeat.prospectors:
191191

192192
### State options
193193

194-
# Files for the modification data is older then clean_older the state from the registry is removed
194+
# Files for the modification data is older then clean_inactive the state from the registry is removed
195195
# By default this is disabled.
196-
#clean_idle: 0
196+
#clean_inactive: 0
197197

198198
# Removes the state for file which cannot be found on disk anymore immediately
199199
#clean_removed: false

filebeat/filebeat.full.yml

+7-7
Original file line numberDiff line numberDiff line change
@@ -163,10 +163,10 @@ filebeat.prospectors:
163163

164164
### Harvester closing options
165165

166-
# Close idle closes the file handler after the predefined period.
166+
# Close inactive closes the file handler after the predefined period.
167167
# The period starts when the last line of the file was, not the file ModTime.
168168
# Time strings like 2h (2 hours), 5m (5 minutes) can be used.
169-
#close_idle: 1h
169+
#close_inactive: 1h
170170

171171
# Close renamed closes a file handler when the file is renamed or rotated.
172172
# Note: Potential data loss. Make sure to read and understand the docs for this option.
@@ -191,9 +191,9 @@ filebeat.prospectors:
191191

192192
### State options
193193

194-
# Files for the modification data is older then clean_older the state from the registry is removed
194+
# Files for the modification data is older then clean_inactive the state from the registry is removed
195195
# By default this is disabled.
196-
#clean_idle: 0
196+
#clean_inactive: 0
197197

198198
# Removes the state for file which cannot be found on disk anymore immediately
199199
#clean_removed: false
@@ -273,8 +273,8 @@ filebeat.prospectors:
273273

274274
#================================ Processors =====================================
275275

276-
# Processors are used to reduce the number of fields in the exported event or to
277-
# enhance the event with external meta data. This section defines a list of processors
276+
# Processors are used to reduce the number of fields in the exported event or to
277+
# enhance the event with external meta data. This section defines a list of processors
278278
# that are applied one by one and the first one receives the initial event:
279279
#
280280
# event -> filter1 -> event1 -> filter2 ->event2 ...
@@ -380,7 +380,7 @@ output.elasticsearch:
380380
#template.overwrite: false
381381

382382
# If set to true, filebeat checks the Elasticsearch version at connect time, and if it
383-
# is 2.x, it loads the file specified by the template.versions.2x.path setting. The
383+
# is 2.x, it loads the file specified by the template.versions.2x.path setting. The
384384
# default is true.
385385
#template.versions.2x.enabled: true
386386

filebeat/harvester/config.go

+8-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ var (
2222
Backoff: 1 * time.Second,
2323
BackoffFactor: 2,
2424
MaxBackoff: 10 * time.Second,
25-
CloseOlder: 1 * time.Hour,
25+
CloseInactive: 1 * time.Hour,
2626
MaxBytes: 10 * humanize.MiByte,
2727
CloseRemoved: false,
2828
CloseRenamed: false,
@@ -41,6 +41,7 @@ type harvesterConfig struct {
4141
Backoff time.Duration `config:"backoff" validate:"min=0,nonzero"`
4242
BackoffFactor int `config:"backoff_factor" validate:"min=1"`
4343
MaxBackoff time.Duration `config:"max_backoff" validate:"min=0,nonzero"`
44+
CloseInactive time.Duration `config:"close_inactive"`
4445
CloseOlder time.Duration `config:"close_older"`
4546
CloseRemoved bool `config:"close_removed"`
4647
CloseRenamed bool `config:"close_renamed"`
@@ -62,6 +63,12 @@ func (config *harvesterConfig) Validate() error {
6263
logp.Warn("DEPRECATED: force_close_files was set to true. Use close_removed + close_rename")
6364
}
6465

66+
// DEPRECATED: remove in 6.0
67+
if config.CloseOlder > 0 {
68+
config.CloseInactive = config.CloseOlder
69+
logp.Warn("DEPRECATED: close_older is deprecated. Use close_inactive")
70+
}
71+
6572
// Check input type
6673
if _, ok := cfg.ValidInputType[config.InputType]; !ok {
6774
return fmt.Errorf("Invalid input type: %v", config.InputType)

filebeat/harvester/config_test.go

+13
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package harvester
22

33
import (
44
"testing"
5+
"time"
56

67
"github.com/stretchr/testify/assert"
78
)
@@ -20,3 +21,15 @@ func TestForceCloseFiles(t *testing.T) {
2021
assert.True(t, config.CloseRemoved)
2122
assert.True(t, config.CloseRenamed)
2223
}
24+
25+
func TestCloseOlder(t *testing.T) {
26+
27+
config := defaultConfig
28+
assert.Equal(t, config.CloseOlder, 0*time.Hour)
29+
assert.Equal(t, config.CloseInactive, defaultConfig.CloseInactive)
30+
31+
config.CloseOlder = 5 * time.Hour
32+
config.Validate()
33+
34+
assert.Equal(t, config.CloseInactive, 5*time.Hour)
35+
}

filebeat/harvester/log.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ func (h *Harvester) newLogFileReaderConfig() reader.LogFileReaderConfig {
277277
return reader.LogFileReaderConfig{
278278
CloseRemoved: h.config.CloseRemoved,
279279
CloseRenamed: h.config.CloseRenamed,
280-
CloseOlder: h.config.CloseOlder,
280+
CloseInactive: h.config.CloseInactive,
281281
CloseEOF: h.config.CloseEOF,
282282
Backoff: h.config.Backoff,
283283
MaxBackoff: h.config.MaxBackoff,

filebeat/harvester/log_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ func TestReadLine(t *testing.T) {
5959

6060
h := Harvester{
6161
config: harvesterConfig{
62-
CloseOlder: 500 * time.Millisecond,
62+
CloseInactive: 500 * time.Millisecond,
6363
Backoff: 100 * time.Millisecond,
6464
MaxBackoff: 1 * time.Second,
6565
BackoffFactor: 2,

filebeat/harvester/reader/log.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ type LogFileReaderConfig struct {
3232
MaxBackoff time.Duration
3333
BackoffFactor int
3434
CloseEOF bool
35-
CloseOlder time.Duration
35+
CloseInactive time.Duration
3636
CloseRenamed bool
3737
CloseRemoved bool
3838
}
@@ -129,9 +129,9 @@ func (r *logFileReader) errorChecks(err error) error {
129129
return ErrFileTruncate
130130
}
131131

132-
// Check file wasn't read for longer then CloseOlder
132+
// Check file wasn't read for longer then CloseInactive
133133
age := time.Since(r.lastTimeRead)
134-
if age > r.config.CloseOlder {
134+
if age > r.config.CloseInactive {
135135
return ErrInactive
136136
}
137137

filebeat/prospector/config.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ var (
1313
IgnoreOlder: 0,
1414
ScanFrequency: 10 * time.Second,
1515
InputType: cfg.DefaultInputType,
16-
CleanOlder: 0,
16+
CleanInactive: 0,
1717
CleanRemoved: false,
1818
}
1919
)
@@ -24,7 +24,7 @@ type prospectorConfig struct {
2424
Paths []string `config:"paths"`
2525
ScanFrequency time.Duration `config:"scan_frequency"`
2626
InputType string `config:"input_type"`
27-
CleanOlder time.Duration `config:"clean_older" validate:"min=0"`
27+
CleanInactive time.Duration `config:"clean_inactive" validate:"min=0"`
2828
CleanRemoved bool `config:"clean_removed"`
2929
}
3030

0 commit comments

Comments
 (0)