fluent-plugin-logdna 0.1.0

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: d6d4f3ff540859fa2e19ea517febef74e210cfd7
4
+ data.tar.gz: ff5f6c81db7105855ceea9180cd3b86aa1a5f1f6
5
+ SHA512:
6
+ metadata.gz: a50034d4665e5ec010190dd49c03defc5cb8d84c93522942d5431052bf572914096632b09cc46ccce669fb00ca531b4fcd85beb02a6b893ef21a85564dce10c4
7
+ data.tar.gz: 9867b079ffcd131b4192625bb8fe5bc1b113e3f28e0b9df2547aaba4f71a24a1c33513d2a131a6d189e2c2c4cd2617e8dde2b02e50be3f8c51d0b381329b0e56
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/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.3.1
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2016 Answerbook, Inc.
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,25 @@
1
+ # fluent-plugin-logdna
2
+
3
+ Using fluent-plugin-logdna, you can send the logs you collect with Fluentd to LogDNA.
4
+
5
+ ## Instructions
6
+
7
+ * Install [Fluentd](http://www.fluentd.org/download)
8
+ * `gem install fluent-plugin-logdna` or `td-agent-gem install fluent-plugin-logdna` if you are using td-agent.
9
+ * Make sure you have a LogDNA account.
10
+ * Configure Fluentd like the following:
11
+
12
+ ~~~~~
13
+ <match your_match>
14
+ type logdna
15
+ api_key d942fed2d0a65b0181e49ae3307465dd # paste your api key here (required)
16
+ hostname GitHub # replace with your hostname (required)
17
+ mac C0:FF:EE:C0:FF:EE # replace with host mac address
18
+ ip 127.0.0.1 # replace with host ip address
19
+ app my_app # replace with your app name
20
+ </match>
21
+ ~~~~~
22
+
23
+ For advanced configuration options, refer to the [buffered output parameters documentation.](http://docs.fluentd.org/articles/output-plugin-overview#buffered-output-parameters)
24
+
25
+ Questions or concerns? Contact [support@logdna.com](mailto:support@logdna.com).
@@ -0,0 +1,20 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = 'fluent-plugin-logdna'
5
+ s.version = '0.1.0'
6
+ s.date = '2016-10-20'
7
+ s.summary = 'LogDNA plugin for Fluentd'
8
+ s.description = 'Fluentd plugin for supplying output to LogDNA.'
9
+ s.authors = ['Edwin Lai']
10
+ s.email = 'edwin@logdna.com'
11
+ s.files = ['lib/fluent/plugin/out_logdna.rb']
12
+ s.homepage = 'https://github.com/logdna/fluent-plugin-logdna'
13
+ s.license = 'MIT'
14
+
15
+ s.require_paths = ['lib']
16
+ s.files = `git ls-files -z`.split("\x0")
17
+ s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ s.required_ruby_version = Gem::Requirement.new('>= 2.0.0')
19
+ s.add_runtime_dependency 'http', '~> 2.0', '>= 2.0.3'
20
+ end
@@ -0,0 +1,85 @@
1
+ require 'fluent/output'
2
+
3
+ module Fluent
4
+ class LogDNAOutput < Fluent::BufferedOutput
5
+ Fluent::Plugin.register_output('logdna', self)
6
+
7
+ INGESTER_DOMAIN = 'https://logs.logdna.com'.freeze
8
+
9
+ config_param :api_key, :string
10
+ config_param :hostname, :string
11
+ config_param :mac, :string, default: nil
12
+ config_param :ip, :string, default: nil
13
+ config_param :app, :string, default: nil
14
+
15
+ def configure(conf)
16
+ super
17
+ @host = conf['hostname']
18
+ end
19
+
20
+ def start
21
+ super
22
+ require 'json'
23
+ require 'base64'
24
+ require 'http'
25
+ @ingester = HTTP.persistent INGESTER_DOMAIN
26
+ end
27
+
28
+ def shutdown
29
+ super
30
+ ingester.close if ingester
31
+ end
32
+
33
+ def format(tag, time, record)
34
+ [tag, time, record].to_msgpack
35
+ end
36
+
37
+ def write(chunk)
38
+ body = chunk_to_body(chunk)
39
+ response = send_request(body)
40
+ handle(response)
41
+ end
42
+
43
+ private
44
+
45
+ def chunk_to_body(chunk)
46
+ data = []
47
+
48
+ chunk.msgpack_each do |(tag, time, record)|
49
+ line = gather_line_data(tag, time, record)
50
+ data << line
51
+ end
52
+
53
+ { lines: data }
54
+ end
55
+
56
+ def gather_line_data(tag, time, record)
57
+ line = {
58
+ level: tag.split('.').last,
59
+ timestamp: time,
60
+ line: record['message']
61
+ }
62
+ line[:app] = @app if @app
63
+ line
64
+ end
65
+
66
+ def handle(response)
67
+ if response.code >= 400
68
+ print "Error connecting to LogDNA ingester. \n"
69
+ print "Details: #{response}"
70
+ else
71
+ print "Success! #{response}"
72
+ end
73
+
74
+ response.flush
75
+ end
76
+
77
+ def send_request(body)
78
+ now = Time.now.to_i
79
+ url = "/logs/ingest?hostname=#{@host}&mac=#{@mac}&ip=#{@ip}&now=#{now}"
80
+ @ingester.headers('apikey' => @api_key,
81
+ 'content-type' => 'application/json')
82
+ .post(url, json: body)
83
+ end
84
+ end
85
+ end
metadata ADDED
@@ -0,0 +1,69 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fluent-plugin-logdna
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Edwin Lai
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-10-20 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: http
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.0'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 2.0.3
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: '2.0'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 2.0.3
33
+ description: Fluentd plugin for supplying output to LogDNA.
34
+ email: edwin@logdna.com
35
+ executables: []
36
+ extensions: []
37
+ extra_rdoc_files: []
38
+ files:
39
+ - ".gitignore"
40
+ - ".ruby-version"
41
+ - LICENSE
42
+ - README.md
43
+ - fluent-plugin-logdna.gemspec
44
+ - lib/fluent/plugin/out_logdna.rb
45
+ homepage: https://github.com/logdna/fluent-plugin-logdna
46
+ licenses:
47
+ - MIT
48
+ metadata: {}
49
+ post_install_message:
50
+ rdoc_options: []
51
+ require_paths:
52
+ - lib
53
+ required_ruby_version: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ version: 2.0.0
58
+ required_rubygems_version: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ requirements: []
64
+ rubyforge_project:
65
+ rubygems_version: 2.5.1
66
+ signing_key:
67
+ specification_version: 4
68
+ summary: LogDNA plugin for Fluentd
69
+ test_files: []