fluent-plugin-grok_pure-parser 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: fa26798ef35727f5de838a43e27aace6f28d0ba7
4
+ data.tar.gz: bedad52e8c1465f3eecd1f0f33af9fccd6e0132d
5
+ SHA512:
6
+ metadata.gz: 87f8b7eadc768bf4fb0027848771fa243a7490319f97c65079fd116e1977bf77ddd8e7689e8a420674f550ee83d9f889be1896fae8f15b9094a778379508606a
7
+ data.tar.gz: b6cd515ba810bab014954cf87c2fe4c50d0dfc98f96687bd1172e6851c21abf9276876e6b8b093541122e86362e4e00387d45c7aa235f3c40d88c43e695c7b08
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in fluent-plugin-grok_pure-parser.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Alex Hornung
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,41 @@
1
+ # Fluent::Plugin::grok_pure::Parser
2
+
3
+ This fluentd parser plugin adds a parse format `grok_pure` which allows using any Grok pattern. It uses the [jls-grok](https://rubygems.org/gems/jls-grok) ruby gem, so it supports all Grok features, including type coercion.
4
+
5
+ ## Installation
6
+
7
+ Install the plugin by running:
8
+
9
+ fluent-gem install fluent-plugin-grok_pure-parser
10
+
11
+ ## Usage
12
+
13
+ ```
14
+ <source>
15
+ type tail
16
+ path /path/to/log
17
+ tag foo.log
18
+
19
+ format grok_pure
20
+ grok_pattern %{HAPROXYHTTP}
21
+ grok_pattern_path /etc/grok_patterns
22
+ </source>
23
+ ```
24
+
25
+ Setting `format` to `grok_pure` enables the Grok parser. The two main configuration options are `grok_pattern_path`, which must be the path to a directory that contains grok patterns, and `grok_pattern`, which is the pattern used to match and format the record. All named grok patterns will end up as keys in the resulting record.
26
+
27
+ The following standard format options are also supported:
28
+
29
+ - `time_key`: Sets the name of the grok capture group that contains the log timestamp
30
+ - `time_format`: Sets the format of the log timestamp, for parsing
31
+ - type coercion via the `TypeConverter` mixin (no official documentation available yet)
32
+
33
+ Grok patterns can generally be of the form of `%{PATTERN_NAME}`, `%{PATTERN_NAME:CAPTURE_NAME}` or `%{PATTERN_NAME:CAPTURE_NAME:type_coercion}`. See the [Logstash Grok documentation](http://logstash.net/docs/latest/filters/grok) for more details.
34
+
35
+ ## Contributing
36
+
37
+ 1. Fork it
38
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
39
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
40
+ 4. Push to the branch (`git push origin my-new-feature`)
41
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.7
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "fluent-plugin-grok_pure-parser"
7
+ spec.version = File.read("VERSION").strip
8
+ spec.authors = ["Alex Hornung"]
9
+ spec.email = ["alex@alexhornung.com"]
10
+ spec.description = %q{fluentd parser plugin to be able to use Grok patterns}
11
+ spec.summary = spec.description
12
+ spec.homepage = "https://github.com/bwalex/fluent-plugin-grok_pure-parser"
13
+ spec.license = "MIT"
14
+ spec.has_rdoc = false
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency "jls-grok", "~> 0.11.0"
22
+ spec.add_dependency "fluentd", "~> 0.10.17"
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.3"
25
+ spec.add_development_dependency "rake", "~> 10.4.2"
26
+ end
@@ -0,0 +1,80 @@
1
+ require 'grok-pure'
2
+
3
+ module Fluent
4
+ class TextParser
5
+ class GrokPure < Parser
6
+ include TypeConverter
7
+
8
+ Plugin.register_parser('grok_pure', self)
9
+
10
+ config_param :time_format, :string, :default => nil
11
+ config_param :time_key, :string, :default => 'time'
12
+ config_param :grok_pattern, :string
13
+ config_param :grok_pattern_path, :string, :default => nil
14
+
15
+ unless method_defined?(:log)
16
+ define_method(:log) { $log }
17
+ end
18
+
19
+ class PatternError < ParserError; end
20
+
21
+ def initialize
22
+ super
23
+ @time_parser = TimeParser.new(@time_format)
24
+ @mutex = Mutex.new
25
+ @grok = Grok.new
26
+ @grok.logger = LogProxy.new(log)
27
+ end
28
+
29
+ def configure(conf)
30
+ super
31
+
32
+ if @grok_pattern_path
33
+ Dir["#{@grok_pattern_path}/*"].sort.each do |f|
34
+ @grok.add_patterns_from_file(f)
35
+ end
36
+ end
37
+
38
+ begin
39
+ @grok.compile(@grok_pattern, true)
40
+ rescue Grok::PatternError => e
41
+ raise PatternError, e.message
42
+ end
43
+ end
44
+
45
+ def parse(text)
46
+ time = nil
47
+ record = {}
48
+
49
+ matched = @grok.match_and_capture(text) do |k,v|
50
+ if k == @time_key
51
+ time = @mutex.synchronize { @time_parser.parse(v) }
52
+ else
53
+ record[k] = @type_converters.nil? ? v : convert_type(k,v)
54
+ end
55
+ end
56
+
57
+ if matched
58
+ time ||= Engine.now if @estimate_current_event
59
+ yield time, record
60
+ else
61
+ yield nil, nil
62
+ end
63
+ end
64
+
65
+ class LogProxy
66
+ def initialize(logger)
67
+ @logger = logger
68
+ end
69
+
70
+ def method_missing(sym, *args, &block)
71
+ @logger.send(sym, *args, &block)
72
+ end
73
+
74
+ %w(debug info warn error fatal).each do |name|
75
+ define_method("#{name}?".to_sym) { true }
76
+ end
77
+ end
78
+ end
79
+ end
80
+ end
metadata ADDED
@@ -0,0 +1,108 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fluent-plugin-grok_pure-parser
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.7
5
+ platform: ruby
6
+ authors:
7
+ - Alex Hornung
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-01-06 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: jls-grok
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: 0.11.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: 0.11.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: fluentd
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: 0.10.17
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: 0.10.17
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '1.3'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '1.3'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 10.4.2
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: 10.4.2
69
+ description: fluentd parser plugin to be able to use Grok patterns
70
+ email:
71
+ - alex@alexhornung.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - .gitignore
77
+ - Gemfile
78
+ - LICENSE.txt
79
+ - README.md
80
+ - Rakefile
81
+ - VERSION
82
+ - fluent-plugin-grok_pure-parser.gemspec
83
+ - lib/fluent/plugin/parser_grok_pure.rb
84
+ homepage: https://github.com/bwalex/fluent-plugin-grok_pure-parser
85
+ licenses:
86
+ - MIT
87
+ metadata: {}
88
+ post_install_message:
89
+ rdoc_options: []
90
+ require_paths:
91
+ - lib
92
+ required_ruby_version: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ required_rubygems_version: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ requirements: []
103
+ rubyforge_project:
104
+ rubygems_version: 2.0.14
105
+ signing_key:
106
+ specification_version: 4
107
+ summary: fluentd parser plugin to be able to use Grok patterns
108
+ test_files: []