fluent-plugin-directory 0.1.0 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +24 -6
- data/fluent-plugin-directory.gemspec +2 -2
- data/lib/fluent/plugin/in_directory.rb +31 -30
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 55d77adfb2d0512e04037176adff4a2b82e16cf9264efce510eb61d88af5c64c
|
4
|
+
data.tar.gz: cc44c79f31f7194f6c45080cff9a4b6ed8cf6f3ba55f7ef827ea1a88d0d94ef0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ff2e8b35d7118616430406a4a6740ce9636d05c64fd2ec48e3a40f4108d2c927b2a6394a4ad1f7f58bfa579ab2dff5b5970cabeac6b7309ef001154d467c5233
|
7
|
+
data.tar.gz: 9e83689cd6e2da654949c702500798ded723e2d4f2db5c0a4635c2b165f483301faf62c0009761d2046862636e972a9b13cf98421acce63b0a0b0adf4a54aeb3
|
data/README.md
CHANGED
@@ -26,16 +26,34 @@ $ bundle
|
|
26
26
|
|
27
27
|
## Configuration
|
28
28
|
|
29
|
-
|
29
|
+
### content_key (string) (optional)
|
30
30
|
|
31
|
-
|
32
|
-
|
33
|
-
|
31
|
+
The field where the content of the file is stored in the output event.
|
32
|
+
|
33
|
+
Default value: `content`.
|
34
|
+
|
35
|
+
### filename_key (string) (optional)
|
36
|
+
|
37
|
+
The field where the name of the file is stored in the output event.
|
38
|
+
|
39
|
+
Default value: `filename`.
|
40
|
+
|
41
|
+
### path (string) (required)
|
42
|
+
|
43
|
+
The path of the folder to scan.
|
44
|
+
|
45
|
+
### run_interval (integer) (optional)
|
46
|
+
|
47
|
+
The interval (in seconds) to wait between scans.
|
48
|
+
|
49
|
+
Default value: `60`.
|
50
|
+
|
51
|
+
### tag (string) (required)
|
34
52
|
|
35
|
-
|
53
|
+
The tag added to the output event.
|
36
54
|
|
37
55
|
## Copyright
|
38
56
|
|
39
|
-
- Copyright(c) 2021-
|
57
|
+
- Copyright(c) 2021- Rémy DUTHU
|
40
58
|
- License
|
41
59
|
- Apache License, Version 2.0
|
@@ -3,8 +3,8 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |spec|
|
5
5
|
spec.name = "fluent-plugin-directory"
|
6
|
-
spec.version = "0.1.
|
7
|
-
spec.authors = ["
|
6
|
+
spec.version = "0.1.4"
|
7
|
+
spec.authors = ["Rémy DUTHU"]
|
8
8
|
spec.email = ["remyduthu@icloud.com"]
|
9
9
|
|
10
10
|
spec.summary = "A Fluentd input plugin to scan files recurrently from a directory"
|
@@ -1,5 +1,5 @@
|
|
1
1
|
#
|
2
|
-
# Copyright 2021-
|
2
|
+
# Copyright 2021- Rémy DUTHU
|
3
3
|
#
|
4
4
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
5
|
# you may not use this file except in compliance with the License.
|
@@ -20,19 +20,21 @@ module Fluent
|
|
20
20
|
class DirectoryInput < Fluent::Plugin::Input
|
21
21
|
Fluent::Plugin.register_input('directory', self)
|
22
22
|
|
23
|
-
|
24
|
-
|
23
|
+
helpers :timer
|
24
|
+
|
25
|
+
desc 'The maximum number of files processed in each run.'
|
26
|
+
config_param :batch_size, :integer, default: 10
|
25
27
|
|
26
|
-
desc 'The
|
27
|
-
config_param :
|
28
|
+
desc 'The field where the content of the file is stored in the output event.'
|
29
|
+
config_param :content_key, :string, default: 'content'
|
28
30
|
|
29
|
-
desc 'The name of the
|
31
|
+
desc 'The field where the name of the file is stored in the output event.'
|
30
32
|
config_param :filename_key, :string, default: 'filename'
|
31
33
|
|
32
|
-
desc 'The path of the folder to
|
34
|
+
desc 'The path of the folder to scan.'
|
33
35
|
config_param :path, :string
|
34
36
|
|
35
|
-
desc 'The
|
37
|
+
desc 'The interval (in seconds) to wait between scans.'
|
36
38
|
config_param :run_interval, :integer, default: 60
|
37
39
|
|
38
40
|
desc 'The tag added to the output event.'
|
@@ -41,9 +43,9 @@ module Fluent
|
|
41
43
|
def start
|
42
44
|
super
|
43
45
|
|
44
|
-
|
45
|
-
|
46
|
-
|
46
|
+
# See: https://docs.fluentd.org/plugin-helper-overview/api-plugin-helper-timer
|
47
|
+
timer_execute(:directory_timer, @run_interval) do
|
48
|
+
begin
|
47
49
|
# Use a stream to submit multiple events at the same time
|
48
50
|
multiEventStream = MultiEventStream.new
|
49
51
|
|
@@ -51,29 +53,28 @@ module Fluent
|
|
51
53
|
time = Fluent::Engine.now
|
52
54
|
|
53
55
|
# Read filenames in the directory
|
54
|
-
Dir
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
56
|
+
Dir
|
57
|
+
.glob(@path + '/*')
|
58
|
+
.take(@batch_size)
|
59
|
+
.each do |filename|
|
60
|
+
# Add the record to the stream
|
61
|
+
multiEventStream.add(
|
62
|
+
time,
|
63
|
+
{
|
64
|
+
@content_key => File.read(filename),
|
65
|
+
@filename_key => filename
|
66
|
+
}
|
67
|
+
)
|
68
|
+
|
69
|
+
# Remove the file
|
70
|
+
File.delete(filename)
|
71
|
+
end
|
67
72
|
|
68
73
|
# Send the events
|
69
74
|
router.emit_stream(tag, multiEventStream)
|
70
|
-
|
71
|
-
|
72
|
-
sleep(@run_interval)
|
75
|
+
rescue StandardError
|
76
|
+
yield(nil, nil)
|
73
77
|
end
|
74
|
-
rescue Exception => e
|
75
|
-
$log.warn 'Directory input error: ', e
|
76
|
-
$log.debug_backtrace(e.backtrace)
|
77
78
|
end
|
78
79
|
end
|
79
80
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-directory
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
7
|
+
- Rémy DUTHU
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-11-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -106,7 +106,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
106
106
|
- !ruby/object:Gem::Version
|
107
107
|
version: '0'
|
108
108
|
requirements: []
|
109
|
-
rubygems_version: 3.0.3
|
109
|
+
rubygems_version: 3.0.3.1
|
110
110
|
signing_key:
|
111
111
|
specification_version: 4
|
112
112
|
summary: A Fluentd input plugin to scan files recurrently from a directory
|