-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
root
committed
Oct 3, 2018
0 parents
commit 09184a3
Showing
10 changed files
with
201 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
## 0.1.0 | ||
- Plugin created with the logstash plugin generator |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
The following is a list of people who have contributed ideas, code, bug | ||
reports, or in general have helped logstash along its way. | ||
|
||
Contributors: | ||
* - | ||
|
||
Note: If you've sent us patches, bug reports, or otherwise contributed to | ||
Logstash, and you aren't on the list above and want to be, please let us know | ||
and we'll make sure you're here. Contributions from folks like you are what make | ||
open source awesome. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# logstash-input-okta_system_log | ||
Example input plugin. This should help bootstrap your effort to write your own input plugin! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
source 'https://rubygems.org' | ||
gemspec | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
# Logstash Plugin | ||
|
||
This is a plugin for [Logstash](https://github.com/elastic/logstash). | ||
|
||
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. | ||
|
||
## Documentation | ||
|
||
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/). | ||
|
||
- For formatting code or config example, you can use the asciidoc `[source,ruby]` directive | ||
- For more asciidoc formatting tips, see the excellent reference here https://github.com/elastic/docs#asciidoc-guide | ||
|
||
## Need Help? | ||
|
||
Need help? Try #logstash on freenode IRC or the https://discuss.elastic.co/c/logstash discussion forum. | ||
|
||
## Developing | ||
|
||
### 1. Plugin Developement and Testing | ||
|
||
#### Code | ||
- To get started, you'll need JRuby with the Bundler gem installed. | ||
|
||
- 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). | ||
|
||
- Install dependencies | ||
```sh | ||
bundle install | ||
``` | ||
|
||
#### Test | ||
|
||
- Update your dependencies | ||
|
||
```sh | ||
bundle install | ||
``` | ||
|
||
- Run tests | ||
|
||
```sh | ||
bundle exec rspec | ||
``` | ||
|
||
### 2. Running your unpublished Plugin in Logstash | ||
|
||
#### 2.1 Run in a local Logstash clone | ||
|
||
- Edit Logstash `Gemfile` and add the local plugin path, for example: | ||
```ruby | ||
gem "logstash-filter-awesome", :path => "/your/local/logstash-filter-awesome" | ||
``` | ||
- Install plugin | ||
```sh | ||
bin/logstash-plugin install --no-verify | ||
``` | ||
- Run Logstash with your plugin | ||
```sh | ||
bin/logstash -e 'filter {awesome {}}' | ||
``` | ||
At this point any modifications to the plugin code will be applied to this local Logstash setup. After modifying the plugin, simply rerun Logstash. | ||
|
||
#### 2.2 Run in an installed Logstash | ||
|
||
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: | ||
|
||
- Build your plugin gem | ||
```sh | ||
gem build logstash-filter-awesome.gemspec | ||
``` | ||
- Install the plugin from the Logstash home | ||
```sh | ||
bin/logstash-plugin install /your/local/plugin/logstash-filter-awesome.gem | ||
``` | ||
- Start Logstash and proceed to test the plugin | ||
|
||
## Contributing | ||
|
||
All contributions are welcome: ideas, patches, documentation, bug reports, complaints, and even something you drew up on a napkin. | ||
|
||
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. | ||
|
||
It is more important to the community that you are able to contribute. | ||
|
||
For more information about contributing, see the [CONTRIBUTING](https://github.com/elastic/logstash/blob/master/CONTRIBUTING.md) file. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
require "logstash/devutils/rake" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# encoding: utf-8 | ||
require "logstash/inputs/base" | ||
require "stud/interval" | ||
require "socket" # for Socket.gethostname | ||
|
||
# Generate a repeating message. | ||
# | ||
# This plugin is intented only as an example. | ||
|
||
class LogStash::Inputs::OktaSystemLog < LogStash::Inputs::Base | ||
config_name "" | ||
|
||
# If undefined, Logstash will complain, even if codec is unused. | ||
default :codec, "plain" | ||
|
||
# The message string to use in the event. | ||
config :message, :validate => :string, :default => "Hello World!" | ||
|
||
# Set how frequently messages should be sent. | ||
# | ||
# The default, `1`, means send a message every second. | ||
config :interval, :validate => :number, :default => 1 | ||
|
||
public | ||
def register | ||
@host = Socket.gethostname | ||
end # def register | ||
|
||
def run(queue) | ||
# we can abort the loop if stop? becomes true | ||
while !stop? | ||
event = LogStash::Event.new("message" => @message, "host" => @host) | ||
decorate(event) | ||
queue << event | ||
# because the sleep interval can be big, when shutdown happens | ||
# we want to be able to abort the sleep | ||
# Stud.stoppable_sleep will frequently evaluate the given block | ||
# and abort the sleep(@interval) if the return value is true | ||
Stud.stoppable_sleep(@interval) { stop? } | ||
end # loop | ||
end # def run | ||
|
||
def stop | ||
# nothing to do in this case so it is not necessary to define stop | ||
# examples of common "stop" tasks: | ||
# * close sockets (unblocking blocking reads/accepts) | ||
# * cleanup temporary files | ||
# * terminate spawned threads | ||
end | ||
end # class LogStash::Inputs::OktaSystemLog |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
Gem::Specification.new do |s| | ||
s.name = 'logstash-input-okta_system_log' | ||
s.version = '0.1.0' | ||
s.licenses = ['Apache-2.0'] | ||
s.summary = 'TODO: Write a short summary, because Rubygems requires one.' | ||
s.description = '{TODO: Write a longer description or delete this line.' | ||
s.homepage = 'TODO: Put your plugin''s website or public repo URL here.' | ||
s.authors = [''] | ||
s.email = '' | ||
s.require_paths = ['lib'] | ||
|
||
# Files | ||
s.files = Dir['lib/**/*','spec/**/*','vendor/**/*','*.gemspec','*.md','CONTRIBUTORS','Gemfile','LICENSE','NOTICE.TXT'] | ||
# Tests | ||
s.test_files = s.files.grep(%r{^(test|spec|features)/}) | ||
|
||
# Special flag to let us know this is actually a logstash plugin | ||
s.metadata = { "logstash_plugin" => "true", "logstash_group" => "input" } | ||
|
||
# Gem dependencies | ||
s.add_runtime_dependency "logstash-core-plugin-api", "~> 2.0" | ||
s.add_runtime_dependency 'logstash-codec-plain' | ||
s.add_runtime_dependency 'stud', '>= 0.0.22' | ||
s.add_development_dependency 'logstash-devutils', '>= 0.0.16' | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# encoding: utf-8 | ||
require "logstash/devutils/rspec/spec_helper" | ||
require "logstash/inputs/okta_system_log" | ||
|
||
describe LogStash::Inputs::OktaSystemLog do | ||
|
||
it_behaves_like "an interruptible input plugin" do | ||
let(:config) { { "interval" => 100 } } | ||
end | ||
|
||
end |