logstash-output-rollbar 0.1.2 → 0.2.0

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: 5ceb5758f3895bbe8f60148fd3ea4e44f39a6a95
4
- data.tar.gz: 315224277928bc3828087517bebbf28be8b19034
3
+ metadata.gz: 3757f2d43517c7d7fb5e81598503772a9165014c
4
+ data.tar.gz: 9602ce3c72e15a182989ac438d3dd88cf0ce3d01
5
5
  SHA512:
6
- metadata.gz: a1d34114545efaa27eb2562a7ac0037e97d23355234dcb9ee23c9d9c72aa86df76baefad58e3ce4178305089184b00695d8f44116591e3cedb6ecc210b26b609
7
- data.tar.gz: 8f2b33edeb86aa71cf3017722dc03a93055fcd7e82737da23b04fb2c3f4a152a3f48dbac59b396272a9971f74bb84315f33b4deb2cf7233e4092337718078847
6
+ metadata.gz: ecbe5a8b28b9eb148508cdf8ee8f4388e7d01c090cae8eb66a2c679669f70089991ecf5b9eb9043186f16ec2d09b2506cfda5f94312cd4ccb916e70ec6f3dd20
7
+ data.tar.gz: 57bcee646d6d1cc86e12b957e536c7192cebe1eb35d87bd89a0c1bada983f21eee0e72769adae8fbaf6834d3fdcb52405b19a5184a65e843fc8bc8683332e16e
@@ -9,19 +9,25 @@ require "json"
9
9
  # applications, you can use the same token.
10
10
  class LogStash::Outputs::Rollbar < LogStash::Outputs::Base
11
11
  config_name "rollbar"
12
- milestone 1
13
12
 
14
- # Your Rollbar access token
13
+ # Each of these config values can be specified in the plugin configuration section, in which
14
+ # case they'll apply to all events, or you can override them on an event by event basis.
15
+ #
16
+ # Your default Rollbar access token. You can override this for a specific event by adding
17
+ # a "[rollbar][access_token]" field to that event
15
18
  config :access_token, :validate => :password, :required => true
16
19
 
17
- # The Rollbar environment
20
+ # The default Rollbar environment. You can override this for a specific event by adding
21
+ # a "[rollbar][environment]" field to that event
18
22
  config :environment, :validate => :string, :default => 'production'
19
23
 
20
- # The Rollbar event level (info, warning, error)
24
+ # The default level for Rollbar events (info, warning, error) You can override this for a specific
25
+ # event by adding a "[rollbar][level]" field to that event
21
26
  config :level, :validate => ['debug', 'info', 'warning', 'error', 'critical'] , :default => 'info'
22
27
 
23
- # Format for the Rollbar "message" or item title. In most cases you'll want to override this
24
- # and build up a message with specific fields from the event.
28
+ # The default format for the Rollbar "message" or item title. In most cases you'll want to override
29
+ # this and build up a message with specific fields from the event. You can override this for a specific
30
+ # event by adding a "[rollbar][format]" field to that event.
25
31
  config :format, :validate => :string, :default => "%{message}"
26
32
 
27
33
  # Rollbar API URL endpoint. You shouldn't need to change this.
@@ -50,7 +56,6 @@ class LogStash::Outputs::Rollbar < LogStash::Outputs::Base
50
56
  return unless output?(event)
51
57
 
52
58
  rb_item = hash_recursive
53
- rb_item['access_token'] = @access_token.value
54
59
 
55
60
  # We'll want to remove fields from data without removing them from the original event
56
61
  data = JSON.parse(event.to_json)
@@ -59,7 +64,9 @@ class LogStash::Outputs::Rollbar < LogStash::Outputs::Base
59
64
  # If logstash has created 'rollbar' fields, we'll use those to populate the item...
60
65
  #
61
66
  if data['rollbar']
62
- merge_keys = %w{platform language framework context request person server client fingerprint title uuid}
67
+
68
+ merge_keys = %w{access_token client context environment fingerprint format framework
69
+ language level person platform request server title uuid }
63
70
  merge_keys.each do |key|
64
71
  data['rollbar'][key] && rb_item['data'][key] = data['rollbar'][key]
65
72
  end
@@ -67,16 +74,35 @@ class LogStash::Outputs::Rollbar < LogStash::Outputs::Base
67
74
  end
68
75
 
69
76
  # ...then put whatever's left in 'custom'...
70
- rb_item['data']['body']['custom'] = data
77
+ rb_item['data']['custom'] = data
71
78
 
72
- # ...and finally override the top level fields that have a specific meaning
79
+ # ...and finally override the fields that have a specific meaning
73
80
  rb_item['data']['timestamp'] = event.timestamp.to_i
74
- rb_item['data']['level'] = @level
75
- rb_item['data']['environment'] = @environment
76
- rb_item['data']['body']['message']['body'] = event.sprintf(@format)
81
+ rb_item['data']['level'] = @level unless rb_item['data'].has_key?('level')
82
+ rb_item['data']['environment'] = @environment unless rb_item['data'].has_key?('environment')
77
83
 
