fluent-plugin-spectrum 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b6ce4a6b4bf074348bde00e83c87e8559e07549c
4
- data.tar.gz: cf2079f18bffc80dee8fe1c547d26460ff2a862e
3
+ metadata.gz: 0c949d2e99ee26e2c94f69cc95f51691bfcb6c06
4
+ data.tar.gz: a0a20f56156aebccbbb21da927b1d7e145622d60
5
5
  SHA512:
6
- metadata.gz: dde69f607871058aa60138bd5a177323a0e0fac45ff6b62c0f13ef74699a5b948974161759b1417609abf02f0e01fc16bb26c5da60971da4dcbc85e6909c83dd
7
- data.tar.gz: 656594019157e6a2555673e9d61094d89a420533c7fca7b1c0d6b909d5e669701edd895618c0b75e47af5c2c5438504dcab801101bbb0486dde1d14578aab052
6
+ metadata.gz: 00b234557427b77bc8ed240f432f74ebb6114cb844af5740eca0215d308ee38e16bde66cdf5147081323794a596ee29cb39cd6515b962849b1f34afc9e9b45cd
7
+ data.tar.gz: 51d6ba395c211abea598b69cabb28178c91b03d2238c631b1909597fd5a6d8f102db1d8a0bca665450c77da34dc38a383a63503637496b17e52ced3327dc652c
data/.travis.yml CHANGED
@@ -1,8 +1,9 @@
1
1
  language: ruby
2
2
  rvm:
3
+ - 1.9.3
3
4
  - 2.0.0
4
- - 2.0.0-p451
5
5
  - 2.1.0
6
+ - 2.2.1
6
7
 
7
8
  gemfile:
8
9
  - Gemfile
data/Gemfile CHANGED
@@ -1,4 +1,3 @@
1
1
  source 'https://rubygems.org'
2
-
3
2
  # Specify your gem's dependencies in fluent-plugin-spectrum.gemspec
4
3
  gemspec
