fluent-plugin-input-gelf 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/fluent-plugin-input-gelf.gemspec +1 -1
- data/lib/fluent/plugin/in_gelf.rb +14 -0
- data/test/plugin/test_in_gelf.rb +49 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7100acddd4910c56b36af50f13695d2773b4ff6b
|
4
|
+
data.tar.gz: e1d860e9bc6541e7b0a35afad2b7149eee717b7b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9ae80360cd1ad43d94601711aae40b753cd78f2257d274554532af22d634ac1a5e92ac82a23757bd597307f5444ad9d559ded507a9af692ab66839df681a7c8b
|
7
|
+
data.tar.gz: cb307f962df7291b71e24a8f351bdb3266a3bd40ec7d392e94a5cd52add9fdb2e90259499de2d58e8c62bd3cc505e537ae715add132f27d4cad3eb6277da2d76
|
@@ -7,7 +7,7 @@ Gem::Specification.new do |gem|
|
|
7
7
|
gem.license = "MIT"
|
8
8
|
gem.homepage = "https://github.com/MerlinDMC/fluent-plugin-input-gelf"
|
9
9
|
gem.summary = gem.description
|
10
|
-
gem.version = "0.1.
|
10
|
+
gem.version = "0.1.1"
|
11
11
|
gem.authors = ["Daniel Malon"]
|
12
12
|
gem.email = "daniel.malon@me.com"
|
13
13
|
gem.has_rdoc = false
|
@@ -36,6 +36,8 @@ module Fluent
|
|
36
36
|
end
|
37
37
|
end
|
38
38
|
config_param :blocking_timeout, :time, default: 0.5
|
39
|
+
desc 'Strip leading underscore'
|
40
|
+
config_param :strip_leading_underscore, :bool, default: true
|
39
41
|
|
40
42
|
def configure(conf)
|
41
43
|
super
|
@@ -86,6 +88,9 @@ module Fluent
|
|
86
88
|
# Use the recorded event time if available
|
87
89
|
time = record.delete('timestamp').to_i if record.key?('timestamp')
|
88
90
|
|
91
|
+
# Postprocess recorded event
|
92
|
+
strip_leading_underscore(record) if @strip_leading_underscore
|
93
|
+
|
89
94
|
emit(time, record)
|
90
95
|
}
|
91
96
|
rescue => e
|
@@ -109,5 +114,14 @@ module Fluent
|
|
109
114
|
rescue => e
|
110
115
|
log.error 'gelf failed to emit', error: e.to_s, error_class: e.class.to_s, tag: @tag, record: Yajl.dump(record)
|
111
116
|
end
|
117
|
+
|
118
|
+
private
|
119
|
+
|
120
|
+
def strip_leading_underscore(record)
|
121
|
+
record.keys.each { |k|
|
122
|
+
next unless k[0,1] == '_'
|
123
|
+
record[k[1..-1]] = record.delete(k)
|
124
|
+
}
|
125
|
+
end
|
112
126
|
end
|
113
127
|
end
|
data/test/plugin/test_in_gelf.rb
CHANGED
@@ -69,4 +69,53 @@ class GelfInputTest < Test::Unit::TestCase
|
|
69
69
|
}
|
70
70
|
}
|
71
71
|
end
|
72
|
+
|
73
|
+
def test_strip_leading_underscore
|
74
|
+
configs = {'127.0.0.1' => CONFIG}
|
75
|
+
# gelf-rb currently does not support IPv6 over UDP
|
76
|
+
# configs.merge!('::1' => IPv6_CONFIG) if ipv6_enabled?
|
77
|
+
|
78
|
+
configs.each_pair { |k, v|
|
79
|
+
d = create_driver(v)
|
80
|
+
|
81
|
+
tests = [
|
82
|
+
{:given =>
|
83
|
+
{
|
84
|
+
:timestamp => 12345,
|
85
|
+
:short_message => 'short message',
|
86
|
+
:full_message => 'full message',
|
87
|
+
'_custom_field' => 12345
|
88
|
+
},
|
89
|
+
:expected =>
|
90
|
+
{
|
91
|
+
'short_message' => 'short message',
|
92
|
+
'full_message' => 'full message',
|
93
|
+
'custom_field' => 12345
|
94
|
+
}
|
95
|
+
}
|
96
|
+
]
|
97
|
+
|
98
|
+
d.run do
|
99
|
+
n = GELF::Notifier.new(k, PORT)
|
100
|
+
|
101
|
+
tests.each { |test|
|
102
|
+
n.notify!(test[:given])
|
103
|
+
}
|
104
|
+
|
105
|
+
sleep 1
|
106
|
+
end
|
107
|
+
|
108
|
+
emits = d.emits
|
109
|
+
assert_equal tests.length, emits.length, 'missing emitted events'
|
110
|
+
emits.each_index { |i|
|
111
|
+
puts emits[i].to_s
|
112
|
+
assert_equal 'gelf', emits[i][0]
|
113
|
+
assert_equal tests[i][:timestamp].to_i, emits[i][1] unless tests[i][:timestamp].nil?
|
114
|
+
assert_block "expectation not met: #{tests[i][:expected]}" do
|
115
|
+
emits[i][2].merge(tests[i][:expected]) == emits[i][2]
|
116
|
+
end
|
117
|
+
}
|
118
|
+
}
|
119
|
+
end
|
120
|
+
|
72
121
|
end
|