logstash-codec-bytes 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: a49c6efaf3841a405282e8cfc2d1463f6b76dc46
4
+ data.tar.gz: a14a4b7f11d9d7b13e776967c3d12a48fbf02ed9
5
+ SHA512:
6
+ metadata.gz: 8589102994eb0363cf0b0b378a99cc76175172379103bfafd1f2f14096f5c0c6477be7ed754e9b857a92be2242748043216eb8f93bbda13ba8c783e194fdf19f
7
+ data.tar.gz: 5ab982e7fc74b073265fc37957924e8589a2d1b2f845baf25ee658eb5238ce3cc171106dc927e1a2d0eb2375d382a7871d369ce382647dc7ec903aed31e216e2
@@ -0,0 +1,6 @@
1
+ ## 1.0.0 (2016-7-6)
2
+
3
+ ##### New Features
4
+
5
+ * **plugin:** add bytes plugin ([15857144](https://github.com/lob/logstash-codec-bytes/commit/1585714491eda98931852dcc5d30f3a1a39107f1))
6
+
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ #ruby=jruby-9.0.5.0
2
+ source 'https://rubygems.org'
3
+ gemspec
@@ -0,0 +1,78 @@
1
+ # logstash-codec-bytes
2
+
3
+ [![Build Status](https://travis-ci.org/lob/logstash-codec-bytes.svg?branch=master)](https://travis-ci.org/lob/logstash-codec-bytes)
4
+ [![Gem Version](https://badge.fury.io/rb/logstash-codec-bytes.svg)](http://badge.fury.io/rb/logstash-codec-bytes)
5
+ [![Coverage Status](https://coveralls.io/repos/github/lob/logstash-codec-bytes/badge.svg?branch=master)](https://coveralls.io/github/lob/logstash-codec-bytes?branch=master)
6
+
7
+ Logstash codec plugin to chunk an input into an event every specified number of bytes.
8
+
9
+ ## About
10
+
11
+ This is a plugin for [Logstash](https://github.com/elastic/logstash).
12
+
13
+ It is fully free and fully open source. The license is MIT, meaning you are pretty much free to use it however you want in whatever way.
14
+
15
+ ### Installation
16
+
17
+ #### Code
18
+ - To get started, you'll need JRuby with the Bundler gem installed.
19
+
20
+ - Install dependencies
21
+ ```sh
22
+ bundle install
23
+ ```
24
+
25
+ #### Test
26
+
27
+ - Update your dependencies
28
+
29
+ ```sh
30
+ $ bundle install
31
+ ```
32
+
33
+ - Run tests
34
+
35
+ ```sh
36
+ $ bundle exec rspec
37
+ ```
38
+
39
+ ### Running the Plugin in Logstash (version 2.3.x)
40
+
41
+ - Install the plugin
42
+
43
+ ```sh
44
+ bin/logstash-plugin install logstash-codec-bytes
45
+ ```
46
+
47
+ - Run Logstash with the plugin
48
+
49
+ ```sh
50
+ bin/logstash -e 'input { file { path => "/path/to/file" delimiter => "" codec => bytes { length => X } } }'
51
+ ```
52
+ where length X is the number of bytes you want to read before emitting an event.
53
+
54
+ Note: we recommend sending smaller, more frequent events into the bytes codec for the best performance. With the file input plugin above, we set the delimiter to "" because otherwise it defaults to emitting an event every \n character. If a file were only one line, the entire file would be fed into the bytes codec, leading to reduced performance.
55
+
56
+ ## Contributing
57
+
58
+ Make sure you have JRuby and Bundler installed. Copy and paste the following commands in your projects directory.
59
+
60
+ git clone https://github.com/lob/logstash-codec-bytes.git
61
+ cd logstash-codec-bytes
62
+ bundle install
63
+
64
+ ### Contributing Instructions
65
+
66
+ 1. Fork it
67
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
68
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
69
+ 4. Push to the branch (`git push origin my-new-feature`)
70
+ 5. Make sure the tests pass
71
+ 6. Open up coverage/index.html in your browser and add tests if required
72
+ 7. Create new Pull Request
73
+
74
+ =======================
75
+
76
+ Copyright © 2016 Lob.com
77
+
78
+ Released under the MIT License, which can be found in the repository in `LICENSE`.
@@ -0,0 +1,40 @@
1
+ # encoding: utf-8
2
+ require "logstash/codecs/base"
3
+ require "logstash/namespace"
4
+
5
+ class LogStash::Codecs::Bytes < LogStash::Codecs::Base
6
+
7
+ # This codec will chunk input into parts of a
8
+ # specified length
9
+ #
10
+ # input {
11
+ # file {
12
+ # delimiter => ""
13
+ # codec => bytes {
14
+ # length => X
15
+ # }
16
+ # }
17
+ # }
18
+
19
+ config_name "bytes"
20
+
21
+ config :length, :validate => :number, :required => true
22
+
23
+ public
24
+ def register
25
+ @payload = []
26
+ end
27
+
28
+ public
29
+ def decode(data)
30
+ @payload += data.bytes.to_a
31
+
32
+ while @payload.length >= @length
33
+ line = @payload.slice!(0...@length).pack('c*')
34
+
35
+ yield LogStash::Event.new({ "message" => line })
36
+ end
37
+
38
+ end
39
+
40
+ end
@@ -0,0 +1,23 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = "logstash-codec-bytes"
3
+ s.version = "1.0.0"
4
+ s.licenses = ["MIT"]
5
+ s.authors = ["Lob"]
6
+ s.email = ["support@lob.com"]
7
+ s.description = "Logstash codec plugin to chunk an input into an event every specified number of bytes."
8
+ s.summary = "Logstash codec plugin to chunk an input into an event every specified number of bytes."
9
+ s.homepage = "https://github.com/lob/logstash-codec-bytes"
10
+ s.require_paths = ["lib"]
11
+
12
+ s.files = Dir["lib/**/*","spec/**/*","vendor/**/*","*.gemspec","*.md","Gemfile"]
13
+
14
+ s.test_files = s.files.grep(%r{^(test|spec|features)/})
15
+
16
+ s.metadata = { "logstash_plugin" => "true", "logstash_group" => "codec" }
17
+
18
+ s.add_runtime_dependency "logstash-core", ">= 2.0.0", "< 3.0.0"
19
+
20
+ s.add_development_dependency "logstash-devutils"
21
+ s.add_development_dependency "coveralls", "~> 0.8.1"
22
+ s.add_development_dependency "simplecov"
23
+ end
@@ -0,0 +1,29 @@
1
+ require "spec_helper"
2
+ require "logstash/codecs/bytes"
3
+
4
+ describe LogStash::Codecs::Bytes do
5
+
6
+ subject do
7
+ LogStash::Codecs::Bytes.new({ "length" => 4 })
8
+ end
9
+
10
+ it "chunks the data into parts of given length" do
11
+ data = "TestTest"
12
+
13
+ subject.decode(data) do |event|
14
+ expect(event["message"].length).to eq(subject.length)
15
+ end
16
+
17
+ end
18
+
19
+ it "creates an event for each complete chunk" do
20
+ data = "TestTes"
21
+ expected_count = data.bytes.length / subject.length
22
+ count = 0
23
+
24
+ subject.decode(data) { count += 1 }
25
+
26
+ expect(count).to eq(expected_count)
27
+ end
28
+
29
+ end
@@ -0,0 +1,11 @@
1
+ require 'simplecov'
2
+ require 'coveralls'
3
+
4
+ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
5
+ SimpleCov::Formatter::HTMLFormatter,
6
+ Coveralls::SimpleCov::Formatter
7
+ ]
8
+ SimpleCov.minimum_coverage 100
9
+ SimpleCov.start
10
+
11
+ require "logstash/devutils/rspec/spec_helper"
metadata ADDED
@@ -0,0 +1,117 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: logstash-codec-bytes
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Lob
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-07-18 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: 2.0.0
19
+ - - "<"
20
+ - !ruby/object:Gem::Version
21
+ version: 3.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: 2.0.0
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: 3.0.0
33
+ - !ruby/object:Gem::Dependency
34
+ requirement: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - ">="
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
39
+ name: logstash-devutils
40
+ prerelease: false
41
+ type: :development
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ - !ruby/object:Gem::Dependency
48
+ requirement: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - "~>"
51
+ - !ruby/object:Gem::Version
52
+ version: 0.8.1
53
+ name: coveralls
54
+ prerelease: false
55
+ type: :development
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: 0.8.1
61
+ - !ruby/object:Gem::Dependency
62
+ requirement: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: '0'
67
+ name: simplecov
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: Logstash codec plugin to chunk an input into an event every specified number of bytes.
76
+ email:
77
+ - support@lob.com
78
+ executables: []
79
+ extensions: []
80
+ extra_rdoc_files: []
81
+ files:
82
+ - CHANGELOG.md
83
+ - Gemfile
84
+ - README.md
85
+ - lib/logstash/codecs/bytes.rb
86
+ - logstash-codec-bytes.gemspec
87
+ - spec/codecs/bytes_spec.rb
88
+ - spec/spec_helper.rb
89
+ homepage: https://github.com/lob/logstash-codec-bytes
90
+ licenses:
91
+ - MIT
92
+ metadata:
93
+ logstash_plugin: 'true'
94
+ logstash_group: codec
95
+ post_install_message:
96
+ rdoc_options: []
97
+ require_paths:
98
+ - lib
99
+ required_ruby_version: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ required_rubygems_version: !ruby/object:Gem::Requirement
105
+ requirements:
106
+ - - ">="
107
+ - !ruby/object:Gem::Version
108
+ version: '0'
109
+ requirements: []
110
+ rubyforge_project:
111
+ rubygems_version: 2.4.8
112
+ signing_key:
113
+ specification_version: 4
114
+ summary: Logstash codec plugin to chunk an input into an event every specified number of bytes.
115
+ test_files:
116
+ - spec/codecs/bytes_spec.rb
117
+ - spec/spec_helper.rb