fluent-plugin-rollbar 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +50 -0
- data/LICENSE +21 -0
- data/README.md +18 -0
- data/VERSION +1 -0
- data/fluent-plugin-rollbar.gemspec +22 -0
- data/lib/fluent/plugin/out_rollbar.rb +89 -0
- metadata +104 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 489bba670ed94c387ccf36244839059fec2dc306
|
4
|
+
data.tar.gz: 9934efae47e9cb4a67689e9a12d187a36ded6577
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f2814f2a5930d7def1312ac31306fa196b980c2be0ed50c401052b919d7324b1623eedfc4b8b926a4de04c7fd738d32b4e85ca3c5313977715052dce0a3503c2
|
7
|
+
data.tar.gz: 052c0e4739acdd0500d319b427936ba8b50fb9e9fba3a5c78de033f18e0450dccde6d9a9e54691298d61e474328b49f19dffc8bbabcaa57330ca9c457eadf568
|
data/.gitignore
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
/.config
|
4
|
+
/coverage/
|
5
|
+
/InstalledFiles
|
6
|
+
/pkg/
|
7
|
+
/spec/reports/
|
8
|
+
/spec/examples.txt
|
9
|
+
/test/tmp/
|
10
|
+
/test/version_tmp/
|
11
|
+
/tmp/
|
12
|
+
|
13
|
+
# Used by dotenv library to load environment variables.
|
14
|
+
# .env
|
15
|
+
|
16
|
+
## Specific to RubyMotion:
|
17
|
+
.dat*
|
18
|
+
.repl_history
|
19
|
+
build/
|
20
|
+
*.bridgesupport
|
21
|
+
build-iPhoneOS/
|
22
|
+
build-iPhoneSimulator/
|
23
|
+
|
24
|
+
## Specific to RubyMotion (use of CocoaPods):
|
25
|
+
#
|
26
|
+
# We recommend against adding the Pods directory to your .gitignore. However
|
27
|
+
# you should judge for yourself, the pros and cons are mentioned at:
|
28
|
+
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
|
29
|
+
#
|
30
|
+
# vendor/Pods/
|
31
|
+
|
32
|
+
## Documentation cache and generated files:
|
33
|
+
/.yardoc/
|
34
|
+
/_yardoc/
|
35
|
+
/doc/
|
36
|
+
/rdoc/
|
37
|
+
|
38
|
+
## Environment normalization:
|
39
|
+
/.bundle/
|
40
|
+
/vendor/bundle
|
41
|
+
/lib/bundler/man/
|
42
|
+
|
43
|
+
# for a library or gem, you might want to ignore these files since the code is
|
44
|
+
# intended to run in multiple environments; otherwise, check them in:
|
45
|
+
# Gemfile.lock
|
46
|
+
# .ruby-version
|
47
|
+
# .ruby-gemset
|
48
|
+
|
49
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
50
|
+
.rvmrc
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2017 Volker Machon
|
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 all
|
13
|
+
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 THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
# fluent-plugin-rollbar
|
2
|
+
Fluentd Plugin to forward rollbar payloads to https://rollbar.com/
|
3
|
+
|
4
|
+
## Configuration
|
5
|
+
|
6
|
+
Adding the following source block will enable the datadog out plugin for FluentD
|
7
|
+
|
8
|
+
<match rollbar.***>
|
9
|
+
@type rollbar
|
10
|
+
access_token <your-access-token-from-rollbar.com>
|
11
|
+
</match>
|
12
|
+
|
13
|
+
|
14
|
+
## Options
|
15
|
+
| Key | Default | Required |
|
16
|
+
|:-------------- |:---------------: |:---------:|
|
17
|
+
| `access_token` | --- | yes |
|
18
|
+
| `endpoint` | `https://api.rollbar.com/api/1/item/` | yes |
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
1.0.1
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
$LOAD_PATH.push File.expand_path('../lib', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.name = 'fluent-plugin-rollbar'
|
6
|
+
gem.description = 'Rollbar Out Plugin for Fluentd'
|
7
|
+
gem.homepage = 'https://github.com/olafnorge/fluent-plugin-rollbar'
|
8
|
+
gem.summary = gem.description
|
9
|
+
gem.version = File.read('VERSION').strip
|
10
|
+
gem.authors = ['Volker Machon']
|
11
|
+
gem.email = 'volker@machon.biz'
|
12
|
+
gem.has_rdoc = false
|
13
|
+
gem.files = `git ls-files`.split("\n")
|
14
|
+
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
15
|
+
gem.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
16
|
+
gem.require_paths = ['lib']
|
17
|
+
|
18
|
+
gem.add_dependency 'fluentd'
|
19
|
+
gem.add_dependency 'eventmachine'
|
20
|
+
gem.add_dependency 'json'
|
21
|
+
gem.add_dependency 'em-http-request'
|
22
|
+
end
|
@@ -0,0 +1,89 @@
|
|
1
|
+
require 'eventmachine'
|
2
|
+
require 'em-http-request'
|
3
|
+
require 'fluent/output'
|
4
|
+
require 'json'
|
5
|
+
|
6
|
+
module Fluent
|
7
|
+
class RollbarOutput < BufferedOutput
|
8
|
+
# First, register the plugin. NAME is the name of this plugin
|
9
|
+
# and identifies the plugin in the configuration file.
|
10
|
+
Fluent::Plugin.register_output('rollbar', self)
|
11
|
+
|
12
|
+
# config_param defines a parameter. You can refer a parameter via @path instance variable
|
13
|
+
# Without :default, a parameter is required.
|
14
|
+
config_param :access_token, :string
|
15
|
+
config_param :endpoint, :string, default: 'https://api.rollbar.com/api/1/item/'
|
16
|
+
|
17
|
+
# This method is called before starting.
|
18
|
+
# 'conf' is a Hash that includes configuration parameters.
|
19
|
+
# If the configuration is invalid, raise Fluent::ConfigError.
|
20
|
+
def configure(conf)
|
21
|
+
super
|
22
|
+
$log.info 'Rollbar Output initializing'
|
23
|
+
end
|
24
|
+
|
25
|
+
# This method is called when starting.
|
26
|
+
# Open sockets or files here.
|
27
|
+
def start
|
28
|
+
super
|
29
|
+
end
|
30
|
+
|
31
|
+
# This method is called when shutting down.
|
32
|
+
# Shutdown the thread and close sockets or files here.
|
33
|
+
def shutdown
|
34
|
+
super
|
35
|
+
$log.info 'Rollbar Output shutting down'
|
36
|
+
end
|
37
|
+
|
38
|
+
# This method is called when an event reaches to Fluentd.
|
39
|
+
# Convert the event to a raw string.
|
40
|
+
def format(tag, time, record)
|
41
|
+
# [tag, time, record].to_json + "\n"
|
42
|
+
## Alternatively, use msgpack to serialize the object.
|
43
|
+
[tag, time, record].to_msgpack
|
44
|
+
end
|
45
|
+
|
46
|
+
# This method is called every flush interval. Write the buffer chunk
|
47
|
+
# to files or databases here.
|
48
|
+
# 'chunk' is a buffer chunk that includes multiple formatted
|
49
|
+
# events. You can use 'data = chunk.read' to get all events and
|
50
|
+
# 'chunk.open {|io| ... }' to get IO objects.
|
51
|
+
#
|
52
|
+
# NOTE! This method is called by internal thread, not Fluentd's main thread. So IO wait doesn't affect other plugins.
|
53
|
+
# def write(chunk)
|
54
|
+
# data = chunk.read
|
55
|
+
# print data
|
56
|
+
# end
|
57
|
+
|
58
|
+
## Optionally, you can use chunk.msgpack_each to deserialize objects.
|
59
|
+
def write(chunk)
|
60
|
+
chunk.msgpack_each do |(_tag, _time, record)|
|
61
|
+
record = record['log'] if record.key? 'log'
|
62
|
+
|
63
|
+
EventMachine.run do
|
64
|
+
record['access_token'] = @access_token
|
65
|
+
headers = { 'X-Rollbar-Access-Token' => @access_token }
|
66
|
+
req = EventMachine::HttpRequest.new(@endpoint).post(body: record.to_json, head: headers)
|
67
|
+
|
68
|
+
req.callback do
|
69
|
+
if req.response_header.status != 200
|
70
|
+
$log.warn "rollbar: Got unexpected status code from Rollbar.io api: #{req.response_header.status}"
|
71
|
+
$log.warn "rollbar: Response: #{req.response}"
|
72
|
+
end
|
73
|
+
|
74
|
+
EventMachine.stop
|
75
|
+
end
|
76
|
+
|
77
|
+
req.errback do
|
78
|
+
$log.warn "rollbar: Call to API failed, status code: #{req.response_header.status}"
|
79
|
+
$log.warn "rollbar: Error's response: #{req.response}"
|
80
|
+
|
81
|
+
EventMachine.stop
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
rescue Exception => e
|
86
|
+
$log.warn "rollbar: #{e}"
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
metadata
ADDED
@@ -0,0 +1,104 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fluent-plugin-rollbar
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Volker Machon
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-02-19 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'
|
20
|
+
type: :runtime
|
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: eventmachine
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
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: json
|
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: em-http-request
|
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: Rollbar Out Plugin for Fluentd
|
70
|
+
email: volker@machon.biz
|
71
|
+
executables: []
|
72
|
+
extensions: []
|
73
|
+
extra_rdoc_files: []
|
74
|
+
files:
|
75
|
+
- ".gitignore"
|
76
|
+
- LICENSE
|
77
|
+
- README.md
|
78
|
+
- VERSION
|
79
|
+
- fluent-plugin-rollbar.gemspec
|
80
|
+
- lib/fluent/plugin/out_rollbar.rb
|
81
|
+
homepage: https://github.com/olafnorge/fluent-plugin-rollbar
|
82
|
+
licenses: []
|
83
|
+
metadata: {}
|
84
|
+
post_install_message:
|
85
|
+
rdoc_options: []
|
86
|
+
require_paths:
|
87
|
+
- lib
|
88
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
89
|
+
requirements:
|
90
|
+
- - ">="
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: '0'
|
93
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - ">="
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '0'
|
98
|
+
requirements: []
|
99
|
+
rubyforge_project:
|
100
|
+
rubygems_version: 2.5.1
|
101
|
+
signing_key:
|
102
|
+
specification_version: 4
|
103
|
+
summary: Rollbar Out Plugin for Fluentd
|
104
|
+
test_files: []
|