hshek-logstash-output-sumologic 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +34 -0
- data/DEVELOPER.md +39 -0
- data/Gemfile +4 -0
- data/LICENSE +196 -0
- data/README.md +158 -0
- data/lib/logstash/outputs/sumologic.rb +158 -0
- data/lib/logstash/outputs/sumologic/batch.rb +13 -0
- data/lib/logstash/outputs/sumologic/common.rb +73 -0
- data/lib/logstash/outputs/sumologic/compressor.rb +39 -0
- data/lib/logstash/outputs/sumologic/header_builder.rb +52 -0
- data/lib/logstash/outputs/sumologic/message_queue.rb +57 -0
- data/lib/logstash/outputs/sumologic/monitor.rb +76 -0
- data/lib/logstash/outputs/sumologic/payload_builder.rb +159 -0
- data/lib/logstash/outputs/sumologic/piler.rb +89 -0
- data/lib/logstash/outputs/sumologic/sender.rb +172 -0
- data/lib/logstash/outputs/sumologic/statistics.rb +100 -0
- data/logstash-output-sumologic.gemspec +27 -0
- data/spec/outputs/sumologic/compressor_spec.rb +27 -0
- data/spec/outputs/sumologic/header_builder_spec.rb +244 -0
- data/spec/outputs/sumologic/message_queue_spec.rb +50 -0
- data/spec/outputs/sumologic/payload_builder_spec.rb +522 -0
- data/spec/outputs/sumologic/piler_spec.rb +154 -0
- data/spec/outputs/sumologic/sender_spec.rb +188 -0
- data/spec/outputs/sumologic_spec.rb +240 -0
- data/spec/test_server.rb +49 -0
- metadata +161 -0
@@ -0,0 +1,50 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require "logstash/devutils/rspec/spec_helper"
|
3
|
+
require "logstash/outputs/sumologic"
|
4
|
+
include LogStash::Outputs
|
5
|
+
|
6
|
+
describe SumoLogic::MessageQueue do
|
7
|
+
|
8
|
+
context "working in pile mode if interval > 0 && pile_max > 0" do
|
9
|
+
|
10
|
+
let(:queue) { SumoLogic::MessageQueue.new(stats, "queue_max" => 10) }
|
11
|
+
let(:stats) { SumoLogic::Statistics.new }
|
12
|
+
|
13
|
+
it "enq() correctly" do
|
14
|
+
10.times { |i|
|
15
|
+
queue.enq(SumoLogic::Batch.new(Hash.new, "test - #{i}"))
|
16
|
+
expect(queue.size()).to eq(i + 1)
|
17
|
+
expect(stats.total_enque_times.value).to eq(i + 1)
|
18
|
+
}
|
19
|
+
expect(queue.bytesize()).to eq(100)
|
20
|
+
end
|
21
|
+
|
22
|
+
it "deq() correctly" do
|
23
|
+
10.times { |i|
|
24
|
+
queue.enq(SumoLogic::Batch.new(Hash.new, "test - #{i}"))
|
25
|
+
}
|
26
|
+
10.times { |i|
|
27
|
+
expect(queue.size()).to eq(10 - i)
|
28
|
+
result = queue.deq()
|
29
|
+
expect(result.payload).to eq("test - #{i}")
|
30
|
+
expect(stats.total_deque_times.value).to eq(i + 1)
|
31
|
+
}
|
32
|
+
expect(queue.bytesize()).to eq(0)
|
33
|
+
end
|
34
|
+
|
35
|
+
it "drain() correctly" do
|
36
|
+
10.times { |i|
|
37
|
+
queue.enq(SumoLogic::Batch.new(Hash.new, "test - #{i}"))
|
38
|
+
}
|
39
|
+
result = queue.drain()
|
40
|
+
expect(queue.size()).to eq(0)
|
41
|
+
expect(stats.total_deque_times.value).to eq(10)
|
42
|
+
expect(result.size).to eq(10)
|
43
|
+
expect(queue.bytesize()).to eq(0)
|
44
|
+
10.times { |i|
|
45
|
+
expect(result[i].payload).to eq("test - #{i}")
|
46
|
+
}
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,522 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require "logstash/devutils/rspec/spec_helper"
|
3
|
+
require "logstash/outputs/sumologic"
|
4
|
+
|
5
|
+
describe LogStash::Outputs::SumoLogic::PayloadBuilder do
|
6
|
+
|
7
|
+
result = ""
|
8
|
+
|
9
|
+
before :each do
|
10
|
+
result = builder.build(event)
|
11
|
+
end
|
12
|
+
|
13
|
+
context "should build log payload in default format" do
|
14
|
+
let(:stats) { LogStash::Outputs::SumoLogic::Statistics.new() }
|
15
|
+
let(:builder) { LogStash::Outputs::SumoLogic::PayloadBuilder.new(stats, "url" => "http://localhost/1234") }
|
16
|
+
let(:event) { LogStash::Event.new("host" => "myHost", "message" => "Hello world") }
|
17
|
+
|
18
|
+
it "start with a valid timestamp" do
|
19
|
+
ts = result.split(" ")[0]
|
20
|
+
DateTime.parse(ts)
|
21
|
+
end
|
22
|
+
|
23
|
+
it "end with host and message" do
|
24
|
+
expect(result).to end_with("myHost Hello world")
|
25
|
+
end
|
26
|
+
|
27
|
+
end # context
|
28
|
+
|
29
|
+
context "should build log payload with @json tag" do
|
30
|
+
let(:stats) { LogStash::Outputs::SumoLogic::Statistics.new() }
|
31
|
+
let(:builder) { LogStash::Outputs::SumoLogic::PayloadBuilder.new(stats, "url" => "http://localhost/1234", "format" => "%{@json}") }
|
32
|
+
let(:event) { LogStash::Event.new("host" => "myHost", "message" => "Hello world") }
|
33
|
+
|
34
|
+
it "include host field" do
|
35
|
+
expect(result).to include("\"host\":\"myHost\"")
|
36
|
+
end
|
37
|
+
|
38
|
+
it "include host field" do
|
39
|
+
expect(result).to include("\"message\":\"Hello world\"")
|
40
|
+
end
|
41
|
+
|
42
|
+
it "include host field" do
|
43
|
+
expect(result).to include("\"@timestamp\"")
|
44
|
+
end
|
45
|
+
|
46
|
+
end # context
|
47
|
+
|
48
|
+
context "should build log payload with customized format" do
|
49
|
+
let(:stats) { LogStash::Outputs::SumoLogic::Statistics.new() }
|
50
|
+
let(:builder) { LogStash::Outputs::SumoLogic::PayloadBuilder.new(stats, "url" => "http://localhost/1234", "format" => "%{@timestamp} %{foo} %{bar}") }
|
51
|
+
let(:event) { LogStash::Event.new("host" => "myHost", "foo" => "fancy", "bar" => 24) }
|
52
|
+
|
53
|
+
it "start with a valid timestamp" do
|
54
|
+
ts = result.split(" ")[0]
|
55
|
+
DateTime.parse(ts)
|
56
|
+
end
|
57
|
+
|
58
|
+
it "end with host and message" do
|
59
|
+
expect(result).to end_with("fancy 24")
|
60
|
+
end
|
61
|
+
|
62
|
+
end # context
|
63
|
+
|
64
|
+
context "should build log payload with customized json_mapping" do
|
65
|
+
let(:stats) { LogStash::Outputs::SumoLogic::Statistics.new() }
|
66
|
+
let(:builder) {
|
67
|
+
LogStash::Outputs::SumoLogic::PayloadBuilder.new(stats,
|
68
|
+
"url" => "http://localhost/1234",
|
69
|
+
"format" => "%{host} %{@json}",
|
70
|
+
"json_mapping" => {
|
71
|
+
"foo" => "%{foo}",
|
72
|
+
"bar" => "%{bar}"
|
73
|
+
})
|
74
|
+
}
|
75
|
+
let(:event) { LogStash::Event.new("host" => "myHost", "foo" => "fancy", "bar" => 24) }
|
76
|
+
|
77
|
+
specify {
|
78
|
+
expect(result).to eq("myHost {\"foo\":\"fancy\",\"bar\":\"24\"}")
|
79
|
+
}
|
80
|
+
|
81
|
+
end # context
|
82
|
+
|
83
|
+
context "should build metrics payload with graphite format" do
|
84
|
+
let(:stats) { LogStash::Outputs::SumoLogic::Statistics.new() }
|
85
|
+
let(:builder) {
|
86
|
+
LogStash::Outputs::SumoLogic::PayloadBuilder.new(stats,
|
87
|
+
"url" => "http://localhost/1234",
|
88
|
+
"metrics" => {
|
89
|
+
"hurray.%{foo}" => "%{bar}"
|
90
|
+
},
|
91
|
+
"metrics_format" => "graphite")
|
92
|
+
}
|
93
|
+
let(:event) { LogStash::Event.new("host" => "myHost", "foo" => "fancy", "bar" => 24) }
|
94
|
+
|
95
|
+
it "start with metrics name and value" do
|
96
|
+
expect(result).to start_with("hurray.fancy 24 ")
|
97
|
+
end
|
98
|
+
|
99
|
+
it "end with epoch timestamp" do
|
100
|
+
expect(result).to match(/\d{10,}$/)
|
101
|
+
end
|
102
|
+
|
103
|
+
end # context
|
104
|
+
|
105
|
+
context "should build metrics payload with carbon2 format" do
|
106
|
+
let(:stats) { LogStash::Outputs::SumoLogic::Statistics.new() }
|
107
|
+
let(:builder) {
|
108
|
+
LogStash::Outputs::SumoLogic::PayloadBuilder.new(stats,
|
109
|
+
"url" => "http://localhost/1234",
|
110
|
+
"metrics" => {
|
111
|
+
"hurray.%{foo}" => "%{bar}"
|
112
|
+
})
|
113
|
+
}
|
114
|
+
let(:event) { LogStash::Event.new("host" => "myHost", "foo" => "fancy", "bar" => 24) }
|
115
|
+
|
116
|
+
it "start with metrics name and value" do
|
117
|
+
expect(result).to start_with("metric=hurray.fancy 24 ")
|
118
|
+
end
|
119
|
+
|
120
|
+
it "end with epoch timestamp" do
|
121
|
+
expect(result).to match(/\d{10,}$/)
|
122
|
+
end
|
123
|
+
|
124
|
+
end # context
|
125
|
+
|
126
|
+
context "should build metrics payload with metrics_name override" do
|
127
|
+
let(:stats) { LogStash::Outputs::SumoLogic::Statistics.new() }
|
128
|
+
let(:builder) {
|
129
|
+
LogStash::Outputs::SumoLogic::PayloadBuilder.new(stats,
|
130
|
+
"url" => "http://localhost/1234",
|
131
|
+
"metrics" => {
|
132
|
+
"hurray.%{foo}" => "%{bar}"
|
133
|
+
},
|
134
|
+
"metrics_name" => "mynamespace.*")
|
135
|
+
}
|
136
|
+
let(:event) { LogStash::Event.new("host" => "myHost", "foo" => "fancy", "bar" => 24) }
|
137
|
+
|
138
|
+
it "start with modified metrics name and value" do
|
139
|
+
expect(result).to start_with("metric=mynamespace.hurray.fancy 24 ")
|
140
|
+
end
|
141
|
+
|
142
|
+
it "end with epoch timestamp" do
|
143
|
+
expect(result).to match(/\d{10,}$/)
|
144
|
+
end
|
145
|
+
|
146
|
+
end # context
|
147
|
+
|
148
|
+
context "should build metrics payload with intrinsic_tags override" do
|
149
|
+
let(:stats) { LogStash::Outputs::SumoLogic::Statistics.new() }
|
150
|
+
let(:builder) {
|
151
|
+
LogStash::Outputs::SumoLogic::PayloadBuilder.new(stats,
|
152
|
+
"url" => "http://localhost/1234",
|
153
|
+
"metrics" => {
|
154
|
+
"bar" => "%{bar}"
|
155
|
+
},
|
156
|
+
"intrinsic_tags" => {
|
157
|
+
"host" => "%{host}"
|
158
|
+
})
|
159
|
+
}
|
160
|
+
let(:event) { LogStash::Event.new("host" => "myHost", "foo" => "fancy", "bar" => 24) }
|
161
|
+
|
162
|
+
it "start with modified intrinsic tags and value" do
|
163
|
+
expect(result).to start_with("host=myHost metric=bar 24 ")
|
164
|
+
end
|
165
|
+
|
166
|
+
it "end with epoch timestamp" do
|
167
|
+
expect(result).to match(/\d{10,}$/)
|
168
|
+
end
|
169
|
+
|
170
|
+
end # context
|
171
|
+
|
172
|
+
context "should build metrics payload with meta_tags override" do
|
173
|
+
let(:stats) { LogStash::Outputs::SumoLogic::Statistics.new() }
|
174
|
+
let(:builder) {
|
175
|
+
LogStash::Outputs::SumoLogic::PayloadBuilder.new(stats,
|
176
|
+
"url" => "http://localhost/1234",
|
177
|
+
"metrics" => {
|
178
|
+
"bar" => "%{bar}"
|
179
|
+
},
|
180
|
+
"intrinsic_tags" => {
|
181
|
+
"host" => "%{host}"
|
182
|
+
},
|
183
|
+
"meta_tags" => {
|
184
|
+
"foo" => "%{foo}"
|
185
|
+
})
|
186
|
+
}
|
187
|
+
let(:event) { LogStash::Event.new("host" => "myHost", "foo" => "fancy", "bar" => 24) }
|
188
|
+
|
189
|
+
it "start with modified intrinsic/meta tags and value" do
|
190
|
+
expect(result).to start_with("host=myHost metric=bar foo=fancy 24 ")
|
191
|
+
end
|
192
|
+
|
193
|
+
it "end with epoch timestamp" do
|
194
|
+
expect(result).to match(/\d{10,}$/)
|
195
|
+
end
|
196
|
+
|
197
|
+
end # context
|
198
|
+
|
199
|
+
context "should build metrics payload with multi lines with different values (graphite)" do
|
200
|
+
let(:stats) { LogStash::Outputs::SumoLogic::Statistics.new() }
|
201
|
+
let(:builder) {
|
202
|
+
LogStash::Outputs::SumoLogic::PayloadBuilder.new(stats,
|
203
|
+
"url" => "http://localhost/1234",
|
204
|
+
"metrics" => {
|
205
|
+
"cpu1" => "%{cpu1}",
|
206
|
+
"cpu2" => "%{cpu2}"
|
207
|
+
},
|
208
|
+
"metrics_name" => "mynamespace.*",
|
209
|
+
"metrics_format" => "graphite")
|
210
|
+
}
|
211
|
+
let(:event) { LogStash::Event.new("host" => "myHost", "foo" => "fancy", "cpu1" => 0.24, "cpu2" => 0.11) }
|
212
|
+
|
213
|
+
specify {
|
214
|
+
lines = result.split(/\n/).sort
|
215
|
+
expect(lines.length).to eq(2)
|
216
|
+
expect(lines.shift).to match(/^mynamespace\.cpu1 0\.24 \d{10,}$/)
|
217
|
+
expect(lines.shift).to match(/^mynamespace\.cpu2 0\.11 \d{10,}$/)
|
218
|
+
}
|
219
|
+
|
220
|
+
end # context
|
221
|
+
|
222
|
+
context "should build metrics payload with multi lines with different values (carbon2)" do
|
223
|
+
let(:stats) { LogStash::Outputs::SumoLogic::Statistics.new() }
|
224
|
+
let(:builder) {
|
225
|
+
LogStash::Outputs::SumoLogic::PayloadBuilder.new(stats,
|
226
|
+
"url" => "http://localhost/1234",
|
227
|
+
"metrics" => {
|
228
|
+
"cpu1" => "%{cpu1}",
|
229
|
+
"cpu2" => "%{cpu2}"
|
230
|
+
},
|
231
|
+
"intrinsic_tags" => {
|
232
|
+
"host" => "%{host}"
|
233
|
+
},
|
234
|
+
"meta_tags" => {
|
235
|
+
"foo" => "%{foo}"
|
236
|
+
})
|
237
|
+
}
|
238
|
+
let(:event) { LogStash::Event.new("host" => "myHost", "foo" => "fancy", "cpu1" => 0.24, "cpu2" => 0.11) }
|
239
|
+
|
240
|
+
specify {
|
241
|
+
lines = result.split(/\n/).sort
|
242
|
+
expect(lines.length).to eq(2)
|
243
|
+
expect(lines.shift).to match(/^host=myHost metric=cpu1 foo=fancy 0\.24 \d{10,}$/)
|
244
|
+
expect(lines.shift).to match(/^host=myHost metric=cpu2 foo=fancy 0\.11 \d{10,}$/)
|
245
|
+
}
|
246
|
+
|
247
|
+
end # context
|
248
|
+
|
249
|
+
context "should build metrics payload with non-number value dropped (graphite)" do
|
250
|
+
let(:stats) { LogStash::Outputs::SumoLogic::Statistics.new() }
|
251
|
+
let(:builder) {
|
252
|
+
LogStash::Outputs::SumoLogic::PayloadBuilder.new(stats,
|
253
|
+
"url" => "http://localhost/1234",
|
254
|
+
"metrics" => {
|
255
|
+
"cpu1" => "%{cpu1}",
|
256
|
+
"cpu2" => "%{cpu2}",
|
257
|
+
"cpu3" => "%{cpu3}"
|
258
|
+
},
|
259
|
+
"metrics_format" => "graphite")
|
260
|
+
}
|
261
|
+
let(:event) { LogStash::Event.new("host" => "myHost", "foo" => "fancy", "cpu1" => 0.24, "cpu2" => "abc", "cpu3" => 0.11) }
|
262
|
+
|
263
|
+
it "include all points" do
|
264
|
+
lines = result.split(/\n/).sort
|
265
|
+
expect(lines.length).to eq(2)
|
266
|
+
expect(lines.shift).to match(/^cpu1 0\.24 \d{10,}$/)
|
267
|
+
expect(lines.shift).to match(/^cpu3 0\.11 \d{10,}$/)
|
268
|
+
end
|
269
|
+
|
270
|
+
end # context
|
271
|
+
|
272
|
+
context "should build metrics payload with non-number value dropped (carbon2)" do
|
273
|
+
let(:stats) { LogStash::Outputs::SumoLogic::Statistics.new() }
|
274
|
+
let(:builder) {
|
275
|
+
LogStash::Outputs::SumoLogic::PayloadBuilder.new(stats,
|
276
|
+
"url" => "http://localhost/1234",
|
277
|
+
"metrics" => {
|
278
|
+
"cpu1" => "%{cpu1}",
|
279
|
+
"cpu2" => "%{cpu2}",
|
280
|
+
"cpu3" => "%{cpu3}"
|
281
|
+
},
|
282
|
+
"intrinsic_tags" => {
|
283
|
+
"host" => "%{host}"
|
284
|
+
},
|
285
|
+
"metrics_name" => "mynamespace.*",
|
286
|
+
"meta_tags" => {
|
287
|
+
"foo" => "%{foo}"
|
288
|
+
})
|
289
|
+
}
|
290
|
+
let(:event) { LogStash::Event.new("host" => "myHost", "foo" => "fancy", "cpu1" => 0.24, "cpu2" => "abc", "cpu3" => 0.11) }
|
291
|
+
|
292
|
+
specify {
|
293
|
+
lines = result.split(/\n/).sort
|
294
|
+
expect(lines.length).to eq(2)
|
295
|
+
expect(lines.shift).to match(/^host=myHost metric=mynamespace\.cpu1 foo=fancy 0\.24 \d{10,}$/)
|
296
|
+
expect(lines.shift).to match(/^host=myHost metric=mynamespace\.cpu3 foo=fancy 0\.11 \d{10,}$/)
|
297
|
+
}
|
298
|
+
|
299
|
+
end # context
|
300
|
+
|
301
|
+
context "should build metrics payload with fields_as_metrics (graphite)" do
|
302
|
+
let(:stats) { LogStash::Outputs::SumoLogic::Statistics.new() }
|
303
|
+
let(:builder) {
|
304
|
+
LogStash::Outputs::SumoLogic::PayloadBuilder.new(stats,
|
305
|
+
"url" => "http://localhost/1234",
|
306
|
+
"fields_as_metrics" => true,
|
307
|
+
"metrics_format" => "graphite")
|
308
|
+
}
|
309
|
+
let(:event) {
|
310
|
+
LogStash::Event.new(
|
311
|
+
"host" => "myHost",
|
312
|
+
"foo" => "fancy",
|
313
|
+
"cpu" => [0.24, 0.11, 0.75, 0.28],
|
314
|
+
"storageRW" => 51,
|
315
|
+
"bar" => "blahblah",
|
316
|
+
"blkio" => {
|
317
|
+
"write_ps" => 0,
|
318
|
+
"read_ps" => 0,
|
319
|
+
"total_ps" => 0
|
320
|
+
})
|
321
|
+
}
|
322
|
+
|
323
|
+
specify {
|
324
|
+
lines = result.split(/\n/).sort
|
325
|
+
expect(lines.length).to eq(8)
|
326
|
+
expect(lines.shift).to match(/^blkio\.read_ps 0 \d{10,}$/)
|
327
|
+
expect(lines.shift).to match(/^blkio\.total_ps 0 \d{10,}$/)
|
328
|
+
expect(lines.shift).to match(/^blkio\.write_ps 0 \d{10,}$/)
|
329
|
+
expect(lines.shift).to match(/^cpu\.0 0\.24 \d{10,}$/)
|
330
|
+
expect(lines.shift).to match(/^cpu\.1 0\.11 \d{10,}$/)
|
331
|
+
expect(lines.shift).to match(/^cpu\.2 0\.75 \d{10,}$/)
|
332
|
+
expect(lines.shift).to match(/^cpu\.3 0\.28 \d{10,}$/)
|
333
|
+
expect(lines.shift).to match(/^storageRW 51 \d{10,}$/)
|
334
|
+
}
|
335
|
+
|
336
|
+
end # context
|
337
|
+
|
338
|
+
context "should build metrics payload with fields_as_metrics (carbon2)" do
|
339
|
+
let(:stats) { LogStash::Outputs::SumoLogic::Statistics.new() }
|
340
|
+
let(:builder) {
|
341
|
+
LogStash::Outputs::SumoLogic::PayloadBuilder.new(stats,
|
342
|
+
"url" => "http://localhost/1234",
|
343
|
+
"fields_as_metrics" => true,
|
344
|
+
"intrinsic_tags" => {
|
345
|
+
"host"=>"%{host}"
|
346
|
+
},
|
347
|
+
"meta_tags" => {
|
348
|
+
"foo" => "%{foo}"
|
349
|
+
})
|
350
|
+
}
|
351
|
+
let(:event) {
|
352
|
+
LogStash::Event.new(
|
353
|
+
"host" => "myHost",
|
354
|
+
"foo" => "fancy",
|
355
|
+
"cpu" => [0.24, 0.11, 0.75, 0.28],
|
356
|
+
"storageRW" => 51,
|
357
|
+
"bar" => "blahblah",
|
358
|
+
"blkio" => {
|
359
|
+
"write_ps" => 5,
|
360
|
+
"read_ps" => 2,
|
361
|
+
"total_ps" => 0
|
362
|
+
})
|
363
|
+
}
|
364
|
+
|
365
|
+
specify {
|
366
|
+
lines = result.split(/\n/).sort
|
367
|
+
expect(lines.length).to eq(8)
|
368
|
+
expect(lines.shift).to match(/^host=myHost metric=blkio\.read_ps foo=fancy 2 \d{10,}$/)
|
369
|
+
expect(lines.shift).to match(/^host=myHost metric=blkio\.total_ps foo=fancy 0 \d{10,}$/)
|
370
|
+
expect(lines.shift).to match(/^host=myHost metric=blkio\.write_ps foo=fancy 5 \d{10,}$/)
|
371
|
+
expect(lines.shift).to match(/^host=myHost metric=cpu\.0 foo=fancy 0\.24 \d{10,}$/)
|
372
|
+
expect(lines.shift).to match(/^host=myHost metric=cpu\.1 foo=fancy 0\.11 \d{10,}$/)
|
373
|
+
expect(lines.shift).to match(/^host=myHost metric=cpu\.2 foo=fancy 0\.75 \d{10,}$/)
|
374
|
+
expect(lines.shift).to match(/^host=myHost metric=cpu\.3 foo=fancy 0\.28 \d{10,}$/)
|
375
|
+
expect(lines.shift).to match(/^host=myHost metric=storageRW foo=fancy 51 \d{10,}$/)
|
376
|
+
}
|
377
|
+
|
378
|
+
end # context
|
379
|
+
|
380
|
+
context "should hornor fields_include when fields_as_metrics (graphite)" do
|
381
|
+
let(:stats) { LogStash::Outputs::SumoLogic::Statistics.new() }
|
382
|
+
let(:builder) {
|
383
|
+
LogStash::Outputs::SumoLogic::PayloadBuilder.new(stats,
|
384
|
+
"url" => "http://localhost/1234",
|
385
|
+
"fields_as_metrics" => true,
|
386
|
+
"metrics_format" => "graphite",
|
387
|
+
"fields_include" => ["cpu*"])
|
388
|
+
}
|
389
|
+
let(:event) {
|
390
|
+
LogStash::Event.new(
|
391
|
+
"host" => "myHost",
|
392
|
+
"foo" => "fancy",
|
393
|
+
"cpu" => [0.24, 0.11, 0.75, 0.28],
|
394
|
+
"storageRW" => 51,
|
395
|
+
"bar" => "blahblah",
|
396
|
+
"blkio" => {
|
397
|
+
"write_ps" => 5,
|
398
|
+
"read_ps" => 2,
|
399
|
+
"total_ps" => 0
|
400
|
+
})
|
401
|
+
}
|
402
|
+
|
403
|
+
specify {
|
404
|
+
lines = result.split(/\n/).sort
|
405
|
+
expect(lines.length).to eq(4)
|
406
|
+
expect(lines.shift).to match(/^cpu\.0 0\.24 \d{10,}$/)
|
407
|
+
expect(lines.shift).to match(/^cpu\.1 0\.11 \d{10,}$/)
|
408
|
+
expect(lines.shift).to match(/^cpu\.2 0\.75 \d{10,}$/)
|
409
|
+
expect(lines.shift).to match(/^cpu\.3 0\.28 \d{10,}$/)
|
410
|
+
}
|
411
|
+
|
412
|
+
end # context
|
413
|
+
|
414
|
+
context "should hornor fields_include when fields_as_metrics (carbon2)" do
|
415
|
+
let(:stats) { LogStash::Outputs::SumoLogic::Statistics.new() }
|
416
|
+
let(:builder) {
|
417
|
+
LogStash::Outputs::SumoLogic::PayloadBuilder.new(stats,
|
418
|
+
"url" => "http://localhost/1234",
|
419
|
+
"fields_as_metrics" => true,
|
420
|
+
"intrinsic_tags" => {
|
421
|
+
"host" => "%{host}"
|
422
|
+
},
|
423
|
+
"meta_tags" => {
|
424
|
+
"foo" => "%{foo}"
|
425
|
+
},
|
426
|
+
"fields_include" => ["cpu*"])
|
427
|
+
}
|
428
|
+
let(:event) {
|
429
|
+
LogStash::Event.new(
|
430
|
+
"host" => "myHost",
|
431
|
+
"foo" => "fancy",
|
432
|
+
"cpu" => [0.24, 0.11, 0.75, 0.28],
|
433
|
+
"storageRW" => 51,
|
434
|
+
"bar" => "blahblah",
|
435
|
+
"blkio" => {
|
436
|
+
"write_ps" => 5,
|
437
|
+
"read_ps" => 2,
|
438
|
+
"total_ps" => 0
|
439
|
+
})
|
440
|
+
}
|
441
|
+
|
442
|
+
specify {
|
443
|
+
lines = result.split(/\n/).sort
|
444
|
+
expect(lines.length).to eq(4)
|
445
|
+
expect(lines.shift).to match(/^host=myHost metric=cpu\.0 foo=fancy 0\.24 \d{10,}$/)
|
446
|
+
expect(lines.shift).to match(/^host=myHost metric=cpu\.1 foo=fancy 0\.11 \d{10,}$/)
|
447
|
+
expect(lines.shift).to match(/^host=myHost metric=cpu\.2 foo=fancy 0\.75 \d{10,}$/)
|
448
|
+
expect(lines.shift).to match(/^host=myHost metric=cpu\.3 foo=fancy 0\.28 \d{10,}$/)
|
449
|
+
}
|
450
|
+
|
451
|
+
end # context
|
452
|
+
|
453
|
+
context "should hornor fields_exclude when fields_as_metrics (graphite)" do
|
454
|
+
let(:stats) { LogStash::Outputs::SumoLogic::Statistics.new() }
|
455
|
+
let(:builder) {
|
456
|
+
LogStash::Outputs::SumoLogic::PayloadBuilder.new(stats,
|
457
|
+
"url" => "http://localhost/1234",
|
458
|
+
"fields_as_metrics" => true,
|
459
|
+
"metrics_format" => "graphite",
|
460
|
+
"fields_include" => ["cpu*"],
|
461
|
+
"fields_exclude" => [".*1"])
|
462
|
+
}
|
463
|
+
let(:event) { LogStash::Event.new(
|
464
|
+
"host" => "myHost",
|
465
|
+
"foo" => "fancy",
|
466
|
+
"cpu" => [0.24, 0.11, 0.75, 0.28],
|
467
|
+
"storageRW" => 51,
|
468
|
+
"bar" => "blahblah",
|
469
|
+
"blkio" => {
|
470
|
+
"write_ps" => 5,
|
471
|
+
"read_ps" => 2,
|
472
|
+
"total_ps" => 0
|
473
|
+
})}
|
474
|
+
|
475
|
+
specify {
|
476
|
+
lines = result.split(/\n/).sort
|
477
|
+
expect(lines.length).to eq(3)
|
478
|
+
expect(lines.shift).to match(/^cpu\.0 0\.24 \d{10,}$/)
|
479
|
+
expect(lines.shift).to match(/^cpu\.2 0\.75 \d{10,}$/)
|
480
|
+
expect(lines.shift).to match(/^cpu\.3 0\.28 \d{10,}$/)
|
481
|
+
}
|
482
|
+
|
483
|
+
end # context
|
484
|
+
|
485
|
+
context "should hornor fields_exclude when fields_as_metrics (carbon2)" do
|
486
|
+
let(:stats) { LogStash::Outputs::SumoLogic::Statistics.new() }
|
487
|
+
let(:builder) {
|
488
|
+
LogStash::Outputs::SumoLogic::PayloadBuilder.new(stats,
|
489
|
+
"url" => "http://localhost/1234",
|
490
|
+
"fields_as_metrics" => true,
|
491
|
+
"intrinsic_tags" => {
|
492
|
+
"host" => "%{host}"
|
493
|
+
},
|
494
|
+
"meta_tags" => {
|
495
|
+
"foo" => "%{foo}"
|
496
|
+
},
|
497
|
+
"fields_include" => ["cpu*"],
|
498
|
+
"fields_exclude" => [".*1"])
|
499
|
+
}
|
500
|
+
let(:event) { LogStash::Event.new(
|
501
|
+
"host" => "myHost",
|
502
|
+
"foo" => "fancy",
|
503
|
+
"cpu" => [0.24, 0.11, 0.75, 0.28],
|
504
|
+
"storageRW" => 51,
|
505
|
+
"bar" => "blahblah",
|
506
|
+
"blkio" => {
|
507
|
+
"write_ps" => 5,
|
508
|
+
"read_ps" => 2,
|
509
|
+
"total_ps" => 0
|
510
|
+
})}
|
511
|
+
|
512
|
+
specify {
|
513
|
+
lines = result.split(/\n/).sort
|
514
|
+
expect(lines.length).to eq(3)
|
515
|
+
expect(lines.shift).to match(/^host=myHost metric=cpu\.0 foo=fancy 0\.24 \d{10,}$/)
|
516
|
+
expect(lines.shift).to match(/^host=myHost metric=cpu\.2 foo=fancy 0\.75 \d{10,}$/)
|
517
|
+
expect(lines.shift).to match(/^host=myHost metric=cpu\.3 foo=fancy 0\.28 \d{10,}$/)
|
518
|
+
}
|
519
|
+
|
520
|
+
end # context
|
521
|
+
|
522
|
+
end # describe
|