78
84
  rb_item['data']['notifier']['name'] = 'logstash'
79
- rb_item['data']['notifier']['version'] = '0.1.0'
85
+ rb_item['data']['notifier']['version'] = Gem.loaded_specs["logstash-output-rollbar"].version
86
+
87
+ # Construct the message body using either:
88
+ #
89
+ # - The default format string defined above "%{message}"
90
+ # - The format string specified in the rollbar plugin config section
91
+ # - The format string specified in the [rollbar][format] event field
92
+ #
93
+ format = rb_item['data'].has_key?('format') ? rb_item['data']['format'] : @format
94
+ rb_item['data']['body']['message']['body'] = event.sprintf(format)
95
+
96
+ # Treat the [rollbar][access_token] field as a special case, since we don't need to
97
+ # include it more than once in the Rollbar item
98
+ #
99
+ if rb_item['data'].has_key?('access_token')
100
+ rb_item['access_token'] = rb_item['data']['access_token']
101
+ rb_item['data'].delete('access_token')
102
+ else
103
+ rb_item['access_token'] = @access_token.value
104
+ end
105
+
80
106
 
81
107
  @logger.debug("Rollbar Item", :rb_item => rb_item)
82
108
 
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
 
3
3
  s.name = 'logstash-output-rollbar'
4
- s.version = '0.1.2'
4
+ s.version = '0.2.0'
5
5
  s.licenses = ['Apache License (2.0)']
6
6
  s.summary = "The Rollbar Logstash output sends events to the Rollbar error monitoring service."
7
7
  s.description = "This gem is a logstash plugin. Install using: $LS_HOME/bin/plugin install gemname. This gem is not a stand-alone program"
metadata CHANGED
@@ -1,47 +1,47 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-output-rollbar
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rollbar
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-13 00:00:00.000000000 Z
11
+ date: 2015-09-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
+ name: logstash-core
14
15
  requirement: !ruby/object:Gem::Requirement
15
16
  requirements:
16
- - - '>='
17
+ - - ">="
17
18
  - !ruby/object:Gem::Version
18
19
  version: 1.4.0
19
- - - <
20
+ - - "<"
20
21
  - !ruby/object:Gem::Version
21
22
  version: 2.0.0
22
- name: logstash-core
23
- prerelease: false
24
23
  type: :runtime
24
+ prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
- - - '>='
27
+ - - ">="
28
28
  - !ruby/object:Gem::Version
29
29
  version: 1.4.0
30
- - - <
30
+ - - "<"
31
31
  - !ruby/object:Gem::Version
32
32
  version: 2.0.0
33
33
  - !ruby/object:Gem::Dependency
34
+ name: logstash-devutils
34
35
  requirement: !ruby/object:Gem::Requirement
35
36
  requirements:
36
- - - '>='
37
+ - - ">="
37
38
  - !ruby/object:Gem::Version
38
39
  version: '0'
39
- name: logstash-devutils
40
- prerelease: false
41
40
  type: :development
41
+ prerelease: false
42
42
  version_requirements: !ruby/object:Gem::Requirement
43
43
  requirements:
44
- - - '>='
44
+ - - ">="
45
45
  - !ruby/object:Gem::Version
46
46
  version: '0'
47
47
  description: 'This gem is a logstash plugin. Install using: $LS_HOME/bin/plugin install
@@ -51,7 +51,7 @@ executables: []
51
51
  extensions: []
52
52
  extra_rdoc_files: []
53
53
  files:
54
- - .gitignore
54
+ - ".gitignore"
55
55
  - CONTRIBUTORS
56
56
  - Gemfile
57
57
  - LICENSE
@@ -66,25 +66,26 @@ licenses:
66
66
  metadata:
67
67
  logstash_plugin: 'true'
68
68
  logstash_group: output
69
- post_install_message:
69
+ post_install_message:
70
70
  rdoc_options: []
71
71
  require_paths:
72
72
  - lib
73
73
  required_ruby_version: !ruby/object:Gem::Requirement
74
74
  requirements:
75
- - - '>='
75
+ - - ">="
76
76
  - !ruby/object:Gem::Version
77
77
  version: '0'
78
78
  required_rubygems_version: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - '>='
80
+ - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  requirements: []
84
- rubyforge_project:
85
- rubygems_version: 2.4.5
86
- signing_key:
84
+ rubyforge_project:
85
+ rubygems_version: 2.4.8
86
+ signing_key:
87
87
  specification_version: 4
88
- summary: The Rollbar Logstash output sends events to the Rollbar error monitoring service.
88
+ summary: The Rollbar Logstash output sends events to the Rollbar error monitoring
89
+ service.
89
90
  test_files:
90
91
  - spec/outputs/rollbar_spec.rb