diff --git a/DEVELOPER.md b/DEVELOPER.md new file mode 100644 index 0000000..c1a77cf --- /dev/null +++ b/DEVELOPER.md @@ -0,0 +1,2 @@ +# logstash-output-rollbar +Example output plugin. This should help bootstrap your effort to write your own output plugin! diff --git a/Gemfile b/Gemfile index c48c3d1..06618ce 100644 --- a/Gemfile +++ b/Gemfile @@ -1,3 +1,3 @@ source 'https://rubygems.org' gemspec -gem "logstash", :github => "elasticsearch/logstash", :branch => "1.5" + diff --git a/LICENSE b/LICENSE index 8eba2be..51fca54 100644 --- a/LICENSE +++ b/LICENSE @@ -1,5 +1,3 @@ -Copyright (c) 2012-2015 Elasticsearch - 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 diff --git a/README.md b/README.md index 3f008af..2070593 100644 --- a/README.md +++ b/README.md @@ -1,19 +1,19 @@ # Logstash Plugin -This is a plugin for [Logstash](https://github.com/elasticsearch/logstash) that sends events to the [Rollbar](https://www.rollbar.com) error monitoring service. +This is a plugin for [Logstash](https://github.com/elastic/logstash) that sends events to the [Rollbar](https://www.rollbar.com) error monitoring service. 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.elasticsearch.org/guide/en/logstash/current/). +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/elasticsearch/docs#asciidoc-guide +- 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 logstash-users@googlegroups.com mailing list. +Need help? Try #logstash on freenode IRC or the https://discuss.elastic.co/c/logstash discussion forum. ## Developing @@ -22,7 +22,7 @@ Need help? Try #logstash on freenode IRC or the logstash-users@googlegroups.com #### 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. +- 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 @@ -31,26 +31,15 @@ bundle install #### Test -```sh -bundle exec rspec -``` +- Update your dependencies -The Logstash code required to run the tests/specs is specified in the `Gemfile` by the line similar to: -```ruby -gem "logstash", :github => "elasticsearch/logstash", :branch => "1.5" -``` -To test against another version or a local Logstash, edit the `Gemfile` to specify an alternative location, for example: -```ruby -gem "logstash", :github => "elasticsearch/logstash", :ref => "master" -``` -```ruby -gem "logstash", :path => "/your/local/logstash" +```sh +bundle install ``` -Then update your dependencies and run your tests: +- Run tests ```sh -bundle install bundle exec rspec ``` @@ -58,13 +47,13 @@ bundle exec rspec #### 2.1 Run in a local Logstash clone -- Edit Logstash `tools/Gemfile` and add the local plugin path, for example: +- Edit Logstash `Gemfile` and add the local plugin path, for example: ```ruby gem "logstash-filter-awesome", :path => "/your/local/logstash-filter-awesome" ``` -- Update Logstash dependencies +- Install plugin ```sh -rake vendor:gems +bin/logstash-plugin install --no-verify ``` - Run Logstash with your plugin ```sh @@ -74,13 +63,15 @@ At this point any modifications to the plugin code will be applied to this local #### 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/plugin install /your/local/plugin/logstash-filter-awesome.gem +bin/logstash-plugin install /your/local/plugin/logstash-filter-awesome.gem ``` - Start Logstash and proceed to test the plugin @@ -90,6 +81,6 @@ All contributions are welcome: ideas, patches, documentation, bug reports, compl 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 me that you are able to contribute. +It is more important to the community that you are able to contribute. -For more information about contributing, see the [CONTRIBUTING](https://github.com/elasticsearch/logstash/blob/master/CONTRIBUTING.md) file. +For more information about contributing, see the [CONTRIBUTING](https://github.com/elastic/logstash/blob/master/CONTRIBUTING.md) file. diff --git a/Rakefile b/Rakefile index 4f4b858..d50e796 100644 --- a/Rakefile +++ b/Rakefile @@ -1,7 +1 @@ -@files=[] - -task :default do - system("rake -T") -end - require "logstash/devutils/rake" diff --git a/docs/index.asciidoc b/docs/index.asciidoc new file mode 100644 index 0000000..623a89d --- /dev/null +++ b/docs/index.asciidoc @@ -0,0 +1,127 @@ +:plugin: example +:type: output +:default_codec: plain +// Update header with plugin name and default codec + +/////////////////////////////////////////// +START - GENERATED VARIABLES, DO NOT EDIT! +/////////////////////////////////////////// +:version: %VERSION% +:release_date: %RELEASE_DATE% +:changelog_url: %CHANGELOG_URL% +:include_path: ../../../../logstash/docs/include +/////////////////////////////////////////// +END - GENERATED VARIABLES, DO NOT EDIT! +/////////////////////////////////////////// + +[id="plugins-{type}s-{plugin}"] + +=== Example output plugin + +include::{include_path}/plugin_header.asciidoc[] + +==== Description + +Add plugin description here + +// Format anchors and links to support generated ids for versioning +// Sample anchor: [id="plugins-{type}s-{plugin}-setting_name"] +// Sample link: <> + +[id="plugins-{type}s-{plugin}-options"] +==== Example Output Configuration Options + +[cols="<,<,<",options="header",] +|======================================================================= +|Setting |Input type|Required +| <> |<>|No +| <> |<>|No +| <> |<>|No +| <> |<>|No +| <> |<>|No +| <> |<>|No +| <> |<>|No +| <> |<>|No +| <> |<>|No +|======================================================================= + +[id="plugins-{type}s-{plugin}-a_setting_name"] +===== `a_setting_name` + + * Value type is <> + * Default value is `true` + +Add description here + +[id="plugins-{type}s-{plugin}-another_setting_name"] +===== `another_setting_name` + + * Value type is <> + * Default value is `{}` + +Add description here + +[id="plugins-{type}s-{plugin}-setting_name_3"] +===== `setting_name_3` + + * Value type is <> + * Default value is `{}` + +Add description here + +[id="plugins-{type}s-{plugin}-setting_name_4"] +===== `setting_name_4` + + * Value type is <> + * Default value is `0` + +Add description here + +[id="plugins-{type}s-{plugin}-setting_name_5"] +===== `setting_name_5` + + * Value type is <> + * Default value is {} + +Add description here + +[id="plugins-{type}s-{plugin}-setting_name_6"] +===== `setting_name_6` + + * Value type is <> + * Default value is {} + +Add description here + +[id="plugins-{type}s-{plugin}-setting_name_7"] +===== `setting_name_7` + + * Value type is <> + * Default value is {} + +Add description here + +[id="plugins-{type}s-{plugin}-setting_name_8"] +===== `setting_name_8` + + * Value type is <> + * Default value is {} + +Add description here + + +[id="plugins-{type}s-{plugin}-setting_name_9"] +===== `setting_name_9` + + * Value type is <> + * Default value is {} + +Add description here + +// The full list of Value Types is here: +// https://www.elastic.co/guide/en/logstash/current/configuration-file-structure.html + +[id="plugins-{type}s-{plugin}-common-options"] +include::{include_path}/{type}.asciidoc[] + +:default_codec!: diff --git a/logstash-output-rollbar.gemspec b/logstash-output-rollbar.gemspec index 611e5fd..ca96fe8 100644 --- a/logstash-output-rollbar.gemspec +++ b/logstash-output-rollbar.gemspec @@ -1,27 +1,25 @@ Gem::Specification.new do |s| - s.name = 'logstash-output-rollbar' - s.version = '0.2.0' - s.licenses = ['Apache License (2.0)'] - s.summary = "The Rollbar Logstash output sends events to the Rollbar error monitoring service." - s.description = "This gem is a logstash plugin. Install using: $LS_HOME/bin/plugin install gemname. This gem is not a stand-alone program" - s.authors = ["Rollbar"] - s.email = 'support@rollbar.com' - s.homepage = "https://github.com/rollbar/logstash-output-rollbar" - s.require_paths = ["lib"] + s.name = 'logstash-output-rollbar' + s.version = '0.2.0' + s.licenses = ['Apache-2.0'] + s.summary = 'The Rollbar Logstash output sends events to the Rollbar error monitoring service.' + s.description = 'This gem is a logstash plugin. Install using: $LS_HOME/bin/plugin install gemname. This gem is not a stand-alone program' + s.authors = ['Rollbar'] + s.email = 'support@rollbar.com' + s.homepage = 'https://github.com/rollbar/logstash-output-rollbar' + s.require_paths = ['lib'] # Files - s.files = `git ls-files`.split($\)+::Dir.glob('vendor/*') - - # Tests + 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" => "output" } # Gem dependencies - s.add_runtime_dependency 'logstash-core', '>= 1.4.0', '< 2.0.0' - - s.add_development_dependency 'logstash-devutils' + s.add_runtime_dependency "logstash-core-plugin-api", "~> 2.0" + s.add_runtime_dependency "logstash-codec-plain" + s.add_development_dependency "logstash-devutils" end - diff --git a/spec/outputs/rollbar_spec.rb b/spec/outputs/rollbar_spec.rb index 6bf5945..084d528 100644 --- a/spec/outputs/rollbar_spec.rb +++ b/spec/outputs/rollbar_spec.rb @@ -1 +1,22 @@ +# encoding: utf-8 require "logstash/devutils/rspec/spec_helper" +require "logstash/outputs/rollbar" +require "logstash/codecs/plain" +require "logstash/event" + +describe LogStash::Outputs::Rollbar do + let(:sample_event) { LogStash::Event.new } + let(:output) { LogStash::Outputs::Rollbar.new } + + before do + output.register + end + + describe "receive message" do + subject { output.receive(sample_event) } + + it "returns a string" do + expect(subject).to eq("Event received") + end + end +end