fluent-plugin-pagerduty 0.0.1

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: 96e70bdf4f296d3d857f89dbd2bb8938cb8b859e
4
+ data.tar.gz: 1aee8fba1aca9fc563c819c7e262623fe4366acc
5
+ SHA512:
6
+ metadata.gz: 8787ed0e0f46fc14f5aaf7efbf2b1662cb439e9bf68ced78b65de5b507e2d2d2e46a22ebd25ef232040c1e4181ac7217e04ec53d0f56f6e7107237898c2e7f8e
7
+ data.tar.gz: 26c760145fa0902f8856bf2ebf23e24e54136c813a9de17ca61270956e083b62c12c9ac8580d951a4b3c973055b535e7d90333b9f478220724870a767604094c
data/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ vendor/*
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in fluent-plugin-pagerduty.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,13 @@
1
+ Copyright (c) 2013- Kentaro Yoshida
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
data/README.md ADDED
@@ -0,0 +1,76 @@
1
+ # fluent-plugin-pagerduty does not work
2
+
3
+ Fluentd Output plugin to relay alert notification from application to [PagerDuty](http://www.pagerduty.com/).
4
+
5
+ ## Installation
6
+
7
+ install with `gem` or `fluent-gem` command as:
8
+
9
+ ```
10
+ # for fluentd
11
+ $ gem install fluent-plugin-pagerduty
12
+
13
+ # for td-agent
14
+ $ sudo /usr/lib64/fluent/ruby/bin/fluent-gem install fluent-plugin-pagerduty -v 0.0.1
15
+
16
+ # for td-agent2
17
+ $ sudo td-agent-gem install fluent-plugin-pagerduty -v 0.0.1
18
+ ```
19
+
20
+ ## Usage
21
+
22
+ 1. add service selecting `Service Type : Generic API system` on PagerDuty websites
23
+ 2. copy API Key from the `Services` page.
24
+ 3. install fluent-plugin-pagerduty with gem or fluent-gem command.
25
+ 4. create fluentd configuration like below.
26
+ 5. restart fluentd process.
27
+ 6. send test message for fluent-plugin-pagerduty
28
+
29
+ #### configuration example
30
+
31
+ ```
32
+ <source>
33
+ type forward
34
+ </source>
35
+
36
+ <source>
37
+ type http
38
+ port 8888
39
+ </source>
40
+
41
+ <match notify.pagerduty>
42
+ type pagerduty
43
+ service_key ******************
44
+ </match>
45
+ ```
46
+
47
+ #### notify example
48
+
49
+ ```
50
+ # via forward
51
+ $ echo '{"description":"Form validation has failed","details":{"name":"success","mail":"failed"}}' | fluent-cat notify.pagerduty
52
+
53
+ # via http
54
+ $ curl http://localhost:8888/notify.pagerduty -F 'json={"description":"Form validation has failed","details":{"name":"success","mail":"failed"}}'
55
+ ```
56
+
57
+ ## Contributing
58
+
59
+ 1. Fork it
60
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
61
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
62
+ 4. Push to the branch (`git push origin my-new-feature`)
63
+ 5. Create new Pull Request
64
+
65
+ ## TODO
66
+
67
+ patches welcome!
68
+
69
+ ## Copyright
70
+
71
+ Copyright (c) 2013- Kentaro Yoshida (@yoshi_ken)
72
+
73
+ ## License
74
+
75
+ Apache License, Version 2.0
76
+
data/Rakefile ADDED
@@ -0,0 +1,9 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+ Rake::TestTask.new(:test) do |test|
4
+ test.libs << 'lib' << 'test'
5
+ test.pattern = 'test/**/test_*.rb'
6
+ test.verbose = true
7
+ end
8
+
9
+ task :default => :test
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "fluent-plugin-pagerduty"
7
+ spec.version = "0.0.1"
8
+ spec.authors = ["Kentaro Yoshida"]
9
+ spec.email = ["y.ken.studio@gmail.com"]
10
+ spec.description = %q{Fluentd Input plugin to replay alert notification for PagerDuty API.}
11
+ spec.summary = %q{Fluentd Input plugin to replay alert notification for PagerDuty API.}
12
+ spec.homepage = "https://github.com/y-ken/fluent-plugin-pagerduty"
13
+ spec.license = "Apache License, Version 2.0"
14
+
15
+ spec.files = `git ls-files`.split($/)
16
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.add_development_dependency "bundler"
21
+ spec.add_development_dependency "rake"
22
+ spec.add_runtime_dependency "fluentd"
23
+ spec.add_runtime_dependency "pagerduty"
24
+ end
@@ -0,0 +1,42 @@
1
+ class Fluent::PagerdutyOutput < Fluent::Output
2
+ Fluent::Plugin.register_output('pagerduty', self)
3
+
4
+ def initialize
5
+ require 'pagerduty'
6
+ super
7
+ end
8
+
9
+ config_param :service_key, :string, :default => nil
10
+ config_param :event_type, :string, :default => 'trigger'
11
+ config_param :description, :string, :default => nil
12
+
13
+ def configure(conf)
14
+ super
15
+
16
+ if @service_key.nil?
17
+ $log.warn "pagerduty: service_key required."
18
+ end
19
+ end
20
+
21
+ def emit(tag, es, chain)
22
+ es.each do |time,record|
23
+ call_pagerduty(record)
24
+ end
25
+
26
+ chain.next
27
+ end
28
+
29
+ def call_pagerduty(record)
30
+ begin
31
+ service_key = record['service_key'] || @service_key
32
+ event_type = record['event_type'] || @event_type
33
+ description = record['description'] || record['message'] || @description
34
+ details = record['details'] || record
35
+ options = {"details" => details}
36
+ api = Pagerduty.new(service_key)
37
+ incident = api.trigger description, options
38
+ rescue => e
39
+ $log.error "pagerduty: request failed. ", :error_class=>e.class, :error=>e.message
40
+ end
41
+ end
42
+ end
data/test/helper.rb ADDED
@@ -0,0 +1,28 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ begin
4
+ Bundler.setup(:default, :development)
5
+ rescue Bundler::BundlerError => e
6
+ $stderr.puts e.message
7
+ $stderr.puts "Run `bundle install` to install missing gems"
8
+ exit e.status_code
9
+ end
10
+ require 'test/unit'
11
+
12
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
13
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
14
+ require 'fluent/test'
15
+ unless ENV.has_key?('VERBOSE')
16
+ nulllogger = Object.new
17
+ nulllogger.instance_eval {|obj|
18
+ def method_missing(method, *args)
19
+ # pass
20
+ end
21
+ }
22
+ $log = nulllogger
23
+ end
24
+
25
+ require 'fluent/plugin/out_pagerduty'
26
+
27
+ class Test::Unit::TestCase
28
+ end
File without changes
metadata ADDED
@@ -0,0 +1,111 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fluent-plugin-pagerduty
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Kentaro Yoshida
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-03-19 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: fluentd
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: pagerduty
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: Fluentd Input plugin to replay alert notification for PagerDuty API.
70
+ email:
71
+ - y.ken.studio@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - Gemfile
78
+ - LICENSE.txt
79
+ - README.md
80
+ - Rakefile
81
+ - fluent-plugin-pagerduty.gemspec
82
+ - lib/fluent/plugin/out_pagerduty.rb
83
+ - test/helper.rb
84
+ - test/plugin/test_out_pagerdyty.rb
85
+ homepage: https://github.com/y-ken/fluent-plugin-pagerduty
86
+ licenses:
87
+ - Apache License, Version 2.0
88
+ metadata: {}
89
+ post_install_message:
90
+ rdoc_options: []
91
+ require_paths:
92
+ - lib
93
+ required_ruby_version: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - ">="
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
98
+ required_rubygems_version: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ requirements: []
104
+ rubyforge_project:
105
+ rubygems_version: 2.2.5
106
+ signing_key:
107
+ specification_version: 4
108
+ summary: Fluentd Input plugin to replay alert notification for PagerDuty API.
109
+ test_files:
110
+ - test/helper.rb
111
+ - test/plugin/test_out_pagerdyty.rb