fluent-plugin-windows-eventlog 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +28 -38
- data/appveyor.yml +27 -0
- data/fluent-plugin-winevtlog.gemspec +1 -1
- data/lib/fluent/plugin/in_windows_eventlog.rb +26 -14
- data/test/generate-windows-event.rb +47 -0
- data/test/helper.rb +3 -0
- data/test/plugin/test_in_winevtlog.rb +21 -24
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 44561910d111a16a85de6b5d9faee8cf052fed71
|
4
|
+
data.tar.gz: 2bc58308403d20000efe50f2b6f73e86a9a6585a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 194172daa6b8dd788a785d89e392e3698fe7ed6b8ffa0de360ddc89bf2bd9d37818d8abd43bf5c6e71434cffdd603a91126f674ab80c45455aeffe969a5101c2
|
7
|
+
data.tar.gz: 2b45ac6f8ce1c4d142ce1aae21104945c2bdb706db26c57eb6f9a0e2ef90ba468a7b3fd5172242817c6e43f3b1575b2167bcd5f65ebd52600f4f461f3c0780ad
|
data/README.md
CHANGED
@@ -2,72 +2,62 @@
|
|
2
2
|
|
3
3
|
## Component
|
4
4
|
|
5
|
-
#### fluentd Input plugin for Windows Event Log
|
5
|
+
#### fluentd Input plugin for the Windows Event Log
|
6
6
|
|
7
|
-
[Fluentd](http://fluentd.org) plugin to read Windows Event Log.
|
8
|
-
You must use fluentd 'Windows' brach to use me, and it doesn't work on Linux of course.
|
7
|
+
[Fluentd](http://fluentd.org) plugin to read the Windows Event Log.
|
9
8
|
|
10
9
|
## Installation
|
11
10
|
gem install fluent-plugin-windows-eventlog
|
12
11
|
|
13
12
|
## Configuration
|
14
|
-
#### fluentd Input plugin for Windows Event Log
|
13
|
+
#### fluentd Input plugin for the Windows Event Log
|
15
14
|
|
16
15
|
<source>
|
17
16
|
@type windows_eventlog
|
17
|
+
@id windows_eventlog
|
18
18
|
channels application,system
|
19
|
-
pos_file c:\temp\mypos
|
20
19
|
read_interval 2
|
21
20
|
tag winevt.raw
|
22
|
-
@id windows_eventlog
|
23
21
|
<storage>
|
24
|
-
@type local # @type local is default.
|
25
|
-
persistent true #
|
22
|
+
@type local # @type local is the default.
|
23
|
+
persistent true # default is true. Set to false to use in-memory storage.
|
26
24
|
path ./tmp/storage.json # This is required when persistent is true.
|
27
|
-
# Or, please consider
|
25
|
+
# Or, please consider using <system> section's `root_dir` parameter.
|
28
26
|
</storage>
|
29
27
|
</source>
|
30
28
|
|
31
|
-
|
32
29
|
#### parameters
|
33
30
|
|
34
31
|
|name | description |
|
35
32
|
|:----- |:----- |
|
36
|
-
|
37
|
-
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
33
|
+
|`channels` | (option) 'application' as default. One or more of {'application', 'system', 'setup', 'security'}. If you want to read 'setup' or 'security' logs, you must launch fluentd with administrator privileges.|
|
34
|
+
|`keys` | (option) A subset of [keys](#read-keys) to read. Defaults to all keys.|
|
35
|
+
|`read_interval` | (option) Read interval in seconds. 2 seconds as default.|
|
36
|
+
|`from_encoding` | (option) Input character encoding. `nil` as default.|
|
37
|
+
|`encoding` | (option) Output character encoding. `nil` as default.|
|
38
|
+
|`read_from_head`| (option) Start to read the entries from the oldest, not from when fluentd is started. Defaults to `false`.|
|
39
|
+
|`<storage>` | Setting for `storage` plugin for recording read position like `in_tail`'s `pos_file`.|
|
42
40
|
|
43
41
|
#### read keys
|
44
|
-
This plugin reads
|
42
|
+
This plugin reads the following fields from Windows Event Log entries. Use the `keys` configuration option to select a subset. No other customization is allowed for now.
|
45
43
|
|
46
44
|
|key|
|
47
45
|
|:----- |
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
## Etc.
|
62
|
-
'read_from_head' is not supporeted currently.You can read newer records after you start first.
|
63
|
-
No customize to read information keys.
|
64
|
-
|
65
|
-
|
66
|
-
|
46
|
+
|`record_number` |
|
47
|
+
|`time_generated`|
|
48
|
+
|`time_written` |
|
49
|
+
|`event_id` |
|
50
|
+
|`event_type` |
|
51
|
+
|`event_category`|
|
52
|
+
|`source_name` |
|
53
|
+
|`computer_name` |
|
54
|
+
|`user` |
|
55
|
+
|`description` |
|
56
|
+
|`string_inserts`|
|
67
57
|
|
68
58
|
## Copyright
|
69
|
-
####Copyright
|
59
|
+
#### Copyright
|
70
60
|
Copyright(C) 2014- @okahashi117
|
71
|
-
####License
|
61
|
+
#### License
|
72
62
|
Apache License, Version 2.0
|
73
63
|
|
data/appveyor.yml
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
version: '{build}'
|
2
|
+
|
3
|
+
# init:
|
4
|
+
# - ps: iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))
|
5
|
+
|
6
|
+
install:
|
7
|
+
- SET PATH=C:\Ruby%ruby_version%\bin;%PATH%
|
8
|
+
- "%devkit%\\devkitvars.bat"
|
9
|
+
- ruby --version
|
10
|
+
- gem --version
|
11
|
+
- bundle install
|
12
|
+
build: off
|
13
|
+
test_script:
|
14
|
+
- bundle exec rake test
|
15
|
+
# - bundle exec rake test TESTOPTS=-v
|
16
|
+
|
17
|
+
branches:
|
18
|
+
only:
|
19
|
+
- master
|
20
|
+
|
21
|
+
# https://www.appveyor.com/docs/installed-software/#ruby
|
22
|
+
environment:
|
23
|
+
matrix:
|
24
|
+
- ruby_version: "23-x64"
|
25
|
+
devkit: C:\Ruby23-x64\DevKit
|
26
|
+
- ruby_version: "23"
|
27
|
+
devkit: C:\Ruby23\DevKit
|
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = "fluent-plugin-windows-eventlog"
|
7
|
-
spec.version = "0.2.
|
7
|
+
spec.version = "0.2.1"
|
8
8
|
spec.authors = ["okahashi117", "Hiroshi Hatake", "Masahiro Nakagawa"]
|
9
9
|
spec.email = ["naruki_okahashi@jbat.co.jp", "cosmo0920.oucc@gmail.com", "repeatedly@gmail.com"]
|
10
10
|
spec.summary = %q{Fluentd Input plugin to read windows event log.}
|
@@ -9,23 +9,24 @@ module Fluent::Plugin
|
|
9
9
|
helpers :timer, :storage
|
10
10
|
|
11
11
|
DEFAULT_STORAGE_TYPE = 'local'
|
12
|
-
KEY_MAP = {"record_number" => :record_number,
|
13
|
-
"time_generated" => :time_generated,
|
14
|
-
"time_written" => :time_written,
|
15
|
-
"event_id" => :event_id,
|
16
|
-
"event_type" => :event_type,
|
17
|
-
"event_category" => :category,
|
18
|
-
"source_name" => :source,
|
19
|
-
"computer_name" => :computer,
|
20
|
-
"user" => :user,
|
21
|
-
"description" => :description
|
12
|
+
KEY_MAP = {"record_number" => [:record_number, :string],
|
13
|
+
"time_generated" => [:time_generated, :string],
|
14
|
+
"time_written" => [:time_written, :string],
|
15
|
+
"event_id" => [:event_id, :string],
|
16
|
+
"event_type" => [:event_type, :string],
|
17
|
+
"event_category" => [:category, :string],
|
18
|
+
"source_name" => [:source, :string],
|
19
|
+
"computer_name" => [:computer, :string],
|
20
|
+
"user" => [:user, :string],
|
21
|
+
"description" => [:description, :string],
|
22
|
+
"string_inserts" => [:string_inserts, :array]}
|
22
23
|
|
23
24
|
config_param :tag, :string
|
24
25
|
config_param :read_interval, :time, default: 2
|
25
26
|
config_param :pos_file, :string, default: nil,
|
26
27
|
obsoleted: "This section is not used anymore. Use 'store_pos' instead."
|
27
|
-
config_param :channels, :array, default: ['
|
28
|
-
config_param :keys, :
|
28
|
+
config_param :channels, :array, default: ['application']
|
29
|
+
config_param :keys, :array, default: []
|
29
30
|
config_param :read_from_head, :bool, default: false
|
30
31
|
config_param :from_encoding, :string, default: nil
|
31
32
|
config_param :encoding, :string, default: nil
|
@@ -123,8 +124,19 @@ module Fluent::Plugin
|
|
123
124
|
begin
|
124
125
|
for r in lines
|
125
126
|
h = {"channel" => ch}
|
126
|
-
@keynames.each
|
127
|
-
|
127
|
+
@keynames.each do |k|
|
128
|
+
type = KEY_MAP[k][1]
|
129
|
+
value = r.send(KEY_MAP[k][0])
|
130
|
+
h[k]=case type
|
131
|
+
when :string
|
132
|
+
@receive_handlers.call(value.to_s)
|
133
|
+
when :array
|
134
|
+
value.map {|v| @receive_handlers.call(v.to_s)}
|
135
|
+
else
|
136
|
+
raise "Unknown value type: #{type}"
|
137
|
+
end
|
138
|
+
end
|
139
|
+
#h = Hash[@keynames.map {|k| [k, r.send(KEY_MAP[k][0]).to_s]}]
|
128
140
|
router.emit(@tag, Fluent::Engine.now, h)
|
129
141
|
end
|
130
142
|
rescue => e
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'win32/eventlog'
|
2
|
+
|
3
|
+
class EventLog
|
4
|
+
def initialize
|
5
|
+
@logger = Win32::EventLog.new
|
6
|
+
@app_source = "fluent-plugins"
|
7
|
+
end
|
8
|
+
|
9
|
+
def info(event_id, message)
|
10
|
+
@logger.report_event(
|
11
|
+
source: @app_source,
|
12
|
+
event_type: Win32::EventLog::INFO_TYPE,
|
13
|
+
event_id: event_id,
|
14
|
+
data: message
|
15
|
+
)
|
16
|
+
end
|
17
|
+
|
18
|
+
def warn(event_id, message)
|
19
|
+
@logger.report_event(
|
20
|
+
source: @app_source,
|
21
|
+
event_type: Win32::EventLog::WARN_TYPE,
|
22
|
+
event_id: event_id,
|
23
|
+
data: message
|
24
|
+
)
|
25
|
+
end
|
26
|
+
|
27
|
+
def crit(event_id, message)
|
28
|
+
@logger.report_event(
|
29
|
+
source: @app_source,
|
30
|
+
event_type: Win32::EventLog::ERROR_TYPE,
|
31
|
+
event_id: event_id,
|
32
|
+
data: message
|
33
|
+
)
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
|
38
|
+
module Fluent
|
39
|
+
module Plugin
|
40
|
+
class EventService
|
41
|
+
def run
|
42
|
+
eventlog = EventLog.new()
|
43
|
+
eventlog.info(65500, "Hi, from fluentd-plugins!! at " + Time.now.strftime("%Y/%m/%d %H:%M:%S "))
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
data/test/helper.rb
CHANGED
@@ -1,13 +1,18 @@
|
|
1
1
|
require 'helper'
|
2
|
+
require 'generate-windows-event'
|
2
3
|
|
3
4
|
class WindowsEventLogInputTest < Test::Unit::TestCase
|
5
|
+
|
4
6
|
def setup
|
5
7
|
Fluent::Test.setup
|
6
8
|
end
|
7
9
|
|
8
|
-
CONFIG =
|
9
|
-
|
10
|
-
|
10
|
+
CONFIG = config_element("ROOT", "", {"tag" => "fluent.eventlog"}, [
|
11
|
+
config_element("storage", "", {
|
12
|
+
'@type' => 'local',
|
13
|
+
'persistent' => false
|
14
|
+
})
|
15
|
+
])
|
11
16
|
|
12
17
|
def create_driver(conf = CONFIG)
|
13
18
|
Fluent::Test::Driver::Input.new(Fluent::Plugin::WindowsEventLogInput).configure(conf)
|
@@ -18,34 +23,26 @@ class WindowsEventLogInputTest < Test::Unit::TestCase
|
|
18
23
|
assert_equal 'fluent.eventlog', d.instance.tag
|
19
24
|
assert_equal 2, d.instance.read_interval
|
20
25
|
assert_nil d.instance.pos_file
|
21
|
-
assert_equal ['
|
26
|
+
assert_equal ['application'], d.instance.channels
|
22
27
|
assert_true d.instance.keys.empty?
|
23
28
|
assert_false d.instance.read_from_head
|
24
29
|
end
|
25
30
|
|
26
|
-
def test_format
|
27
|
-
d = create_driver
|
28
|
-
|
29
|
-
# time = Time.parse("2011-01-02 13:14:15 UTC").to_i
|
30
|
-
# d.emit({"a"=>1}, time)
|
31
|
-
# d.emit({"a"=>2}, time)
|
32
|
-
|
33
|
-
# d.expect_format %[2011-01-02T13:14:15Z\ttest\t{"a":1}\n]
|
34
|
-
# d.expect_format %[2011-01-02T13:14:15Z\ttest\t{"a":2}\n]
|
35
|
-
|
36
|
-
# d.run
|
37
|
-
end
|
38
|
-
|
39
31
|
def test_write
|
40
32
|
d = create_driver
|
41
33
|
|
42
|
-
|
43
|
-
|
44
|
-
|
34
|
+
service = Fluent::Plugin::EventService.new
|
35
|
+
|
36
|
+
d.run(expect_emits: 1) do
|
37
|
+
service.run
|
38
|
+
end
|
45
39
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
40
|
+
assert(d.events.length >= 1)
|
41
|
+
event = d.events.last
|
42
|
+
record = event.last
|
43
|
+
assert_equal("application", record["channel"])
|
44
|
+
assert_equal("65500", record["event_id"])
|
45
|
+
assert_equal("information", record["event_type"])
|
46
|
+
assert_equal("fluent-plugins", record["source_name"])
|
50
47
|
end
|
51
48
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-windows-eventlog
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- okahashi117
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2017-
|
13
|
+
date: 2017-06-06 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: bundler
|
@@ -102,8 +102,10 @@ files:
|
|
102
102
|
- LICENSE.txt
|
103
103
|
- README.md
|
104
104
|
- Rakefile
|
105
|
+
- appveyor.yml
|
105
106
|
- fluent-plugin-winevtlog.gemspec
|
106
107
|
- lib/fluent/plugin/in_windows_eventlog.rb
|
108
|
+
- test/generate-windows-event.rb
|
107
109
|
- test/helper.rb
|
108
110
|
- test/plugin/test_in_winevtlog.rb
|
109
111
|
homepage: https://github.com/fluent/fluent-plugin-windows-eventlog
|
@@ -126,10 +128,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
126
128
|
version: '0'
|
127
129
|
requirements: []
|
128
130
|
rubyforge_project:
|
129
|
-
rubygems_version: 2.
|
131
|
+
rubygems_version: 2.6.11
|
130
132
|
signing_key:
|
131
133
|
specification_version: 4
|
132
134
|
summary: Fluentd Input plugin to read windows event log.
|
133
135
|
test_files:
|
136
|
+
- test/generate-windows-event.rb
|
134
137
|
- test/helper.rb
|
135
138
|
- test/plugin/test_in_winevtlog.rb
|