fluent-plugin-newrelictransform 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/Gemfile +4 -0
- data/README +65 -0
- data/README.md +65 -0
- data/Rakefile +13 -0
- data/fluent-plugin-newrelic.gemspec +24 -0
- data/lib/fluent/plugin/out_newrelic.rb +62 -0
- data/sample/snmp.conf.sample +15 -0
- data/test/helper.rb +28 -0
- data/test/plugin/test_in_newrelic.rb +24 -0
- metadata +129 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 3cd6718c44974ac5f041abc9f6b03dc4bbf58a86
|
4
|
+
data.tar.gz: 932c47cda15b15bd989dc589b4d20e72d1693917
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a9a1e2d913dd54b0b5ed97de840dabd5c68c7e5429b00d2f608149bf7eda0c1979234be594656ee870c64975fdcd12c40f62d566e1b5a8e5d9ba5624bf760667
|
7
|
+
data.tar.gz: 1093c50c2cf54a9d222267f2085c983ca739f2074fdd76219b8676a3e587570e01cafd927faa504b19b7e1f2366cc220a1b10058a97fa6df0350e841acaa99ae
|
data/Gemfile
ADDED
data/README
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
# Fluent::Plugin::NewRelic
|
2
|
+
|
3
|
+
fluent-plugin-newlrelictransform is an input plug-in for [Fluentd](http://fluentd.org)
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
These instructions assume you already have fluentd installed.
|
8
|
+
If you don't, please run through [quick start for fluentd] (https://github.com/fluent/fluentd#quick-start)
|
9
|
+
|
10
|
+
Now after you have fluentd installed you can follow either of the steps below:
|
11
|
+
|
12
|
+
Add this line to your application's Gemfile:
|
13
|
+
|
14
|
+
gem 'fluent-plugin-newlrelictransform'
|
15
|
+
|
16
|
+
Or install it yourself as:
|
17
|
+
|
18
|
+
$ gem install fluent-plugin-newlrelictransform
|
19
|
+
|
20
|
+
## Usage
|
21
|
+
This plugin can be used in conjunction with fluent-plugin-ironio. A typical use case is to use webhooks in newrelic and forward alerts to ironio. This is done when the alert handling infrastructure is behind a firewall and cannot ingest them directly. The messages coming from ironio is then funnelled to this plugin where it breaks up the alerts into individual ones.
|
22
|
+
Add the following into your fluentd config.
|
23
|
+
|
24
|
+
<match alert.newrelic.in>
|
25
|
+
type newrelic
|
26
|
+
log_level debug
|
27
|
+
</match>
|
28
|
+
|
29
|
+
#{"creation_time":"2015-02-11T13:58:08Z","business_unit_l1":"QDC-PROD","alert_policy_name":"Default server alert policy","criticality":"critical","event_name":"Fullest disk > 70%","alert_description":"Ended alert on pprdihbas307.corp.intuit.net","long_description":"Alert ended: Disk IO > 90%","alert_url":"https://rpm.newrelic.com/accounts/643508/incidents/13378503","server":"oprdoaspf300.corp.intuit.net","tag":"alert.newrelic"}
|
30
|
+
|
31
|
+
Advance configurations. Please add these as needed.
|
32
|
+
<match alert.newrelic.out>
|
33
|
+
type rename_key
|
34
|
+
log_level debug
|
35
|
+
remove_tag_prefix alert.newrelic.out
|
36
|
+
append_tag alert.newrelic
|
37
|
+
deep_rename false
|
38
|
+
rename_rule1 created_at creation_time
|
39
|
+
rename_rule2 severity criticality
|
40
|
+
rename_rule3 message event_name
|
41
|
+
rename_rule4 short_description alert_description
|
42
|
+
rename_rule5 account_name business_unit_l1
|
43
|
+
rename_rule6 id source_event_id
|
44
|
+
rename_rule7 long_description value
|
45
|
+
rename_rule8 newraw raw
|
46
|
+
rename_rule9 alert_url intermediary_source
|
47
|
+
rename_rule10 server source_hostname
|
48
|
+
</match>
|
49
|
+
|
50
|
+
|
51
|
+
#<match alert.newrelic>
|
52
|
+
# type stdout
|
53
|
+
#</match>
|
54
|
+
|
55
|
+
Now startup fluentd
|
56
|
+
|
57
|
+
$ sudo fluentd -c fluent.conf &
|
58
|
+
|
59
|
+
|
60
|
+
# to test ..
|
61
|
+
|
62
|
+
$ cd test; rvmsudo ./newrelic.rb
|
63
|
+
|
64
|
+
## To Do
|
65
|
+
Inclde travis ci checks
|
data/README.md
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
# Fluent::Plugin::NewRelic
|
2
|
+
|
3
|
+
fluent-plugin-newlrelictransform is an input plug-in for [Fluentd](http://fluentd.org)
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
These instructions assume you already have fluentd installed.
|
8
|
+
If you don't, please run through [quick start for fluentd] (https://github.com/fluent/fluentd#quick-start)
|
9
|
+
|
10
|
+
Now after you have fluentd installed you can follow either of the steps below:
|
11
|
+
|
12
|
+
Add this line to your application's Gemfile:
|
13
|
+
|
14
|
+
gem 'fluent-plugin-newlrelictransform'
|
15
|
+
|
16
|
+
Or install it yourself as:
|
17
|
+
|
18
|
+
$ gem install fluent-plugin-newlrelictransform
|
19
|
+
|
20
|
+
## Usage
|
21
|
+
This plugin can be used in conjunction with fluent-plugin-ironio. A typical use case is to use webhooks in newrelic and forward alerts to ironio. This is done when the alert handling infrastructure is behind a firewall and cannot ingest them directly. The messages coming from ironio is then funnelled to this plugin where it breaks up the alerts into individual ones.
|
22
|
+
Add the following into your fluentd config.
|
23
|
+
|
24
|
+
<match alert.newrelic.in>
|
25
|
+
type newrelic
|
26
|
+
log_level debug
|
27
|
+
</match>
|
28
|
+
|
29
|
+
#{"creation_time":"2015-02-11T13:58:08Z","business_unit_l1":"QDC-PROD","alert_policy_name":"Default server alert policy","criticality":"critical","event_name":"Fullest disk > 70%","alert_description":"Ended alert on pprdihbas307.corp.intuit.net","long_description":"Alert ended: Disk IO > 90%","alert_url":"https://rpm.newrelic.com/accounts/643508/incidents/13378503","server":"oprdoaspf300.corp.intuit.net","tag":"alert.newrelic"}
|
30
|
+
|
31
|
+
Advance configurations. Please add these as needed.
|
32
|
+
<match alert.newrelic.out>
|
33
|
+
type rename_key
|
34
|
+
log_level debug
|
35
|
+
remove_tag_prefix alert.newrelic.out
|
36
|
+
append_tag alert.newrelic
|
37
|
+
deep_rename false
|
38
|
+
rename_rule1 created_at creation_time
|
39
|
+
rename_rule2 severity criticality
|
40
|
+
rename_rule3 message event_name
|
41
|
+
rename_rule4 short_description alert_description
|
42
|
+
rename_rule5 account_name business_unit_l1
|
43
|
+
rename_rule6 id source_event_id
|
44
|
+
rename_rule7 long_description value
|
45
|
+
rename_rule8 newraw raw
|
46
|
+
rename_rule9 alert_url intermediary_source
|
47
|
+
rename_rule10 server source_hostname
|
48
|
+
</match>
|
49
|
+
|
50
|
+
|
51
|
+
#<match alert.newrelic>
|
52
|
+
# type stdout
|
53
|
+
#</match>
|
54
|
+
|
55
|
+
Now startup fluentd
|
56
|
+
|
57
|
+
$ sudo fluentd -c fluent.conf &
|
58
|
+
|
59
|
+
|
60
|
+
# to test ..
|
61
|
+
|
62
|
+
$ cd test; rvmsudo ./newrelic.rb
|
63
|
+
|
64
|
+
## To Do
|
65
|
+
Inclde travis ci checks
|
data/Rakefile
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
require 'bundler'
|
3
|
+
Bundler::GemHelper.install_tasks
|
4
|
+
|
5
|
+
require 'rake/testtask'
|
6
|
+
|
7
|
+
Rake::TestTask.new(:test) do |test|
|
8
|
+
test.libs << 'lib' << 'test'
|
9
|
+
test.pattern = 'test/**/test_*.rb'
|
10
|
+
test.verbose = true
|
11
|
+
end
|
12
|
+
|
13
|
+
task :default => [:build]
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.name = "fluent-plugin-newrelictransform"
|
6
|
+
gem.version = "0.0.1"
|
7
|
+
gem.date = '2015-01-30'
|
8
|
+
gem.authors = ["chandrashekar Tippur"]
|
9
|
+
gem.email = ["ctippur@gmail.com"]
|
10
|
+
gem.summary = %q{Fluentd input plugin for Newrelic alerts}
|
11
|
+
gem.description = %q{FLuentd plugin for Newrelic alerts... WIP}
|
12
|
+
gem.homepage = 'https://github.com/ctippur/fluent-plugin-newrelic'
|
13
|
+
gem.license = 'MIT'
|
14
|
+
|
15
|
+
gem.files = `git ls-files`.split($\)
|
16
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
17
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
18
|
+
gem.require_paths = ["lib"]
|
19
|
+
|
20
|
+
gem.add_runtime_dependency 'fluentd', '~> 0.10', '>= 0.10.9'
|
21
|
+
gem.add_development_dependency 'bundler', '~> 1.3'
|
22
|
+
gem.add_development_dependency 'rake', '~> 0.9', '>= 0.9.2'
|
23
|
+
gem.add_development_dependency 'rspec', '~> 2.11', '>= 2.11.0'
|
24
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
module Fluent
|
2
|
+
class NewrelicOutput < Output
|
3
|
+
# First, register the plugin. NAME is the name of this plugin
|
4
|
+
# and identifies the plugin in the configuration file.
|
5
|
+
Fluent::Plugin.register_output('newrelic', self)
|
6
|
+
|
7
|
+
config_param :tag, :string, default:'alert.newrelic.out'
|
8
|
+
|
9
|
+
# This method is called before starting.
|
10
|
+
def configure(conf)
|
11
|
+
super
|
12
|
+
end
|
13
|
+
|
14
|
+
# This method is called when starting.
|
15
|
+
def start
|
16
|
+
super
|
17
|
+
end
|
18
|
+
|
19
|
+
# This method is called when shutting down.
|
20
|
+
def shutdown
|
21
|
+
super
|
22
|
+
end
|
23
|
+
|
24
|
+
# This method is called when an event reaches Fluentd.
|
25
|
+
# 'es' is a Fluent::EventStream object that includes multiple events.
|
26
|
+
# You can use 'es.each {|time,record| ... }' to retrieve events.
|
27
|
+
# 'chain' is an object that manages transactions. Call 'chain.next' at
|
28
|
+
# appropriate points and rollback if it raises an exception.
|
29
|
+
#
|
30
|
+
# NOTE! This method is called by Fluentd's main thread so you should not write slow routine here. It causes Fluentd's performance degression.
|
31
|
+
def emit(tag, es, chain)
|
32
|
+
chain.next
|
33
|
+
es.each {|time,record|
|
34
|
+
$stderr.puts "OK!"
|
35
|
+
if (record.has_key?("server_events"))
|
36
|
+
newhash = Hash.new
|
37
|
+
# If the record value is not a array, then assign the name to value
|
38
|
+
record.each_pair do |singlekey, singlevalue|
|
39
|
+
if (singlevalue.class == String)
|
40
|
+
newhash[singlekey]=singlevalue
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
# Walk thro the array and assign each value
|
45
|
+
record["server_events"].each_with_index do |attr, idx|
|
46
|
+
temphash=Hash.new
|
47
|
+
# Each value within the array is a hash
|
48
|
+
# Iterate thro the hash and assign the values
|
49
|
+
attr.each_pair do |key, value|
|
50
|
+
temphash[key]=value
|
51
|
+
end
|
52
|
+
newhash["raw"]=temphash.clone
|
53
|
+
Fluent::Engine.emit @tag, time.to_i, newhash
|
54
|
+
end
|
55
|
+
else
|
56
|
+
# Emit as is
|
57
|
+
Fluent::Engine.emit @tag, time, record
|
58
|
+
end
|
59
|
+
}
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<source>
|
2
|
+
type newrelic # required, chossing the input plugin.
|
3
|
+
endpoint # Optional.
|
4
|
+
projectId # Needed for Ironio
|
5
|
+
token # Needed for Ironio
|
6
|
+
endpointQueue # Needed for Ironio
|
7
|
+
endpointType # Example ironio, kinesis
|
8
|
+
oauthId # authorization key
|
9
|
+
interval # frequency to pull data
|
10
|
+
readOnly # True or false. This is to control the deletion of message after it is read
|
11
|
+
</source>
|
12
|
+
|
13
|
+
<match alert.newrelic>
|
14
|
+
type stdout
|
15
|
+
</match>
|
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/in_newrelic'
|
26
|
+
|
27
|
+
class Test::Unit::TestCase
|
28
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class SnmpTrapInputTest < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
Fluent::Test.setup
|
6
|
+
end
|
7
|
+
|
8
|
+
CONFIG = %[
|
9
|
+
host 0
|
10
|
+
port 1062
|
11
|
+
tag alert.snmptrap
|
12
|
+
]
|
13
|
+
|
14
|
+
def create_driver(conf=CONFIG)
|
15
|
+
Fluent::Test::InputTestDriver.new(Fluent::SnmpTrapInput).configure(conf)
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_configure
|
19
|
+
d = create_driver('')
|
20
|
+
assert_equal "0".to_i, d.instance.host
|
21
|
+
assert_equal "1062".to_i, d.instance.port
|
22
|
+
assert_equal 'alert.snmptrap', d.instance.tag
|
23
|
+
end
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,129 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fluent-plugin-newrelictransform
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- chandrashekar Tippur
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-01-30 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: fluentd
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.10'
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 0.10.9
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - "~>"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0.10'
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 0.10.9
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: bundler
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '1.3'
|
40
|
+
type: :development
|
41
|
+
prerelease: false
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - "~>"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '1.3'
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: rake
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - "~>"
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0.9'
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: 0.9.2
|
57
|
+
type: :development
|
58
|
+
prerelease: false
|
59
|
+
version_requirements: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - "~>"
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '0.9'
|
64
|
+
- - ">="
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: 0.9.2
|
67
|
+
- !ruby/object:Gem::Dependency
|
68
|
+
name: rspec
|
69
|
+
requirement: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - "~>"
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '2.11'
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: 2.11.0
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - "~>"
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '2.11'
|
84
|
+
- - ">="
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: 2.11.0
|
87
|
+
description: FLuentd plugin for Newrelic alerts... WIP
|
88
|
+
email:
|
89
|
+
- ctippur@gmail.com
|
90
|
+
executables: []
|
91
|
+
extensions: []
|
92
|
+
extra_rdoc_files: []
|
93
|
+
files:
|
94
|
+
- Gemfile
|
95
|
+
- README
|
96
|
+
- README.md
|
97
|
+
- Rakefile
|
98
|
+
- fluent-plugin-newrelic.gemspec
|
99
|
+
- lib/fluent/plugin/out_newrelic.rb
|
100
|
+
- sample/snmp.conf.sample
|
101
|
+
- test/helper.rb
|
102
|
+
- test/plugin/test_in_newrelic.rb
|
103
|
+
homepage: https://github.com/ctippur/fluent-plugin-newrelic
|
104
|
+
licenses:
|
105
|
+
- MIT
|
106
|
+
metadata: {}
|
107
|
+
post_install_message:
|
108
|
+
rdoc_options: []
|
109
|
+
require_paths:
|
110
|
+
- lib
|
111
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
112
|
+
requirements:
|
113
|
+
- - ">="
|
114
|
+
- !ruby/object:Gem::Version
|
115
|
+
version: '0'
|
116
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
117
|
+
requirements:
|
118
|
+
- - ">="
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: '0'
|
121
|
+
requirements: []
|
122
|
+
rubyforge_project:
|
123
|
+
rubygems_version: 2.2.2
|
124
|
+
signing_key:
|
125
|
+
specification_version: 4
|
126
|
+
summary: Fluentd input plugin for Newrelic alerts
|
127
|
+
test_files:
|
128
|
+
- test/helper.rb
|
129
|
+
- test/plugin/test_in_newrelic.rb
|