fluentd-plugin-coralogix_logger 1.1.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/lib/fluent/plugin/out_coralogix.rb +104 -0
- metadata +64 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 0f09fc385c5b1a10910952f83fe13236f195ecc4
|
4
|
+
data.tar.gz: 2896d97af1a861401a988fa4bc6d0474ec539bd9
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 4e8ece81947e161e8dd098e82eb564f3abf01b317469c0e3b26859ce15d844f66e46c55715e2d7eb114ae63cce725a299d55c5b120a1a35e273bfa725ff60968
|
7
|
+
data.tar.gz: bea365dc80f6acc5bb90d1bf082d460316e2b4ae632543833a24b4a44f27f60119ee4b40edab473ba8d370b20ccfe99fae12e4a203707dc4cbd24f850e4ea438
|
@@ -0,0 +1,104 @@
|
|
1
|
+
require 'fluent/output'
|
2
|
+
require 'coralogix_fluentd_logger'
|
3
|
+
|
4
|
+
include Coralogix
|
5
|
+
|
6
|
+
module Fluent
|
7
|
+
|
8
|
+
DEFAULT_appname = "FAILED_APP_NAME"
|
9
|
+
DEFAULT_subsystemname = "FAILED_SUBSYSTEM_NAME"
|
10
|
+
|
11
|
+
class SomeOutput < Output
|
12
|
+
# First, register the plugin. NAME is the name of this plugin
|
13
|
+
# and identifies the plugin in the configuration file.
|
14
|
+
Fluent::Plugin.register_output('coralogix', self)
|
15
|
+
config_param :log_key_name, :string, :default => nil
|
16
|
+
config_param :privatekey, :string, :default => nil
|
17
|
+
config_param :appname, :string
|
18
|
+
config_param :subsystemname, :string
|
19
|
+
config_param :is_json, :bool, :default => false
|
20
|
+
@configured = false
|
21
|
+
|
22
|
+
|
23
|
+
# This method is called before starting.
|
24
|
+
def configure(conf)
|
25
|
+
super
|
26
|
+
begin
|
27
|
+
@loggers = {}
|
28
|
+
#If config parameters doesn't start with $ then we can configure Coralogix logger now.
|
29
|
+
if !appname.start_with?("$") && !subsystemname.start_with?("$")
|
30
|
+
@logger = CoralogixLogger.new privatekey, appname, subsystemname
|
31
|
+
@configured = true
|
32
|
+
end
|
33
|
+
rescue Exception => e
|
34
|
+
$log.error "Failed to configure: #{e}"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def extract record, key, default
|
39
|
+
begin
|
40
|
+
res = record
|
41
|
+
return key unless key.start_with?("$")
|
42
|
+
key[1..-1].split(".").each do |k|
|
43
|
+
res = res.fetch(k,nil)
|
44
|
+
return default if res == nil
|
45
|
+
end
|
46
|
+
return res
|
47
|
+
rescue Exception => e
|
48
|
+
$log.error "Failed to extract #{key}: #{e}"
|
49
|
+
return default
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
|
54
|
+
def get_app_sub_name(record)
|
55
|
+
app_name = extract(record, appname, DEFAULT_appname)
|
56
|
+
sub_name = extract(record, subsystemname, DEFAULT_subsystemname)
|
57
|
+
return app_name, sub_name
|
58
|
+
end
|
59
|
+
|
60
|
+
def get_logger(record)
|
61
|
+
|
62
|
+
return @logger if @configured
|
63
|
+
|
64
|
+
app_name, sub_name = get_app_sub_name(record)
|
65
|
+
|
66
|
+
if !@loggers.key?("#{app_name}.#{sub_name}")
|
67
|
+
@loggers["#{app_name}.#{sub_name}"] = CoralogixLogger.new privatekey, app_name, sub_name
|
68
|
+
end
|
69
|
+
|
70
|
+
return @loggers["#{app_name}.#{sub_name}"]
|
71
|
+
end
|
72
|
+
|
73
|
+
|
74
|
+
# This method is called when starting.
|
75
|
+
def start
|
76
|
+
super
|
77
|
+
end
|
78
|
+
|
79
|
+
# This method is called when shutting down.
|
80
|
+
def shutdown
|
81
|
+
super
|
82
|
+
end
|
83
|
+
|
84
|
+
# This method is called when an event reaches Fluentd.
|
85
|
+
# 'es' is a Fluent::EventStream object that includes multiple events.
|
86
|
+
# You can use 'es.each {|time,record| ... }' to retrieve events.
|
87
|
+
# 'chain' is an object that manages transactions. Call 'chain.next' at
|
88
|
+
# appropriate points and rollback if it raises an exception.
|
89
|
+
#
|
90
|
+
# NOTE! This method is called by Fluentd's main thread so you should not write slow routine here. It causes Fluentd's performance degression.
|
91
|
+
def emit(tag, es, chain)
|
92
|
+
chain.next
|
93
|
+
es.each {|time,record|
|
94
|
+
logger = get_logger(record)
|
95
|
+
|
96
|
+
log_record = log_key_name != nil ? record.fetch(log_key_name, record) : record
|
97
|
+
log_record = is_json ? log_record.to_json : log_record
|
98
|
+
log_record = log_record.to_s.empty? ? record : log_record
|
99
|
+
#puts log_record
|
100
|
+
logger.debug log_record
|
101
|
+
}
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
metadata
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fluentd-plugin-coralogix_logger
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Amnon Shahar
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-02-26 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: coralogix_fluentd_logger
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.0'
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 0.0.2
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - "~>"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0.0'
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 0.0.2
|
33
|
+
description: Coralogix Fluentd plugin to send logs to Coralogix server.
|
34
|
+
email: amnon@coralogix.com
|
35
|
+
executables: []
|
36
|
+
extensions: []
|
37
|
+
extra_rdoc_files: []
|
38
|
+
files:
|
39
|
+
- lib/fluent/plugin/out_coralogix.rb
|
40
|
+
homepage: http://www.coralogix.com
|
41
|
+
licenses:
|
42
|
+
- MIT
|
43
|
+
metadata: {}
|
44
|
+
post_install_message:
|
45
|
+
rdoc_options: []
|
46
|
+
require_paths:
|
47
|
+
- lib
|
48
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
49
|
+
requirements:
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: 2.0.0
|
53
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: '0'
|
58
|
+
requirements: []
|
59
|
+
rubyforge_project:
|
60
|
+
rubygems_version: 2.6.8
|
61
|
+
signing_key:
|
62
|
+
specification_version: 4
|
63
|
+
summary: Coralogix Fluentd out plugin
|
64
|
+
test_files: []
|