logstash-output-hangoutchat 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: ba0817e131bd6f1f0100aebbb2b6875a84352536da9300cf0db740359540906d
4
+ data.tar.gz: a285af92b45e5b81033e848cfc2c48a06a84fbab85afaa82c09278201b93a503
5
+ SHA512:
6
+ metadata.gz: c01ab517376a31e54f279bf14a0f2de7f2a9562baa83984888a621efa9d90d14529e606f3fcbc1c3c4cb14aa4c83a6f45137b95f3fbe9e6ceb54903c08ab643d
7
+ data.tar.gz: 3c2e7314479d4add37f7d26c6d4774be2449095ee2edb3f1e9e3d0ff392ca71e052a77004d2c20e9aee1ae0ec8ce33b535ee9fb142a047e419be35f8362f021d
data/Gemfile ADDED
@@ -0,0 +1,11 @@
1
+ source 'http://production.cf.rubygems.org'
2
+
3
+ gemspec
4
+
5
+ logstash_path = ENV["LOGSTASH_PATH"] || "../../logstash"
6
+ use_logstash_source = ENV["LOGSTASH_SOURCE"] && ENV["LOGSTASH_SOURCE"].to_s == "1"
7
+
8
+ if Dir.exist?(logstash_path) && use_logstash_source
9
+ gem 'logstash-core', :path => "#{logstash_path}/logstash-core"
10
+ gem 'logstash-core-plugin-api', :path => "#{logstash_path}/logstash-core-plugin-api"
11
+ end
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License
2
+
3
+ Copyright (c) 2010 Xtreme Labs, Pivotal Labs and Google Inc.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,5 @@
1
+ Elasticsearch
2
+ Copyright 2012-2015 Elasticsearch
3
+
4
+ This product includes software developed by The Apache Software
5
+ Foundation (http://www.apache.org/).
@@ -0,0 +1,98 @@
1
+ # Logstash Plugin
2
+
3
+ This is a plugin for [Logstash](https://github.com/elastic/logstash).
4
+
5
+ ## Documentation
6
+
7
+ 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/).
8
+
9
+ - For formatting code or config example, you can use the asciidoc `[source,ruby]` directive
10
+ - For more asciidoc formatting tips, see the excellent reference here https://github.com/elastic/docs#asciidoc-guide
11
+
12
+ ### Description
13
+
14
+ This output allows you to write events to [Stride](https://www.stride.com).
15
+
16
+ ## Need Help?
17
+
18
+ Need help? Try #logstash on freenode IRC or the https://discuss.elastic.co/c/logstash discussion forum.
19
+
20
+ ## Developing
21
+
22
+ ### 1. Plugin Developement and Testing
23
+
24
+ #### Code
25
+ - To get started, you'll need JRuby with the Bundler gem installed.
26
+
27
+ - 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).
28
+
29
+ - Install dependencies
30
+ ```sh
31
+ bundle install
32
+ ```
33
+
34
+ #### Test
35
+
36
+ - Update your dependencies
37
+
38
+ ```sh
39
+ bundle install
40
+ ```
41
+
42
+ - Run tests
43
+
44
+ ```sh
45
+ bundle exec rspec
46
+ ```
47
+
48
+ ### 2. Running your unpublished Plugin in Logstash
49
+
50
+ #### 2.1 Run in a local Logstash clone
51
+
52
+ - Edit Logstash `Gemfile` and add the local plugin path, for example:
53
+ ```ruby
54
+ gem "logstash-filter-awesome", :path => "/your/local/logstash-filter-awesome"
55
+ ```
56
+ - Install plugin
57
+ ```sh
58
+ # Logstash 2.3 and higher
59
+ bin/logstash-plugin install --no-verify
60
+
61
+ # Prior to Logstash 2.3
62
+ bin/plugin install --no-verify
63
+
64
+ ```
65
+ - Run Logstash with your plugin
66
+ ```sh
67
+ bin/logstash -e 'filter {awesome {}}'
68
+ ```
69
+ At this point any modifications to the plugin code will be applied to this local Logstash setup. After modifying the plugin, simply rerun Logstash.
70
+
71
+ #### 2.2 Run in an installed Logstash
72
+
73
+ 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:
74
+
75
+ - Build your plugin gem
76
+ ```sh
77
+ gem build logstash-filter-awesome.gemspec
78
+ ```
79
+ - Install the plugin from the Logstash home
80
+ ```sh
81
+ # Logstash 2.3 and higher
82
+ bin/logstash-plugin install --no-verify
83
+
84
+ # Prior to Logstash 2.3
85
+ bin/plugin install --no-verify
86
+
87
+ ```
88
+ - Start Logstash and proceed to test the plugin
89
+
90
+ ## Contributing
91
+
92
+ All contributions are welcome: ideas, patches, documentation, bug reports, complaints, and even something you drew up on a napkin.
93
+
94
+ 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.
95
+
96
+ It is more important to the community that you are able to contribute.
97
+
98
+ For more information about contributing, see the [CONTRIBUTING](https://github.com/elastic/logstash/blob/master/CONTRIBUTING.md) file.
@@ -0,0 +1,69 @@
1
+ # encoding: utf-8
2
+ require "logstash/outputs/base"
3
+ require "logstash/namespace"
4
+ require 'net/http'
5
+ require 'uri'
6
+ require 'json'
7
+
8
+ # An example output that does nothing.
9
+ class LogStash::Outputs::HangoutChat < LogStash::Outputs::Base
10
+
11
+ config_name "hangoutchat"
12
+
13
+ # the access token, cloud_id and conversation id of the stride room
14
+ config :webhook, :validate => :string, :required => true
15
+
16
+ # message variable contains the default message retreived inside logstash
17
+ # Examples:-
18
+ # for nxlog default message is in `Message` variable
19
+ # for filebeat & log4j default message is in `message` variable
20
+ config :message, :validate => :string, :default => "%{message}"
21
+
22
+ # the host contains the IP, type is the type of log and severity denotes priority
23
+ config :host, :validate => :string, :default => "%{host}"
24
+ config :type, :validate => :string, :default => "%{type}"
25
+ config :priority, :validate => :string, :default => "%{priority}"
26
+
27
+ public
28
+ def register
29
+ end # def register
30
+
31
+ public
32
+ def receive(event)
33
+
34
+ # initialize all variables
35
+ url = event.sprintf(@webhook)
36
+ message = event.sprintf(@message)
37
+ host = event.sprintf(@host)
38
+ type = event.sprintf(@type)
39
+ priority = event.sprintf(@priority)
40
+
41
+ post_message(url,host,type,priority,message)
42
+
43
+ rescue Exception => e
44
+ puts '**** ERROR ****'
45
+ puts e.message
46
+ end
47
+
48
+ # sends the message to hangout-chat
49
+ public
50
+ def post_message(url,host,type,priority,message)
51
+
52
+ # format of the log
53
+ message = %Q|#{Time.now} : #{message}|
54
+ message = %Q|#{host} : #{message}| if host
55
+ message = %Q|#{type} : #{message}| if type
56
+ message = %Q|#{priority} : #{message}| if priority
57
+
58
+ # prep and send the http request
59
+ uri = URI.parse(url)
60
+ request = Net::HTTP::Post.new(uri)
61
+ request['Content-Type'] = "application/json"
62
+ request.body = {text: message}.to_json
63
+ response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
64
+ http.request(request)
65
+ end
66
+
67
+ end
68
+
69
+ end # class LogStash::Outputs::HangoutChat
@@ -0,0 +1,25 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = 'logstash-output-hangoutchat'
3
+ s.version = '0.0.1'
4
+ s.licenses = ['Apache-2.0']
5
+ s.summary = "This logstash ouput plugin allows posting messages to google hangouts chat rooms"
6
+ s.description = "This gem is a Logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/logstash-plugin install gemname. This gem is not a stand-alone program"
7
+ s.authors = ["Vishnu Prasanth"]
8
+ s.email = "vishnu@ontash.net"
9
+ s.homepage = "http://www.ontash.net"
10
+ s.require_paths = ["lib"]
11
+
12
+ # Files
13
+ s.files = Dir['lib/**/*','spec/**/*','vendor/**/*','*.gemspec','*.md','CONTRIBUTORS','Gemfile','LICENSE','NOTICE.TXT']
14
+ # Tests
15
+ s.test_files = s.files.grep(%r{^(test|spec|features)/})
16
+
17
+ # Special flag to let us know this is actually a logstash plugin
18
+ s.metadata = { "logstash_plugin" => "true", "logstash_group" => "output" }
19
+
20
+ # Gem dependencies
21
+ #
22
+ s.add_runtime_dependency "logstash-core-plugin-api", "~> 2.0", "<= 2.99"
23
+ s.add_runtime_dependency "logstash-codec-plain", '~> 3.0', '>= 3.0.6'
24
+ s.add_development_dependency 'logstash-devutils', '~> 1.3', '>= 1.3.6'
25
+ end
@@ -0,0 +1,19 @@
1
+ # encoding: utf-8
2
+ require "logstash/devutils/rspec/spec_helper"
3
+ require "logstash/outputs/hangoutchat"
4
+ require "logstash/codecs/plain"
5
+ require "logstash/event"
6
+
7
+ describe LogStash::Outputs::HangoutChat do
8
+ let(:sample_event) { LogStash::Event.new }
9
+ let(:output) { LogStash::Outputs::HangoutChat.new }
10
+
11
+ before do
12
+ output.register
13
+ end
14
+
15
+ describe "receive message" do
16
+ subject { output.receive(sample_event) }
17
+ end
18
+ end
19
+ end
metadata ADDED
@@ -0,0 +1,116 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: logstash-output-hangoutchat
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Vishnu Prasanth
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-01-31 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'
19
+ - - "<="
20
+ - !ruby/object:Gem::Version
21
+ version: '2.99'
22
+ name: logstash-core-plugin-api
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'
30
+ - - "<="
31
+ - !ruby/object:Gem::Version
32
+ version: '2.99'
33
+ - !ruby/object:Gem::Dependency
34
+ requirement: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - "~>"
37
+ - !ruby/object:Gem::Version
38
+ version: '3.0'
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ version: 3.0.6
42
+ name: logstash-codec-plain
43
+ prerelease: false
44
+ type: :runtime
45
+ version_requirements: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - "~>"
48
+ - !ruby/object:Gem::Version
49
+ version: '3.0'
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: 3.0.6
53
+ - !ruby/object:Gem::Dependency
54
+ requirement: !ruby/object:Gem::Requirement
55
+ requirements:
56
+ - - "~>"
57
+ - !ruby/object:Gem::Version
58
+ version: '1.3'
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: 1.3.6
62
+ name: logstash-devutils
63
+ prerelease: false
64
+ type: :development
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - "~>"
68
+ - !ruby/object:Gem::Version
69
+ version: '1.3'
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: 1.3.6
73
+ description: This gem is a Logstash plugin required to be installed on top of the
74
+ Logstash core pipeline using $LS_HOME/bin/logstash-plugin install gemname. This
75
+ gem is not a stand-alone program
76
+ email: vishnu@ontash.net
77
+ executables: []
78
+ extensions: []
79
+ extra_rdoc_files: []
80
+ files:
81
+ - Gemfile
82
+ - LICENSE
83
+ - NOTICE.TXT
84
+ - README.md
85
+ - lib/logstash/outputs/hangoutchat.rb
86
+ - logstash-output-hangoutchat.gemspec
87
+ - spec/outputs/hangoutchat_spec.rb
88
+ homepage: http://www.ontash.net
89
+ licenses:
90
+ - Apache-2.0
91
+ metadata:
92
+ logstash_plugin: 'true'
93
+ logstash_group: output
94
+ post_install_message:
95
+ rdoc_options: []
96
+ require_paths:
97
+ - lib
98
+ required_ruby_version: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ required_rubygems_version: !ruby/object:Gem::Requirement
104
+ requirements:
105
+ - - ">="
106
+ - !ruby/object:Gem::Version
107
+ version: '0'
108
+ requirements: []
109
+ rubyforge_project:
110
+ rubygems_version: 2.6.13
111
+ signing_key:
112
+ specification_version: 4
113
+ summary: This logstash ouput plugin allows posting messages to google hangouts chat
114
+ rooms
115
+ test_files:
116
+ - spec/outputs/hangoutchat_spec.rb