logstash-input-reqsample 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: a18ef6e16f5c7c37e81abdb47aa944ad0a2917a7
4
+ data.tar.gz: 95f400a4587ef4ed9fd1035da3c0062bb9aeabb7
5
+ SHA512:
6
+ metadata.gz: 4f2830583c4a80d30f7f416ad5b94db132cf9d9759e030ba592c24344919c822accdf6f144d53f7719d5e6a9e5f765b00f6ef5acafac00bd8ed969d8b4f16d0c
7
+ data.tar.gz: c33eaf07fcb23c3daf397e1241dab99612b1daa3981e42e484d149349433bcabfbd565be5878615365f1e625497b3c0d258fd115a37f8d1502b0ea9562ac82a5
data/CHANGELOG.md ADDED
@@ -0,0 +1,2 @@
1
+ ## 0.1.0
2
+ - Plugin created with the logstash plugin generator
data/CONTRIBUTORS ADDED
@@ -0,0 +1,10 @@
1
+ The following is a list of people who have contributed ideas, code, bug
2
+ reports, or in general have helped logstash along its way.
3
+
4
+ Contributors:
5
+ * Tyler Langlois - tjl@byu.net
6
+
7
+ Note: If you've sent us patches, bug reports, or otherwise contributed to
8
+ Logstash, and you aren't on the list above and want to be, please let us know
9
+ and we'll make sure you're here. Contributions from folks like you are what make
10
+ open source awesome.
data/DEVELOPER.md ADDED
@@ -0,0 +1,2 @@
1
+ # logstash-input-reqsample
2
+ Example input plugin. This should help bootstrap your effort to write your own input plugin!
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,11 @@
1
+ Licensed under the Apache License, Version 2.0 (the "License");
2
+ you may not use this file except in compliance with the License.
3
+ You may obtain a copy of the License at
4
+
5
+ http://www.apache.org/licenses/LICENSE-2.0
6
+
7
+ Unless required by applicable law or agreed to in writing, software
8
+ distributed under the License is distributed on an "AS IS" BASIS,
9
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10
+ See the License for the specific language governing permissions and
11
+ limitations under the License.
data/README.md ADDED
@@ -0,0 +1,86 @@
1
+ # Logstash Plugin
2
+
3
+ This is a plugin for [Logstash](https://github.com/elastic/logstash).
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.elastic.co/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/elastic/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. We also provide [example plugins](https://github.com/logstash-plugins?query=example).
26
+
27
+ - Install dependencies
28
+ ```sh
29
+ bundle install
30
+ ```
31
+
32
+ #### Test
33
+
34
+ - Update your dependencies
35
+
36
+ ```sh
37
+ bundle install
38
+ ```
39
+
40
+ - Run tests
41
+
42
+ ```sh
43
+ bundle exec rspec
44
+ ```
45
+
46
+ ### 2. Running your unpublished Plugin in Logstash
47
+
48
+ #### 2.1 Run in a local Logstash clone
49
+
50
+ - Edit Logstash `Gemfile` and add the local plugin path, for example:
51
+ ```ruby
52
+ gem "logstash-filter-awesome", :path => "/your/local/logstash-filter-awesome"
53
+ ```
54
+ - Install plugin
55
+ ```sh
56
+ bin/logstash-plugin install --no-verify
57
+ ```
58
+ - Run Logstash with your plugin
59
+ ```sh
60
+ bin/logstash -e 'filter {awesome {}}'
61
+ ```
62
+ At this point any modifications to the plugin code will be applied to this local Logstash setup. After modifying the plugin, simply rerun Logstash.
63
+
64
+ #### 2.2 Run in an installed Logstash
65
+
66
+ You can use the same **2.1** method to run your plugin in an installed Logstash by editing its `Gemfile` and pointing the `:path` to your local plugin development directory or you can build the gem and install it using:
67
+
68
+ - Build your plugin gem
69
+ ```sh
70
+ gem build logstash-filter-awesome.gemspec
71
+ ```
72
+ - Install the plugin from the Logstash home
73
+ ```sh
74
+ bin/logstash-plugin install /your/local/plugin/logstash-filter-awesome.gem
75
+ ```
76
+ - Start Logstash and proceed to test the plugin
77
+
78
+ ## Contributing
79
+
80
+ All contributions are welcome: ideas, patches, documentation, bug reports, complaints, and even something you drew up on a napkin.
81
+
82
+ 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.
83
+
84
+ It is more important to the community that you are able to contribute.
85
+
86
+ For more information about contributing, see the [CONTRIBUTING](https://github.com/elastic/logstash/blob/master/CONTRIBUTING.md) file.
@@ -0,0 +1,71 @@
1
+ # encoding: utf-8
2
+ require 'chronic'
3
+ require 'logstash/inputs/base'
4
+ require 'logstash/namespace'
5
+ require 'reqsample'
6
+ require 'socket' # for Socket.gethostname
7
+
8
+ # Generate randomized webserver log strings.
9
+ #
10
+ # Logs can be generated at once in bulk, or streamed over time.
11
+ class LogStash::Inputs::Reqsample < LogStash::Inputs::Base
12
+ config_name 'reqsample'
13
+
14
+ # If undefined, Logstash will complain, even if codec is unused.
15
+ default :codec, 'plain'
16
+
17
+ # Set how frequently messages should be sent.
18
+ #
19
+ # The default, `1000`, generates 1000 logs.
20
+ config :count, :validate => :number, :default => 1000
21
+
22
+ # The format in which logs should be generated.
23
+ config :format, :validate => :string, :default => 'apache'
24
+
25
+ # The peak of the normal distribution curve that logs will occur at.
26
+ #
27
+ # This should be a human-readable string that will be parsed by the Chronic
28
+ # gem.
29
+ config :peak, :validate => :string, :default => '12 hours ago'
30
+
31
+ # Standard deviation for the normal distribution of log events.
32
+ config :stdev, :validate => :number, :default => 4
33
+
34
+ # Whether the logs should be streamed gradually instead or returned all at
35
+ # once.
36
+ config :stream, :validate => :boolean, :default => false
37
+
38
+ # Cutoff (in hours) that logs should remain generated within.
39
+ config :truncate, :validate => :number, :default => 12
40
+
41
+ public
42
+
43
+ def register
44
+ @host = Socket.gethostname
45
+ @generator = ::ReqSample::Generator.new @stdev
46
+ @production_options = {
47
+ :count => @count,
48
+ :format => @format,
49
+ :truncate => @truncate,
50
+ :peak => Chronic.parse(@peak)
51
+ }
52
+ end # def register
53
+
54
+ def run(queue)
55
+ if @stream
56
+ @generator.produce(@production_options) do |log|
57
+ break if stop?
58
+ event = LogStash::Event.new('message' => log, 'host' => @host)
59
+ decorate(event)
60
+ queue << event
61
+ end # produce
62
+ else
63
+ @generator.produce(@production_options).each do |log|
64
+ break if stop?
65
+ event = LogStash::Event.new('message' => log, 'host' => @host)
66
+ decorate(event)
67
+ queue << event
68
+ end # produce
69
+ end # if @stream
70
+ end # def run
71
+ end # class LogStash::Inputs::Reqsample
@@ -0,0 +1,38 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = 'logstash-input-reqsample'
3
+ s.version = '0.1.0'
4
+ s.licenses = ['Apache License (2.0)']
5
+ s.summary = 'Generate randomized log events.'
6
+ s.description = 'Generate randomized log events.'
7
+ s.homepage = 'https://rubygems.org/gems/reqsample'
8
+ s.authors = ['Tyler Langlois']
9
+ s.email = 'tjl@byu.net'
10
+ s.require_paths = ['lib']
11
+
12
+ # Files
13
+ s.files = Dir[
14
+ 'lib/**/*',
15
+ 'spec/**/*',
16
+ 'vendor/**/*',
17
+ '*.gemspec',
18
+ '*.md',
19
+ 'CONTRIBUTORS',
20
+ 'Gemfile',
21
+ 'LICENSE',
22
+ 'NOTICE.TXT'
23
+ ]
24
+
25
+ # Tests
26
+ s.test_files = s.files.grep(%r{^(test|spec|features)/})
27
+
28
+ # Special flag to let us know this is actually a logstash plugin
29
+ s.metadata = { 'logstash_plugin' => 'true', 'logstash_group' => 'input' }
30
+
31
+ # Gem dependencies
32
+ s.add_runtime_dependency 'chronic', '~> 0.10.2'
33
+ s.add_runtime_dependency 'logstash-core-plugin-api', '~> 2.0'
34
+ s.add_runtime_dependency 'logstash-codec-plain'
35
+ s.add_runtime_dependency 'reqsample', '~> 0.0.2'
36
+ s.add_runtime_dependency 'stud', '>= 0.0.22'
37
+ s.add_development_dependency 'logstash-devutils'
38
+ end
@@ -0,0 +1,6 @@
1
+ # encoding: utf-8
2
+ require 'logstash/devutils/rspec/spec_helper'
3
+ require 'logstash/inputs/reqsample'
4
+
5
+ describe LogStash::Inputs::Reqsample do
6
+ end
metadata ADDED
@@ -0,0 +1,139 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: logstash-input-reqsample
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Tyler Langlois
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-09-30 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.10.2
19
+ name: chronic
20
+ prerelease: false
21
+ type: :runtime
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.10.2
27
+ - !ruby/object:Gem::Dependency
28
+ requirement: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - "~>"
31
+ - !ruby/object:Gem::Version
32
+ version: '2.0'
33
+ name: logstash-core-plugin-api
34
+ prerelease: false
35
+ type: :runtime
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '2.0'
41
+ - !ruby/object:Gem::Dependency
42
+ requirement: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ name: logstash-codec-plain
48
+ prerelease: false
49
+ type: :runtime
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ requirement: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: 0.0.2
61
+ name: reqsample
62
+ prerelease: false
63
+ type: :runtime
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 0.0.2
69
+ - !ruby/object:Gem::Dependency
70
+ requirement: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: 0.0.22
75
+ name: stud
76
+ prerelease: false
77
+ type: :runtime
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: 0.0.22
83
+ - !ruby/object:Gem::Dependency
84
+ requirement: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ name: logstash-devutils
90
+ prerelease: false
91
+ type: :development
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description: Generate randomized log events.
98
+ email: tjl@byu.net
99
+ executables: []
100
+ extensions: []
101
+ extra_rdoc_files: []
102
+ files:
103
+ - CHANGELOG.md
104
+ - CONTRIBUTORS
105
+ - DEVELOPER.md
106
+ - Gemfile
107
+ - LICENSE
108
+ - README.md
109
+ - lib/logstash/inputs/reqsample.rb
110
+ - logstash-input-reqsample.gemspec
111
+ - spec/inputs/reqsample_spec.rb
112
+ homepage: https://rubygems.org/gems/reqsample
113
+ licenses:
114
+ - Apache License (2.0)
115
+ metadata:
116
+ logstash_plugin: 'true'
117
+ logstash_group: input
118
+ post_install_message:
119
+ rdoc_options: []
120
+ require_paths:
121
+ - lib
122
+ required_ruby_version: !ruby/object:Gem::Requirement
123
+ requirements:
124
+ - - ">="
125
+ - !ruby/object:Gem::Version
126
+ version: '0'
127
+ required_rubygems_version: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ requirements: []
133
+ rubyforge_project:
134
+ rubygems_version: 2.6.8
135
+ signing_key:
136
+ specification_version: 4
137
+ summary: Generate randomized log events.
138
+ test_files:
139
+ - spec/inputs/reqsample_spec.rb