data/README.md CHANGED
@@ -3,9 +3,11 @@
3
3
  fluent-plugin-spectrum is an input plug-in for [Fluentd](http://fluentd.org)
4
4
 
5
5
  ## Status
6
- [![Gem Version](https://badge.fury.io/rb/fluent-plugin-spectrum.png)](http://badge.fury.io/rb/fluent-plugin-spectrum)
7
6
  [![Build Status](https://travis-ci.org/Bigel0w/fluent-plugin-spectrum.png?branch=master)](https://travis-ci.org/Bigel0w/fluent-plugin-spectrum)
8
7
  [![Coverage Status](https://coveralls.io/repos/Bigel0w/fluent-plugin-spectrum/badge.png?branch=master)](https://coveralls.io/r/Bigel0w/fluent-plugin-spectrum?branch=master)
8
+ [![Dependency Status](https://gemnasium.com/Bigel0w/fluent-plugin-spectrum.svg)](https://gemnasium.com/Bigel0w/fluent-plugin-spectrum)
9
+ [![Code Climate](https://codeclimate.com/github/Bigel0w/fluent-plugin-spectrum/badges/gpa.svg)](https://codeclimate.com/github/Bigel0w/fluent-plugin-spectrum)
10
+ [![Gem Version](https://badge.fury.io/rb/fluent-plugin-spectrum.png)](http://badge.fury.io/rb/fluent-plugin-spectrum)
9
11
 
10
12
  ## Installation
11
13
 
@@ -94,8 +96,6 @@ Verify:
94
96
  2015-03-05 15:04:00 -0800 alert.spectrum: {"event_type":"alert.spectrum","intermediary_source":"spectrumapi001.corp.yourdomain.net","ALARM_ID":"54f8e0e0-e706-12c2-0165-005056a07ac5","CREATION_DATE":"1425596640","SEVERITY":"3","ALARM_TITLE":"LOGMATCH TRAPSEND CRIT","HOSTNAME":"yourhost001.corp.yourdomain.net","IP_ADDRESS":"10.10.0.14","ORIGINATING_EVENT_ATTR":"A SEC logmatch trapsend CRIT Your Alert Message here","MODEL_STRING":"Host_Device","ACKNOWLEDGED":"false","ALARM_STATUS":"","OCCURRENCES":"1","TROUBLE_SHOOTER":"","USER_CLEARABLE":"true","TROUBLE_TICKET_ID":"","PERSISTENT":"true","GC_NAME":"Your_Global_Collection"}
95
97
 
96
98
  ## To Do
97
- * Add retry login. On timeout/failure retry, how often, increasing delay? (how would that affect polling time, possible duplicates?)
98
99
  * All flag to allow specifying spectrum attributes to get or get _ALL_
99
100
  * Add flag to allow start date/time if users want to backfill data from a specific date. then start loop.
100
- * Add flag to disable loop, if users only wanted to backfill from datetime to now or specific end time.
101
- * Change loop to allow multiple runs to stack on eachother to avoid missing data?
101
+ * Add flag to disable loop, if users only wanted to backfill from datetime to now or specific end time.
data/Rakefile CHANGED
@@ -1,5 +1,5 @@
1
- #!/usr/bin/env rake
2
1
  require 'bundler'
2
+ require "bundler/gem_tasks"
3
3
  Bundler::GemHelper.install_tasks
4
4
 
5
5
  require 'rake/testtask'
@@ -10,4 +10,4 @@ Rake::TestTask.new(:test) do |test|
10
10
  test.verbose = true
11
11
  end
12
12
 
13
- task :default => [:build]
13
+ task :default => [:test]
@@ -3,12 +3,12 @@ $:.push File.expand_path("../lib", __FILE__)
3
3
 
4
4
  Gem::Specification.new do |gem|
5
5
  gem.name = "fluent-plugin-spectrum"
6
- gem.version = "0.0.5"
7
- gem.date = '2015-03-31'
6
+ gem.version = "0.0.6"
7
+ gem.date = '2015-04-04'
8
8
  gem.authors = ["Alex Pena"]
9
9
  gem.email = ["pena.alex@gmail.com"]
10
- gem.summary = %q{Fluentd input plugin for pulling alerts from CA Spectrum}
11
- gem.description = %q{Fluentd plugin for pulling monitoring alerts from CA Spectrum}
10
+ gem.summary = %q{Fluentd plugin for managing monitoring alerts from CA Spectrum}
11
+ gem.description = %q{Fluentd input/output plugin for managing monitoring alerts from CA Spectrum. Input supports polling CA Spectrum APIs. Output currently only supports updating events retrieved from Spectrum.}
12
12
  gem.homepage = 'https://github.com/Bigel0w/fluent-plugin-spectrum'
13
13
  gem.license = 'MIT'
14
14
 
@@ -16,10 +16,12 @@ Gem::Specification.new do |gem|
16
16
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
17
17
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
18
18
  gem.require_paths = ["lib"]
19
-
20
- gem.add_development_dependency "rake", '~> 0.9', '>= 0.9.6'
21
-
22
- gem.add_runtime_dependency "fluentd", '~> 0.10', '>= 0.10.52'
23
- gem.add_runtime_dependency "json", '~> 1.1', '>= 1.8.2'
24
- gem.add_runtime_dependency "rest-client", '~> 1.7', '>= 1.7.3'
19
+ # dev deps
20
+ gem.add_development_dependency "rake", '~> 10.0'
21
+ gem.add_development_dependency "bundler", '~> 1.6'
22
+ gem.add_development_dependency "test-unit", '~> 3.0'
23
+ # runtime deps
24
+ gem.add_runtime_dependency "fluentd", '~> 0.12'
25
+ gem.add_runtime_dependency "json", '~> 1.8'
26
+ gem.add_runtime_dependency "rest-client", '~> 1.8'
25
27
  end
@@ -1,16 +1,19 @@
1
1
  module Fluent
2
2
  class SpectrumInput < Input
3
3
  Fluent::Plugin.register_input('spectrum', self)
4
- config_param :tag, :string, :default => "alert.spectrum"
5
- config_param :endpoint, :string, :default => nil
6
- config_param :username, :string, :default => nil
7
- config_param :password, :string, :default => nil
8
- config_param :interval, :integer, :default => 300 # shoud stay above 10, avg response is 5-7 seconds
9
-
10
- config_param :state_file, :string, :default => nil
11
- config_param :include_raw, :string, :default => "false"
12
- config_param :attributes, :string, :default => "ALL"
13
- config_param :select_limit, :time, :default => 10000
4
+
5
+ # Configurations
6
+ INTERVAL_MIN = 10 # shoud stay above 10, avg response is 5-7 seconds
7
+ config_param :tag, :string, :default => "alert.spectrum"
8
+ config_param :endpoint, :string, :default => nil
9
+ config_param :username, :string, :default => nil
10
+ config_param :password, :string, :default => nil
11
+ config_param :state_file, :string, :default => nil
12
+ config_param :attributes, :string, :default => "ALL"
13
+ config_param :interval, :integer, :default => INTERVAL_MIN
14
+ config_param :select_limit, :integer, :default => 10000
15
+ config_param :include_raw, :bool, :default => "false"
16
+ config_param :debug_mode, :bool, :default => false
14
17
 
15
18
  # Classes
16
19
  class TimerWatcher < Coolio::TimerWatcher
@@ -90,10 +93,22 @@ module Fluent
90
93
  def configure(conf)
91
94
  super
92
95
  @conf = conf
93
-
96
+ # Only check configs if debug is off
97
+ unless @debug_mode
98
+ # Verify configs
99
+ # Stop if required fields are not set
100
+ unless @endpoint && @username && @password
101
+ raise ConfigError, "Spectrum :: ConfigError 'endpoint' and 'username' and 'password' must be all specified."
102
+ end
103
+ # Enforce min interval
104
+ if @interval.to_i < INTERVAL_MIN
105
+ raise ConfigError, "Spectrum :: ConfigError 'interval' must be #{INTERVAL_MIN} or over."
106
+ end
107
+ end
108
+ # Warn about optional state file
94
109
  unless @state_file
95
- $log.warn "'state_file PATH' parameter is not set to a valid source."
96
- $log.warn "this parameter is highly recommended to save the last known good timestamp to resume event consuming"
110
+ $log.warn "Spectrum :: 'state_file PATH' parameter is not set to a valid source."
111
+ $log.warn "Spectrum :: this parameter is highly recommended to save the last known good timestamp to resume event consuming"
97
112
  end
98
113
  # map of Spectrum attribute codes to names
99
114
  @spectrum_access_code={
@@ -144,13 +159,11 @@ module Fluent
144
159
  @spectrum_access_code.each do |key, array|
145
160
  @attr_of_interest += " <rs:requested-attribute id=\"#{key}\"/>"
146
161
  end
147
-
148
- # Setup URL Resource
162
+ # URL Resource
149
163
  def resource
150
164
  @url = 'http://' + @endpoint.to_s + '/spectrum/restful/alarms'
151
- RestClient::Resource.new(@url, :user => @username, :password => @password, :open_timeout => 3, :timeout => (@interval * 2))
165
+ RestClient::Resource.new(@url, :user => @username, :password => @password, :open_timeout => 5, :timeout => (@interval * 3))
152
166
  end
153
-
154
167
  ### need to add this but first figure out how to pass a one time override for timeout since get takes a longtime to return
155
168
  #test = resource.get
156
169
  #if test.code.to_s == 200
@@ -187,15 +200,20 @@ module Fluent
187
200
  pollingStart = Engine.now.to_i
188
201
  if @state_store.last_records.has_key?("spectrum")
189
202
  alertStartTime = @state_store.last_records['spectrum']
190
- #$log.info "Spectrum :: Got time record from state_store - #{alertStartTime}"
203
+ if @debug_mode
204
+ $log.info "Spectrum :: Got time record from state_store - #{alertStartTime}"
205
+ end
191
206
  else
192
207
  alertStartTime = (pollingStart.to_i - @interval.to_i)
193
- #$log.info "Spectrum :: Got time record from initial config - #{alertStartTime}"
208
+ if @debug_mode
209
+ $log.info "Spectrum :: Got time record from initial config - #{alertStartTime}"
210
+ end
194
211
  end
195
212
  pollingEnd = ''
196
213
  pollingDuration = ''
197
- #$log.info "Spectrum :: Polling alerts for time period < #{alertStartTime.to_i}"
198
-
214
+ if @debug_mode
215
+ $log.info "Spectrum :: Polling alerts for time period < #{alertStartTime.to_i}"
216
+ end
199
217
  # Format XML for spectrum post
200
218
  @xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
201
219
  <rs:alarm-request throttlesize=\"#{select_limit}\"
@@ -219,7 +237,9 @@ module Fluent
219
237
  # Post to Spectrum and parse results
220
238
  begin
221
239
  res=resource.post @xml,:content_type => 'application/xml',:accept => 'application/json'
222
- #$log.info "Response code #{res.code.to_s}"
240
+ if @debug_mode
241
+ $log.info "Spectrum :: Response code #{res.code.to_s}"
242
+ end
223
243
  body = JSON.parse(res.body)
224
244
  pollingEnd = Engine.now.to_i
225
245
  @state_store.last_records['spectrum'] = pollingEnd
@@ -236,7 +256,7 @@ module Fluent
236
256
  raw_array = Array.new # temp hash to hold attributes of alarm for raw
237
257
  record_hash['event_type'] = @tag.to_s
238
258
  record_hash['intermediary_source'] = @endpoint.to_s
239
- record_hash['recieved_time_input'] = pollingEnd.to_s
259
+ record_hash['receive_time_input'] = pollingEnd.to_s
240
260
  # iterate though alarm attributes
241
261
  alarm['ns1.attribute'].each do |attribute|
242
262
  key,value = parseAttributes(attribute)
@@ -259,7 +279,7 @@ module Fluent
259
279
  raw_array = Array.new # temp hash to hold attributes of alarm for raw
260
280
  record_hash['event_type'] = @tag.to_s
261
281
  record_hash['intermediary_source'] = @endpoint.to_s
262
- record_hash['recieved_time_input'] = pollingEnd.to_s
282
+ record_hash['receive_time_input'] = pollingEnd.to_s
263
283
  # iterate though alarm attributes and add to temp hash
264
284
  body['ns1.alarm-response-list']['ns1.alarm-responses']['ns1.alarm']['ns1.attribute'].each do |attribute|
265
285
  key,value = parseAttributes(attribute)
data/test/helper.rb CHANGED
@@ -1,5 +1,7 @@
1
- require 'rubygems'
2
1
  require 'bundler'
2
+ require 'test/unit'
3
+ require 'fluent/test'
4
+
3
5
  begin
4
6
  Bundler.setup(:default, :development)
5
7
  rescue Bundler::BundlerError => e
@@ -7,11 +9,10 @@ rescue Bundler::BundlerError => e
7
9
  $stderr.puts "Run `bundle install` to install missing gems"
8
10
  exit e.status_code
9
11
  end
10
- require 'test/unit'
11
12
 
12
13
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
13
14
  $LOAD_PATH.unshift(File.dirname(__FILE__))
14
- require 'fluent/test'
15
+
15
16
  unless ENV.has_key?('VERBOSE')
16
17
  nulllogger = Object.new
17
18
  nulllogger.instance_eval {|obj|
@@ -1,24 +1,33 @@
1
1
  require 'helper'
2
2
 
3
3
  class SpectrumInputTest < Test::Unit::TestCase
4
+
4
5
  def setup
5
6
  Fluent::Test.setup
6
7
  end
7
8
 
8
9
  CONFIG = %[
10
+ username test_username
11
+ password test_password
12
+ endpoint test.endpoint.com
9
13
  ]
10
14
 
11
- def create_driver(conf=CONFIG)
15
+ def create_driver(conf = CONFIG)
12
16
  Fluent::Test::InputTestDriver.new(Fluent::SpectrumInput).configure(conf)
13
17
  end
14
18
 
15
19
  def test_configure
16
- d = create_driver('')
17
- #assert_equal "pleasechangeme.com", d.instance.endpoint
18
- #assert_equal "username", d.instance.user
19
- #assert_equal "password", d.instance.pass
20
- assert_equal "300".to_i, d.instance.interval
20
+ assert_nothing_raised { create_driver }
21
+ end
22
+
23
+ def test_params
24
+ d = create_driver
25
+ assert_equal "test.endpoint.com", d.instance.endpoint
26
+ assert_equal "test_username", d.instance.username
27
+ assert_equal "test_password", d.instance.password
28
+ assert_equal "10".to_i, d.instance.interval
21
29
  assert_equal "false", d.instance.include_raw
22
30
  assert_equal 'alert.spectrum', d.instance.tag
23
31
  end
32
+
24
33
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-spectrum
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Pena
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-31 00:00:00.000000000 Z
11
+ date: 2015-04-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -16,81 +16,87 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0.9'
20
- - - ">="
19
+ version: '10.0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
21
25
  - !ruby/object:Gem::Version
22
- version: 0.9.6
26
+ version: '10.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.6'
23
34
  type: :development
24
35
  prerelease: false
25
36
  version_requirements: !ruby/object:Gem::Requirement
26
37
  requirements:
27
38
  - - "~>"
28
39
  - !ruby/object:Gem::Version
29
- version: '0.9'
30
- - - ">="
40
+ version: '1.6'
41
+ - !ruby/object:Gem::Dependency
42
+ name: test-unit
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
31
53
  - !ruby/object:Gem::Version
32
- version: 0.9.6
54
+ version: '3.0'
33
55
  - !ruby/object:Gem::Dependency
34
56
  name: fluentd
35
57
  requirement: !ruby/object:Gem::Requirement
36
58
  requirements:
37
59
  - - "~>"
38
60
  - !ruby/object:Gem::Version
39
- version: '0.10'
40
- - - ">="
41
- - !ruby/object:Gem::Version
42
- version: 0.10.52
61
+ version: '0.12'
43
62
  type: :runtime
44
63
  prerelease: false
45
64
  version_requirements: !ruby/object:Gem::Requirement
46
65
  requirements:
47
66
  - - "~>"
48
67
  - !ruby/object:Gem::Version
49
- version: '0.10'
50
- - - ">="
51
- - !ruby/object:Gem::Version
52
- version: 0.10.52
68
+ version: '0.12'
53
69
  - !ruby/object:Gem::Dependency
54
70
  name: json
55
71
  requirement: !ruby/object:Gem::Requirement
56
72
  requirements:
57
73
  - - "~>"
58
74
  - !ruby/object:Gem::Version
59
- version: '1.1'
60
- - - ">="
61
- - !ruby/object:Gem::Version
62
- version: 1.8.2
75
+ version: '1.8'
63
76
  type: :runtime
64
77
  prerelease: false
65
78
  version_requirements: !ruby/object:Gem::Requirement
66
79
  requirements:
67
80
  - - "~>"
68
81
  - !ruby/object:Gem::Version
69
- version: '1.1'
70
- - - ">="
71
- - !ruby/object:Gem::Version
72
- version: 1.8.2
82
+ version: '1.8'
73
83
  - !ruby/object:Gem::Dependency
74
84
  name: rest-client
75
85
  requirement: !ruby/object:Gem::Requirement
76
86
  requirements:
77
87
  - - "~>"
78
88
  - !ruby/object:Gem::Version
79
- version: '1.7'
80
- - - ">="
81
- - !ruby/object:Gem::Version
82
- version: 1.7.3
89
+ version: '1.8'
83
90
  type: :runtime
84
91
  prerelease: false
85
92
  version_requirements: !ruby/object:Gem::Requirement
86
93
  requirements:
87
94
  - - "~>"
88
95
  - !ruby/object:Gem::Version
89
- version: '1.7'
90
- - - ">="
91
- - !ruby/object:Gem::Version
92
- version: 1.7.3
93
- description: Fluentd plugin for pulling monitoring alerts from CA Spectrum
96
+ version: '1.8'
97
+ description: Fluentd input/output plugin for managing monitoring alerts from CA Spectrum.
98
+ Input supports polling CA Spectrum APIs. Output currently only supports updating
99
+ events retrieved from Spectrum.
94
100
  email:
95
101
  - pena.alex@gmail.com
96
102
  executables: []
@@ -132,7 +138,7 @@ rubyforge_project:
132
138
  rubygems_version: 2.4.5
133
139
  signing_key:
134
140
  specification_version: 4
135
- summary: Fluentd input plugin for pulling alerts from CA Spectrum
141
+ summary: Fluentd plugin for managing monitoring alerts from CA Spectrum
136
142
  test_files:
137
143
  - test/helper.rb
138
144
  - test/plugin/test_in_spectrum.rb