logstash-codec-logfmt 0.1.0

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: a2b0996a04ab0417afce8855cc54838cc83b5464
4
+ data.tar.gz: 01c9d6d313520cbdff22ec35b8e0df5ab5d457d3
5
+ SHA512:
6
+ metadata.gz: 0e3ec37ad646b65d3d2fd3de970d3d675746ee2de1e20a7ccf0ad4d77d0a6e4d29b892562f307f40c35a5a49f4acb3b2031c6e0753d6e97f0ab0a26bbe151f11
7
+ data.tar.gz: 9b19080321ba9e934fda2aa98d4f1b6965926cbbf2cc0d235b3aaa28ed56f65ab6aaecebe7855328bf264c443c8f1f23e246a38b67dd88223af0123f82132b1b
data/.gitignore ADDED
@@ -0,0 +1,39 @@
1
+ .DS_Store
2
+ *.gem
3
+
4
+
5
+ *.gem
6
+ *.rbc
7
+ /.config
8
+ /coverage/
9
+ /InstalledFiles
10
+ /pkg/
11
+ /spec/reports/
12
+ /test/tmp/
13
+ /test/version_tmp/
14
+ /tmp/
15
+
16
+ ## Specific to RubyMotion:
17
+ .dat*
18
+ .repl_history
19
+ build/
20
+
21
+ ## Documentation cache and generated files:
22
+ /.yardoc/
23
+ /_yardoc/
24
+ /doc/
25
+ /rdoc/
26
+
27
+ ## Environment normalisation:
28
+ /.bundle/
29
+ /vendor/bundle
30
+ /lib/bundler/man/
31
+
32
+ # for a library or gem, you might want to ignore these files since the code is
33
+ # intended to run in multiple environments; otherwise, check them in:
34
+ # Gemfile.lock
35
+ .ruby-version
36
+ .ruby-gemset
37
+
38
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
39
+ .rvmrc
data/CHANGELOG.md ADDED
File without changes
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,80 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ logstash-codec-logfmt (0.1.8)
5
+ logfmt (~> 0.0.7)
6
+ logstash-core (>= 1.4.0, < 2.0.0)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ cabin (0.7.1)
12
+ clamp (0.6.5)
13
+ coderay (1.1.0)
14
+ diff-lcs (1.2.5)
15
+ ffi (1.9.8-java)
16
+ filesize (0.0.4)
17
+ gem_publisher (1.5.0)
18
+ i18n (0.6.9)
19
+ insist (1.0.0)
20
+ jar-dependencies (0.1.14)
21
+ jrjackson (0.2.8)
22
+ logfmt (0.0.7)
23
+ logstash-core (1.5.1-java)
24
+ cabin (~> 0.7.0)
25
+ clamp (~> 0.6.5)
26
+ filesize (= 0.0.4)
27
+ i18n (= 0.6.9)
28
+ jrjackson (~> 0.2.8)
29
+ minitar (~> 0.5.4)
30
+ pry (~> 0.10.1)
31
+ stud (~> 0.0.19)
32
+ thread_safe (~> 0.3.5)
33
+ treetop (< 1.5.0)
34
+ logstash-devutils (0.0.8-java)
35
+ gem_publisher
36
+ insist (= 1.0.0)
37
+ jar-dependencies
38
+ minitar
39
+ rake
40
+ method_source (0.8.2)
41
+ minitar (0.5.4)
42
+ polyglot (0.3.5)
43
+ pry (0.10.1-java)
44
+ coderay (~> 1.1.0)
45
+ method_source (~> 0.8.1)
46
+ slop (~> 3.4)
47
+ spoon (~> 0.0)
48
+ rake (10.4.2)
49
+ rspec (3.3.0)
50
+ rspec-core (~> 3.3.0)
51
+ rspec-expectations (~> 3.3.0)
52
+ rspec-mocks (~> 3.3.0)
53
+ rspec-core (3.3.0)
54
+ rspec-support (~> 3.3.0)
55
+ rspec-expectations (3.3.0)
56
+ diff-lcs (>= 1.2.0, < 2.0)
57
+ rspec-support (~> 3.3.0)
58
+ rspec-mocks (3.3.0)
59
+ diff-lcs (>= 1.2.0, < 2.0)
60
+ rspec-support (~> 3.3.0)
61
+ rspec-support (3.3.0)
62
+ slop (3.6.0)
63
+ spoon (0.0.4)
64
+ ffi
65
+ stud (0.0.19)
66
+ thread_safe (0.3.5-java)
67
+ treetop (1.4.15)
68
+ polyglot
69
+ polyglot (>= 0.3.1)
70
+
71
+ PLATFORMS
72
+ java
73
+
74
+ DEPENDENCIES
75
+ logstash-codec-logfmt!
76
+ logstash-devutils
77
+ rspec
78
+
79
+ BUNDLED WITH
80
+ 1.10.3
data/LICENSE ADDED
@@ -0,0 +1,13 @@
1
+ Copyright (c) 2015 Tim Buchwaldt / grandcentrinx GmbH <http://grandcentrix.net>
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
data/README.md ADDED
@@ -0,0 +1,95 @@
1
+ # Logstash Plugin
2
+
3
+ This is a plugin for [Logstash](https://github.com/elasticsearch/logstash), allowing logstash to parse logfmt-formatted messages to be parsed.
4
+
5
+ It is fully free and fully open source. The license is Apache 2.0, meaning you are pretty much free to use it however you want in whatever way.
6
+
7
+ ## Documentation
8
+
9
+ Logstash provides infrastructure to automatically generate documentation for this plugin. We use the asciidoc format to write documentation so any comments in the source code will be first converted into asciidoc and then into html. All plugin documentation are placed under one [central location](http://www.elasticsearch.org/guide/en/logstash/current/).
10
+
11
+ - For formatting code or config example, you can use the asciidoc `[source,ruby]` directive
12
+ - For more asciidoc formatting tips, see the excellent reference here https://github.com/elasticsearch/docs#asciidoc-guide
13
+
14
+ ## Need Help?
15
+
16
+ Need help? Try #logstash on freenode IRC or the https://discuss.elastic.co/c/logstash discussion forum.
17
+
18
+ ## Developing
19
+
20
+ ### 1. Plugin Developement and Testing
21
+
22
+ #### Code
23
+ - To get started, you'll need JRuby with the Bundler gem installed.
24
+
25
+ - Create a new plugin or clone and existing from the GitHub [logstash-plugins](https://github.com/logstash-plugins) organization.
26
+
27
+ - Install dependencies
28
+ ```sh
29
+ bundle install
30
+ ```
31
+
32
+ #### Test
33
+
34
+ ```sh
35
+ bundle exec rspec
36
+ ```
37
+
38
+ The Logstash code required to run the tests/specs is specified in the `Gemfile` by the line similar to:
39
+ ```ruby
40
+ gem "logstash", :github => "elasticsearch/logstash", :branch => "1.5"
41
+ ```
42
+ To test against another version or a local Logstash, edit the `Gemfile` to specify an alternative location, for example:
43
+ ```ruby
44
+ gem "logstash", :github => "elasticsearch/logstash", :ref => "master"
45
+ ```
46
+ ```ruby
47
+ gem "logstash", :path => "/your/local/logstash"
48
+ ```
49
+
50
+ Then update your dependencies and run your tests:
51
+
52
+ ```sh
53
+ bundle install
54
+ bundle exec rspec
55
+ ```
56
+
57
+ ### 2. Running your unpublished Plugin in Logstash
58
+
59
+ #### 2.1 Run in a local Logstash clone
60
+
61
+ - Edit Logstash `tools/Gemfile` and add the local plugin path, for example:
62
+ ```ruby
63
+ gem "logstash-filter-awesome", :path => "/your/local/logstash-filter-awesome"
64
+ ```
65
+ - Update Logstash dependencies
66
+ ```sh
67
+ rake vendor:gems
68
+ ```
69
+ - Run Logstash with your plugin
70
+ ```sh
71
+ bin/logstash -e 'filter {awesome {}}'
72
+ ```
73
+ At this point any modifications to the plugin code will be applied to this local Logstash setup. After modifying the plugin, simply rerun Logstash.
74
+
75
+ #### 2.2 Run in an installed Logstash
76
+
77
+ - Build your plugin gem
78
+ ```sh
79
+ gem build logstash-filter-awesome.gemspec
80
+ ```
81
+ - Install the plugin from the Logstash home
82
+ ```sh
83
+ bin/plugin install /your/local/plugin/logstash-filter-awesome.gem
84
+ ```
85
+ - Start Logstash and proceed to test the plugin
86
+
87
+ ## Contributing
88
+
89
+ All contributions are welcome: ideas, patches, documentation, bug reports, complaints, and even something you drew up on a napkin.
90
+
91
+ Programming is not a required skill. Whatever you've seen about open source and maintainers or community members saying "send patches or die" - you will not see that here.
92
+
93
+ It is more important to me that you are able to contribute.
94
+
95
+ For more information about contributing, see the [CONTRIBUTING](https://github.com/elasticsearch/logstash/blob/master/CONTRIBUTING.md) file.
@@ -0,0 +1,37 @@
1
+ # encoding: utf-8
2
+ require "logstash/codecs/base"
3
+ require "logfmt"
4
+ # Add any asciidoc formatted documentation here
5
+ class LogStash::Codecs::Logfmt < LogStash::Codecs::Base
6
+
7
+ # This example codec will append a string to the message field
8
+ # of an event, either in the decoding or encoding methods
9
+ #
10
+ # This is only intended to be used as an example.
11
+ #
12
+ # input {
13
+ # stdin { codec => example }
14
+ # }
15
+ #
16
+ # or
17
+ #
18
+ # output {
19
+ # stdout { codec => example }
20
+ # }
21
+ config_name "logfmt"
22
+
23
+ # Append a string to the message
24
+ #config :append, :validate => :string, :default => ', Hello World!'
25
+
26
+ public
27
+ def register
28
+ end
29
+
30
+ public
31
+ def decode(data)
32
+ parsed = Logfmt.parse(data)
33
+ yield LogStash::Event.new(parsed)
34
+ end # def decode
35
+
36
+
37
+ end # class LogStash::Codecs::Logfmt
@@ -0,0 +1,28 @@
1
+ Gem::Specification.new do |s|
2
+
3
+ s.name = 'logstash-codec-logfmt'
4
+ s.version = '0.1.0'
5
+ s.licenses = ['Apache License (2.0)']
6
+ s.summary = "This codec may be used to decode (via inputs) and encode (via outputs) full LogFMT messages"
7
+ s.description = "This gem is a logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/plugin install gemname. This gem is not a stand-alone program"
8
+ s.authors = ["Elastic"]
9
+ s.email = 'info@elastic.co'
10
+ s.homepage = "http://www.elastic.co/guide/en/logstash/current/index.html"
11
+ s.require_paths = ["lib"]
12
+
13
+ # Files
14
+ s.files = `git ls-files`.split($\)
15
+
16
+ # Tests
17
+ s.test_files = s.files.grep(%r{^(test|spec|features)/})
18
+
19
+ # Special flag to let us know this is actually a logstash plugin
20
+ s.metadata = { "logstash_plugin" => "true", "logstash_group" => "codec" }
21
+
22
+ # Gem dependencies
23
+ s.add_runtime_dependency "logstash-core", '>= 1.4.0', '< 2.0.0'
24
+ s.add_runtime_dependency "logfmt", '~> 0.0.7'
25
+
26
+ s.add_development_dependency 'logstash-devutils'
27
+ s.add_development_dependency 'rspec'
28
+ end
@@ -0,0 +1,45 @@
1
+ require "logstash/devutils/rspec/spec_helper"
2
+ require "logstash/codecs/logfmt"
3
+ require "logstash/event"
4
+ require "logstash/json"
5
+ require "insist"
6
+
7
+ describe LogStash::Codecs::Logfmt do
8
+ subject do
9
+ next LogStash::Codecs::Logfmt.new
10
+ end
11
+
12
+ context "#decode" do
13
+ it "should decode valid logfmt data" do
14
+ data = "foo=bar message=baz duration=3.01"
15
+ subject.decode(data) do |event|
16
+ insist { event.is_a? LogStash::Event }
17
+ insist { event["foo"] } == "bar"
18
+ insist { event["message"] } == "baz"
19
+ insist { event["duration"] } == 3.01
20
+ end
21
+ end
22
+ it "should be fast", :performance => true do
23
+ data = "message=foo level=info duration=3.01"
24
+ iterations = 500000
25
+ count = 0
26
+ # Warmup
27
+ 10000.times { subject.decode(data) { } }
28
+ start = Time.now
29
+ iterations.times do
30
+ subject.decode(data) do |event|
31
+ count += 1
32
+ end
33
+ end
34
+ duration = Time.now - start
35
+ insist { count } == iterations
36
+ puts "codecs/logfmt rate: #{"%02.0f/sec" % (iterations / duration)}, elapsed: #{duration}s"
37
+ end
38
+ it "falls back to plain text and doesn't crash (LOGSTASH-1595)" do
39
+ blob = (128..255).to_a.pack("C*").force_encoding("ASCII-8BIT")
40
+ subject.decode(blob) do |event|
41
+ puts event
42
+ end
43
+ end
44
+ end
45
+ end
metadata ADDED
@@ -0,0 +1,117 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: logstash-codec-logfmt
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Elastic
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-06-15 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: 1.4.0
19
+ - - "<"
20
+ - !ruby/object:Gem::Version
21
+ version: 2.0.0
22
+ name: logstash-core
23
+ prerelease: false
24
+ type: :runtime
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: 1.4.0
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: 2.0.0
33
+ - !ruby/object:Gem::Dependency
34
+ requirement: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - "~>"
37
+ - !ruby/object:Gem::Version
38
+ version: 0.0.7
39
+ name: logfmt
40
+ prerelease: false
41
+ type: :runtime
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: 0.0.7
47
+ - !ruby/object:Gem::Dependency
48
+ requirement: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: '0'
53
+ name: logstash-devutils
54
+ prerelease: false
55
+ type: :development
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
+ - !ruby/object:Gem::Dependency
62
+ requirement: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: '0'
67
+ name: rspec
68
+ prerelease: false
69
+ type: :development
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ description: This gem is a logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/plugin install gemname. This gem is not a stand-alone program
76
+ email: info@elastic.co
77
+ executables: []
78
+ extensions: []
79
+ extra_rdoc_files: []
80
+ files:
81
+ - ".gitignore"
82
+ - CHANGELOG.md
83
+ - Gemfile
84
+ - Gemfile.lock
85
+ - LICENSE
86
+ - README.md
87
+ - lib/logstash/codecs/logfmt.rb
88
+ - logstash-codec-logfmt.gemspec
89
+ - spec/codecs/logfmt_spec.rb
90
+ homepage: http://www.elastic.co/guide/en/logstash/current/index.html
91
+ licenses:
92
+ - Apache License (2.0)
93
+ metadata:
94
+ logstash_plugin: 'true'
95
+ logstash_group: codec
96
+ post_install_message:
97
+ rdoc_options: []
98
+ require_paths:
99
+ - lib
100
+ required_ruby_version: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - ">="
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ required_rubygems_version: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ requirements: []
111
+ rubyforge_project:
112
+ rubygems_version: 2.4.8
113
+ signing_key:
114
+ specification_version: 4
115
+ summary: This codec may be used to decode (via inputs) and encode (via outputs) full LogFMT messages
116
+ test_files:
117
+ - spec/codecs/logfmt_spec.rb