Skip to content

Commit c3c7847

Browse files
author
Guy Boertje
committed
Added info about the string duration variant on settings values. Added a changelog entry for string durations.
Fixes logstash-plugins#197
1 parent 28c0534 commit c3c7847

File tree

2 files changed

+71
-21
lines changed

2 files changed

+71
-21
lines changed

CHANGELOG.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
iteration rather than waiting for the end-of-file to be reached. Note: for gz files,
44
the sincedb entry can only be updated at the end of the file as it is not possible
55
to seek into a compressed file and begin reading from that position.
6-
[Issue #196](https://github.com/logstash-plugins/logstash-input-file/pull/196)
6+
[#196](https://github.com/logstash-plugins/logstash-input-file/pull/196)
7+
- Added support for String Durations in some settings e.g. `stat_interval => "750 ms"`
8+
[#194](https://github.com/logstash-plugins/logstash-input-file/pull/194)
79

810
## 4.1.2
911
- Fix `require winhelper` error in WINDOWS.

docs/index.asciidoc

+68-20
Original file line numberDiff line numberDiff line change
@@ -146,10 +146,15 @@ will not get picked up.
146146

147147
This plugin supports the following configuration options plus the <<plugins-{type}s-{plugin}-common-options>> described later.
148148

149+
[NOTE]
150+
Duration settings can be specified in text form e.g. "250 ms", this string will be converted into
151+
decimal seconds. There are quite a few supported natural and abbreviated durations,
152+
see <<string_duration,string duration>> for the details.
153+
149154
[cols="<,<,<",options="header",]
150155
|=======================================================================
151156
|Setting |Input type|Required
152-
| <<plugins-{type}s-{plugin}-close_older>> |<<number,number>>|No
157+
| <<plugins-{type}s-{plugin}-close_older>> |<<number,number>> or <<string_duration,string duration>>|No
153158
| <<plugins-{type}s-{plugin}-delimiter>> |<<string,string>>|No
154159
| <<plugins-{type}s-{plugin}-discover_interval>> |<<number,number>>|No
155160
| <<plugins-{type}s-{plugin}-exclude>> |<<array,array>>|No
@@ -159,15 +164,15 @@ This plugin supports the following configuration options plus the <<plugins-{typ
159164
| <<plugins-{type}s-{plugin}-file_completed_log_path>> |<<string,string>>|No
160165
| <<plugins-{type}s-{plugin}-file_sort_by>> |<<string,string>>, one of `["last_modified", "path"]`|No
161166
| <<plugins-{type}s-{plugin}-file_sort_direction>> |<<string,string>>, one of `["asc", "desc"]`|No
162-
| <<plugins-{type}s-{plugin}-ignore_older>> |<<number,number>>|No
167+
| <<plugins-{type}s-{plugin}-ignore_older>> |<<number,number>> or <<string_duration,string duration>>|No
163168
| <<plugins-{type}s-{plugin}-max_open_files>> |<<number,number>>|No
164169
| <<plugins-{type}s-{plugin}-mode>> |<<string,string>>, one of `["tail", "read"]`|No
165170
| <<plugins-{type}s-{plugin}-path>> |<<array,array>>|Yes
166-
| <<plugins-{type}s-{plugin}-sincedb_clean_after>> |<<number,number>>|No
171+
| <<plugins-{type}s-{plugin}-sincedb_clean_after>> |<<number,number>> or <<string_duration,string duration>>|No
167172
| <<plugins-{type}s-{plugin}-sincedb_path>> |<<string,string>>|No
168-
| <<plugins-{type}s-{plugin}-sincedb_write_interval>> |<<number,number>>|No
173+
| <<plugins-{type}s-{plugin}-sincedb_write_interval>> |<<number,number>> or <<string_duration,string duration>>|No
169174
| <<plugins-{type}s-{plugin}-start_position>> |<<string,string>>, one of `["beginning", "end"]`|No
170-
| <<plugins-{type}s-{plugin}-stat_interval>> |<<number,number>>|No
175+
| <<plugins-{type}s-{plugin}-stat_interval>> |<<number,number>> or <<string_duration,string duration>>|No
171176
|=======================================================================
172177

173178
Also see <<plugins-{type}s-{plugin}-common-options>> for a list of options supported by all
@@ -178,18 +183,18 @@ input plugins.
178183
[id="plugins-{type}s-{plugin}-close_older"]
179184
===== `close_older`
180185

181-
* Value type is <<number,number>>
182-
* Default value is `3600`
186+
* Value type is <<number,number>> or <<string_duration,string duration>>
187+
* Default value is `"1 hour"`
183188

184189
The file input closes any files that were last read the specified
185-
timespan in seconds ago.
190+
duration (seconds if a number is specified) ago.
186191
This has different implications depending on if a file is being tailed or
187192
read. If tailing, and there is a large time gap in incoming data the file
188193
can be closed (allowing other files to be opened) but will be queued for
189194
reopening when new data is detected. If reading, the file will be closed
190195
after closed_older seconds from when the last bytes were read.
191196
This setting is retained for backward compatibility if you upgrade the
192-
plugin to 5.0.0+, are reading not tailing and do not switch to using Read mode.
197+
plugin to 4.1.0+, are reading not tailing and do not switch to using Read mode.
193198

194199
[id="plugins-{type}s-{plugin}-delimiter"]
195200
===== `delimiter`
@@ -206,8 +211,10 @@ this setting is not used, instead the standard Windows or Unix line endings are
206211
* Value type is <<number,number>>
207212
* Default value is `15`
208213

209-
How often (in seconds) we expand the filename patterns in the
210-
`path` option to discover new files to watch.
214+
How often we expand the filename patterns in the `path` option to discover new files to watch.
215+
This value is a multiple to `stat_interval`, e.g. if `stat_interval` is "500 ms" then new files
216+
files could be discovered every 15 X 500 milliseconds - 7.5 seconds.
217+
In practice, this will be the best case because the time taken to read new content needs to be factored in.
211218

212219
[id="plugins-{type}s-{plugin}-exclude"]
213220
===== `exclude`
@@ -294,11 +301,11 @@ If you use special naming conventions for the file full paths then perhaps
294301
[id="plugins-{type}s-{plugin}-ignore_older"]
295302
===== `ignore_older`
296303

297-
* Value type is <<number,number>>
304+
* Value type is <<number,number>> or <<string_duration,string duration>>
298305
* There is no default value for this setting.
299306

300307
When the file input discovers a file that was last modified
301-
before the specified timespan in seconds, the file is ignored.
308+
before the specified duration (seconds if a number is specified), the file is ignored.
302309
After it's discovery, if an ignored file is modified it is no
303310
longer ignored and any new data is read. By default, this option is
304311
disabled. Note this unit is in seconds.
@@ -354,9 +361,9 @@ on the {logstash-ref}/configuration-file-structure.html#array[Logstash configura
354361
[id="plugins-{type}s-{plugin}-sincedb_clean_after"]
355362
===== `sincedb_clean_after`
356363

357-
* Value type is <<number,number>>
358-
* The default value for this setting is 14.
359-
* This unit is in *days* and can be decimal e.g. 0.5 is 12 hours.
364+
* Value type is <<number,number>> or <<string_duration,string duration>>
365+
* The default value for this setting is "2 weeks".
366+
* If a number is specified then it is interpreted as *days* and can be decimal e.g. 0.5 is 12 hours.
360367

361368
The sincedb record now has a last active timestamp associated with it.
362369
If no changes are detected in a tracked file in the last N days its sincedb
@@ -378,8 +385,8 @@ NOTE: it must be a file path and not a directory path
378385
[id="plugins-{type}s-{plugin}-sincedb_write_interval"]
379386
===== `sincedb_write_interval`
380387

381-
* Value type is <<number,number>>
382-
* Default value is `15`
388+
* Value type is <<number,number>> or <<string_duration,string duration>>
389+
* Default value is `"15 seconds"`
383390

384391
How often (in seconds) to write a since database with the current position of
385392
monitored log files.
@@ -404,15 +411,56 @@ position recorded in the sincedb file will be used.
404411
[id="plugins-{type}s-{plugin}-stat_interval"]
405412
===== `stat_interval`
406413

407-
* Value type is <<number,number>>
408-
* Default value is `1`
414+
* Value type is <<number,number>> or <<string_duration,string duration>>
415+
* Default value is `"1 second"`
409416

410417
How often (in seconds) we stat files to see if they have been modified.
411418
Increasing this interval will decrease the number of system calls we make,
412419
but increase the time to detect new log lines.
420+
[NOTE]
421+
Discovering new files and checking whether they have grown/or shrunk occurs in a loop.
422+
This loop will sleep for `stat_interval` seconds before looping again. However, if files
423+
have grown, the new content is read and lines are enqueued.
424+
Reading and enqueuing across all grown files can take time, especially if
425+
the pipeline is congested. So the overall loop time is a combination of the
426+
`stat_interval` and the file read time.
413427

414428
[id="plugins-{type}s-{plugin}-common-options"]
415429
include::{include_path}/{type}.asciidoc[]
416430

417431
:default_codec!:
418432

433+
[id="string_duration"]
434+
// Move this to the includes when we make string durations available generally.
435+
==== String Durations
436+
437+
Format is `number` `string` and the space between these is optional.
438+
So "45s" and "45 s" are both valid.
439+
[TIP]
440+
Use the most suitable duration, for example, "3 days" rather than "72 hours".
441+
442+
===== Weeks
443+
Supported values: `w` `week` `weeks`, e.g. "2 w", "1 week", "4 weeks".
444+
445+
===== Days
446+
Supported values: `d` `day` `days`, e.g. "2 d", "1 day", "2.5 days".
447+
448+
===== Hours
449+
Supported values: `h` `hour` `hours`, e.g. "4 h", "1 hour", "0.5 hours".
450+
451+
===== Minutes
452+
Supported values: `m` `min` `minute` `minutes`, e.g. "45 m", "35 min", "1 minute", "6 minutes".
453+
454+
===== Seconds
455+
Supported values: `s` `sec` `second` `seconds`, e.g. "45 s", "15 sec", "1 second", "2.5 seconds".
456+
457+
===== Milliseconds
458+
Supported values: `ms` `msec` `msecs`, e.g. "500 ms", "750 msec", "50 msecs
459+
[NOTE]
460+
`milli` `millis` and `milliseconds` are not supported
461+
462+
===== Microseconds
463+
Supported values: `us` `usec` `usecs`, e.g. "600 us", "800 usec", "900 usecs"
464+
[NOTE]
465+
`micro` `micros` and `microseconds` are not supported
466+

0 commit comments

Comments
 (0)