embulk-parser-apache_error_log 0.1.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 6cec31b1f52ba754dbffa6d12f538e1102ac89a1
4
+ data.tar.gz: fcc6c57ea12373ea4ddc3ae1cca808209867cd3f
5
+ SHA512:
6
+ metadata.gz: e0cc143ead27a83d4e16184f53840ad8ebde6b6a6ddde0ea809396bdc8b951149bc214d7b6207f4776e15daba2306fe8406076ecd2cf73553f1343ef59ebb55c
7
+ data.tar.gz: 032ab86bb84bea3e45acf55c4e15120157278ee40c7b6b9f9a388eeeb9ace8851b55555d7b1c014dc2eaf7d359e6329563d7ff8b7d08be507b9f7b1eb7751df0
data/.gitignore ADDED
@@ -0,0 +1,5 @@
1
+ *~
2
+ /pkg/
3
+ /tmp/
4
+ /.bundle/
5
+ /Gemfile.lock
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ jruby-9.1.5.0
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source 'https://rubygems.org/'
2
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+
2
+ MIT License
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining
5
+ a copy of this software and associated documentation files (the
6
+ "Software"), to deal in the Software without restriction, including
7
+ without limitation the rights to use, copy, modify, merge, publish,
8
+ distribute, sublicense, and/or sell copies of the Software, and to
9
+ permit persons to whom the Software is furnished to do so, subject to
10
+ the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be
13
+ included in all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,33 @@
1
+ # Apache Error Log parser plugin for Embulk
2
+
3
+ Embulk parser plugin for apache error log
4
+
5
+ ## Overview
6
+
7
+ * **Plugin type**: parser
8
+ * **Guess supported**: no
9
+
10
+ ## Configuration
11
+
12
+ - **hostname**: hostname by generated log (string, optional)
13
+
14
+ ## Example
15
+
16
+ ```yaml
17
+ in:
18
+ type: any file input plugin type
19
+ parser:
20
+ type: apache_error_log
21
+ hostname: example.com
22
+ ```
23
+
24
+
25
+ ```
26
+ $ embulk gem install embulk-parser-apache_error_log
27
+ ```
28
+
29
+ ## Build
30
+
31
+ ```
32
+ $ rake
33
+ ```
data/Rakefile ADDED
@@ -0,0 +1,3 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ task default: :build
@@ -0,0 +1,20 @@
1
+
2
+ Gem::Specification.new do |spec|
3
+ spec.name = "embulk-parser-apache_error_log"
4
+ spec.version = "0.1.0"
5
+ spec.authors = ["Tomohiro Mitsusmune"]
6
+ spec.summary = "Apache Error Log parser plugin for Embulk"
7
+ spec.description = "Parses Apache Error Log files read by other file input plugins."
8
+ spec.email = ["tmitsumune@gmail.com"]
9
+ spec.licenses = ["MIT"]
10
+ spec.homepage = "https://github.com/tmitz/embulk-parser-apache_error_log"
11
+
12
+ spec.files = `git ls-files`.split("\n") + Dir["classpath/*.jar"]
13
+ spec.test_files = spec.files.grep(%r{^(test|spec)/})
14
+ spec.require_paths = ["lib"]
15
+
16
+ #spec.add_dependency 'YOUR_GEM_DEPENDENCY', ['~> YOUR_GEM_DEPENDENCY_VERSION']
17
+ spec.add_development_dependency 'embulk', ['>= 0.8.15']
18
+ spec.add_development_dependency 'bundler', ['>= 1.10.6']
19
+ spec.add_development_dependency 'rake', ['>= 10.0']
20
+ end
@@ -0,0 +1,63 @@
1
+ module Embulk
2
+ module Guess
3
+
4
+ # TODO implement guess plugin to make this command work:
5
+ # $ embulk guess -g "apache_error_log" partial-config.yml
6
+ #
7
+ # Depending on the file format the plugin uses, you can use choose
8
+ # one of binary guess (GuessPlugin), text guess (TextGuessPlugin),
9
+ # or line guess (LineGuessPlugin).
10
+
11
+ #require "embulk/parser/apache_error_log.rb"
12
+
13
+ #class ApacheErrorLog < GuessPlugin
14
+ # Plugin.register_guess("apache_error_log", self)
15
+ #
16
+ # def guess(config, sample_buffer)
17
+ # if sample_buffer[0,2] == GZIP_HEADER
18
+ # guessed = {}
19
+ # guessed["type"] = "apache_error_log"
20
+ # guessed["property1"] = "guessed-value"
21
+ # return {"parser" => guessed}
22
+ # else
23
+ # return {}
24
+ # end
25
+ # end
26
+ #end
27
+
28
+ #class ApacheErrorLog < TextGuessPlugin
29
+ # Plugin.register_guess("apache_error_log", self)
30
+ #
31
+ # def guess_text(config, sample_text)
32
+ # js = JSON.parse(sample_text) rescue nil
33
+ # if js && js["mykeyword"] == "keyword"
34
+ # guessed = {}
35
+ # guessed["type"] = "apache_error_log"
36
+ # guessed["property1"] = "guessed-value"
37
+ # return {"parser" => guessed}
38
+ # else
39
+ # return {}
40
+ # end
41
+ # end
42
+ #end
43
+
44
+ #class ApacheErrorLog < LineGuessPlugin
45
+ # Plugin.register_guess("apache_error_log", self)
46
+ #
47
+ # def guess_lines(config, sample_lines)
48
+ # all_line_matched = sample_lines.all? do |line|
49
+ # line =~ /mypattern/
50
+ # end
51
+ # if all_line_matched
52
+ # guessed = {}
53
+ # guessed["type"] = "apache_error_log"
54
+ # guessed["property1"] = "guessed-value"
55
+ # return {"parser" => guessed}
56
+ # else
57
+ # return {}
58
+ # end
59
+ # end
60
+ #end
61
+
62
+ end
63
+ end
@@ -0,0 +1,60 @@
1
+ module Embulk
2
+ module Parser
3
+
4
+ class ApacheErrorLog < ParserPlugin
5
+ Plugin.register_parser("apache_error_log", self)
6
+
7
+ def self.transaction(config, &control)
8
+ # configuration code:
9
+ puts config
10
+ task = {
11
+ 'hostname' => config.param('hostname', :string)
12
+ }
13
+
14
+ columns = [
15
+ Column.new(0, "time", :string),
16
+ Column.new(1, "level", :string),
17
+ Column.new(2, "pid", :long),
18
+ Column.new(3, "client", :string),
19
+ Column.new(4, "message", :string),
20
+ Column.new(5, "hostname", :string)
21
+ ]
22
+
23
+ yield(task, columns)
24
+ end
25
+
26
+ def init
27
+ # initialization code:
28
+ @hostname = task['hostname']
29
+ end
30
+
31
+ def run(file_input)
32
+ while file = file_input.next_file
33
+ file.each do |buffer|
34
+ # parsering code
35
+ data = buffer.split("\n")
36
+ data.each do |row|
37
+ row.scan(error_format) do |record|
38
+ record.insert(-1, @hostname)
39
+ page_builder.add(record)
40
+ end
41
+ end
42
+ end
43
+ end
44
+ page_builder.finish
45
+ end
46
+
47
+ private
48
+
49
+ def error_format
50
+ /\A\[[^ ]*
51
+ \s(?<time>[^\]]*)\]
52
+ \s\[(?<level>[^\]]*)\]
53
+ \s(?:\((?<pid>[^\)]*)\))?
54
+ (\[client (?<client>[^\]]*)\])?
55
+ \s?(?<message>.*)\z
56
+ /x
57
+ end
58
+ end
59
+ end
60
+ end
metadata ADDED
@@ -0,0 +1,95 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: embulk-parser-apache_error_log
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Tomohiro Mitsusmune
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-11-29 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - ">="
17
+ - !ruby/object:Gem::Version
18
+ version: 0.8.15
19
+ name: embulk
20
+ prerelease: false
21
+ type: :development
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 0.8.15
27
+ - !ruby/object:Gem::Dependency
28
+ requirement: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 1.10.6
33
+ name: bundler
34
+ prerelease: false
35
+ type: :development
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: 1.10.6
41
+ - !ruby/object:Gem::Dependency
42
+ requirement: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: '10.0'
47
+ name: rake
48
+ prerelease: false
49
+ type: :development
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ description: Parses Apache Error Log files read by other file input plugins.
56
+ email:
57
+ - tmitsumune@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - ".ruby-version"
64
+ - Gemfile
65
+ - LICENSE.txt
66
+ - README.md
67
+ - Rakefile
68
+ - embulk-parser-apache_error_log.gemspec
69
+ - lib/embulk/guess/apache_error_log.rb
70
+ - lib/embulk/parser/apache_error_log.rb
71
+ homepage: https://github.com/tmitz/embulk-parser-apache_error_log
72
+ licenses:
73
+ - MIT
74
+ metadata: {}
75
+ post_install_message:
76
+ rdoc_options: []
77
+ require_paths:
78
+ - lib
79
+ required_ruby_version: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ required_rubygems_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ requirements: []
90
+ rubyforge_project:
91
+ rubygems_version: 2.6.6
92
+ signing_key:
93
+ specification_version: 4
94
+ summary: Apache Error Log parser plugin for Embulk
95
+ test_files: []