logstash-output-sumologic 1.3.1 → 1.3.2
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 +4 -4
- data/CHANGELOG.md +4 -0
- data/DEVELOPER.md +10 -4
- data/README.md +2 -1
- data/lib/logstash/outputs/sumologic.rb +2 -0
- data/lib/logstash/outputs/sumologic/common.rb +1 -0
- data/lib/logstash/outputs/sumologic/header_builder.rb +13 -0
- data/lib/logstash/outputs/sumologic/monitor.rb +4 -3
- data/lib/logstash/outputs/sumologic/sender.rb +1 -3
- data/logstash-output-sumologic.gemspec +1 -1
- data/spec/outputs/sumologic/header_builder_spec.rb +86 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0cb3e69cc8d33b60f981ee807b8deeab442bca032d5715df432d467d5a917b51
|
4
|
+
data.tar.gz: 4e1c485db70cace53f2c46b7fd089be90775e74d569ace0fd1462a98ffe7fed7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '0478381fc42c308038c921dcede8662f5c83147f618c34bf5acf1f9c07b693d3a3e95a0978f74dc8114217b7e1c8b0aff78e29feb2435b27d6b1618a116fddb1'
|
7
|
+
data.tar.gz: f8ba1e23876443e518d468f1f2c162f4053093fa251f870b0abd61528caea9c6fdef88dd86ba91278519ee7fd5baf352479e9d97386c8e9cbcf817b19c41e2c9
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## 1.3.2 (2021-02-03)
|
4
|
+
|
5
|
+
- [#60](https://github.com/SumoLogic/logstash-output-sumologic/pull/60) Fix plugin metrics not being sent
|
6
|
+
|
3
7
|
## 1.3.1 (2020-12-18)
|
4
8
|
|
5
9
|
- [#53](https://github.com/SumoLogic/logstash-output-sumologic/pull/53) Fix "undefined method `blank?'"
|
data/DEVELOPER.md
CHANGED
@@ -35,8 +35,7 @@ docker run --rm -it -e 'sumo_url=https://events.sumologic.net/receiver/v1/http/X
|
|
35
35
|
|
36
36
|
### Running on bare metal
|
37
37
|
|
38
|
-
The test requires JRuby to run.
|
39
|
-
And then run:
|
38
|
+
The test requires JRuby to run.
|
40
39
|
|
41
40
|
```bash
|
42
41
|
rvm use jruby
|
@@ -45,5 +44,12 @@ export sumo_url=https://events.sumologic.net/receiver/v1/http/XXXXXXXXXX
|
|
45
44
|
rspec spec/
|
46
45
|
```
|
47
46
|
|
48
|
-
|
49
|
-
|
47
|
+
## Continuous Integration
|
48
|
+
|
49
|
+
The project uses GitHub Actions for:
|
50
|
+
|
51
|
+
- Testing pull requests and main branch commits: [.github/workflows/ci.yml](.github/workflows/ci.yml)
|
52
|
+
- Publishing new version of gem to RubyGems.org after tagging: [.github/workflows/publish.yml](.github/workflows/publish.yml)
|
53
|
+
|
54
|
+
Before publishing a new version, make sure the RubyGems account has MFA disabled for API access.
|
55
|
+
Go to [Settings](https://rubygems.org/settings/edit) and set `MFA Level` to `UI only`.
|
data/README.md
CHANGED
@@ -112,6 +112,7 @@ Logon to Sumo Logic [web app](https://service.sumologic.com/) and run
|
|
112
112
|
| `fields_include` | array | No | all fields | Working with `fields_as_metrics` parameter, only the fields which full name matching these RegEx pattern(s) will be included in metrics.
|
113
113
|
| `fields_exclude` | array | No | none | Working with `fields_as_metrics` parameter, the fields which full name matching these RegEx pattern(s) will be ignored in metrics.
|
114
114
|
| `sleep_before_requeue` | number | No | `30` | The message failed to send to server will be retried after (x) seconds. Not retried if negative number set
|
115
|
+
| `stats_category` | string | No | `Logstash.stats` | The source category this plugin's stats will be sent with when `stats_enabled` is `true`
|
115
116
|
| `stats_enabled` | boolean | No | `false` | If `true`, stats of this plugin will be sent as metrics
|
116
117
|
| `stats_interval` | number | No | `60` | The stats will be sent every (x) seconds
|
117
118
|
|
@@ -136,7 +137,7 @@ On the other side, this version is marked as thread safe so if necessary, multip
|
|
136
137
|
|
137
138
|
### Monitor throughput in metrics
|
138
139
|
|
139
|
-
If your Sumo Logic account supports metrics feature, you can enable the stats monitor of this plugin with configuring `stats_enabled` to `true`. For every `stats_interval` seconds, a batch of metrics data points will be sent to Sumo Logic with source category
|
140
|
+
If your Sumo Logic account supports metrics feature, you can enable the stats monitor of this plugin with configuring `stats_enabled` to `true`. For every `stats_interval` seconds, a batch of metrics data points will be sent to Sumo Logic with source category specified by `stats_category` parameter:
|
140
141
|
|
141
142
|
| Metric | Description |
|
142
143
|
| ------------------------------- | ----------------------------------------------------------- |
|
@@ -105,6 +105,8 @@ class LogStash::Outputs::SumoLogic < LogStash::Outputs::Base
|
|
105
105
|
# For messages fail to send or get 429/503/504 response, try to resend after (x) seconds; don't resend if (x) < 0
|
106
106
|
config :sleep_before_requeue, :validate => :number, :default => 30
|
107
107
|
|
108
|
+
config :stats_category, :validate => :string, :default => CATEGORY_HEADER_DEFAULT_STATS
|
109
|
+
|
108
110
|
# Sending throughput data as metrics
|
109
111
|
config :stats_enabled, :validate => :boolean, :default => false
|
110
112
|
|
@@ -22,6 +22,7 @@ module LogStash; module Outputs; class SumoLogic;
|
|
22
22
|
|
23
23
|
CATEGORY_HEADER = "X-Sumo-Category"
|
24
24
|
CATEGORY_HEADER_DEFAULT = "Logstash"
|
25
|
+
CATEGORY_HEADER_DEFAULT_STATS = "Logstash.stats"
|
25
26
|
HOST_HEADER = "X-Sumo-Host"
|
26
27
|
NAME_HEADER = "X-Sumo-Name"
|
27
28
|
NAME_HEADER_DEFAULT = "logstash-output-sumologic"
|
@@ -11,6 +11,7 @@ module LogStash; module Outputs; class SumoLogic;
|
|
11
11
|
|
12
12
|
@extra_headers = config["extra_headers"] ||= {}
|
13
13
|
@source_category = config["source_category"] ||= CATEGORY_HEADER_DEFAULT
|
14
|
+
@stats_category = config["stats_category"] ||= CATEGORY_HEADER_DEFAULT_STATS
|
14
15
|
@source_host = config["source_host"] ||= Socket.gethostname
|
15
16
|
@source_name = config["source_name"] ||= NAME_HEADER_DEFAULT
|
16
17
|
@metrics = config["metrics"]
|
@@ -33,6 +34,18 @@ module LogStash; module Outputs; class SumoLogic;
|
|
33
34
|
headers
|
34
35
|
end # def build
|
35
36
|
|
37
|
+
def build_stats()
|
38
|
+
headers = Hash.new
|
39
|
+
headers.merge!(@extra_headers)
|
40
|
+
headers[CLIENT_HEADER] = CLIENT_HEADER_VALUE
|
41
|
+
headers[CATEGORY_HEADER] = @stats_category
|
42
|
+
headers[HOST_HEADER] = Socket.gethostname
|
43
|
+
headers[NAME_HEADER] = NAME_HEADER_DEFAULT
|
44
|
+
headers[CONTENT_TYPE] = CONTENT_TYPE_CARBON2
|
45
|
+
append_compress_header(headers)
|
46
|
+
headers
|
47
|
+
end # def build_stats
|
48
|
+
|
36
49
|
private
|
37
50
|
def append_content_header(headers)
|
38
51
|
contentType = CONTENT_TYPE_LOG
|
@@ -14,6 +14,7 @@ module LogStash; module Outputs; class SumoLogic;
|
|
14
14
|
@queue = queue
|
15
15
|
@stats = stats
|
16
16
|
@stopping = Concurrent::AtomicBoolean.new(false)
|
17
|
+
@header_builder = HeaderBuilder.new(config)
|
17
18
|
|
18
19
|
@enabled = config["stats_enabled"] ||= false
|
19
20
|
@interval = config["stats_interval"] ||= 60
|
@@ -27,8 +28,8 @@ module LogStash; module Outputs; class SumoLogic;
|
|
27
28
|
@monitor_t = Thread.new {
|
28
29
|
while @stopping.false?
|
29
30
|
Stud.stoppable_sleep(@interval) { @stopping.true? }
|
30
|
-
if @stats.
|
31
|
-
@queue.enq(build_stats_payload())
|
31
|
+
if @stats.total_log_lines.value > 0 || @stats.total_metrics_datapoints.value > 0
|
32
|
+
@queue.enq(Batch.new(@header_builder.build_stats(), build_stats_payload()))
|
32
33
|
end
|
33
34
|
end # while
|
34
35
|
}
|
@@ -73,4 +74,4 @@ module LogStash; module Outputs; class SumoLogic;
|
|
73
74
|
end # def build_metric_line
|
74
75
|
|
75
76
|
end
|
76
|
-
end; end; end
|
77
|
+
end; end; end
|
@@ -102,8 +102,6 @@ module LogStash; module Outputs; class SumoLogic;
|
|
102
102
|
|
103
103
|
if @stats_enabled && content.start_with?(STATS_TAG)
|
104
104
|
body = @compressor.compress(content[STATS_TAG.length..-1])
|
105
|
-
headers[CATEGORY_HEADER] = "#{headers[CATEGORY_HEADER]}.stats"
|
106
|
-
headers[CONTENT_TYPE] = CONTENT_TYPE_CARBON2
|
107
105
|
else
|
108
106
|
body = @compressor.compress(content)
|
109
107
|
end
|
@@ -169,4 +167,4 @@ module LogStash; module Outputs; class SumoLogic;
|
|
169
167
|
end # def reque_message
|
170
168
|
|
171
169
|
end
|
172
|
-
end; end; end
|
170
|
+
end; end; end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'logstash-output-sumologic'
|
3
|
-
s.version = '1.3.
|
3
|
+
s.version = '1.3.2'
|
4
4
|
s.licenses = ['Apache-2.0']
|
5
5
|
s.summary = 'Deliever the log to Sumo Logic cloud service.'
|
6
6
|
s.description = 'This gem is a Logstash output plugin to deliver the log or metrics to Sumo Logic cloud service. Go to https://github.com/SumoLogic/logstash-output-sumologic for getting help, reporting issues, etc.'
|
@@ -241,4 +241,90 @@ describe LogStash::Outputs::SumoLogic::HeaderBuilder do
|
|
241
241
|
|
242
242
|
end # context
|
243
243
|
|
244
|
+
context "should build headers for stats" do
|
245
|
+
let(:builder) {
|
246
|
+
LogStash::Outputs::SumoLogic::HeaderBuilder.new("url" => "http://localhost/1234")
|
247
|
+
}
|
248
|
+
|
249
|
+
specify {
|
250
|
+
stats_result = builder.build_stats()
|
251
|
+
expected = {
|
252
|
+
"X-Sumo-Client" => "logstash-output-sumologic",
|
253
|
+
"X-Sumo-Name" => "logstash-output-sumologic",
|
254
|
+
"X-Sumo-Host" => Socket.gethostname,
|
255
|
+
"X-Sumo-Category" => "Logstash.stats",
|
256
|
+
"Content-Type" => "application/vnd.sumologic.carbon2"
|
257
|
+
}
|
258
|
+
expect(stats_result).to eq(expected)
|
259
|
+
}
|
260
|
+
end
|
261
|
+
|
262
|
+
context "should build headers for stats with overridden source category" do
|
263
|
+
let(:builder) {
|
264
|
+
LogStash::Outputs::SumoLogic::HeaderBuilder.new("url" => "http://localhost/1234", "stats_category" => "custom")
|
265
|
+
}
|
266
|
+
|
267
|
+
specify {
|
268
|
+
stats_result = builder.build_stats()
|
269
|
+
expect(stats_result["X-Sumo-Category"]).to eq("custom")
|
270
|
+
}
|
271
|
+
end
|
272
|
+
|
273
|
+
context "should build headers for stats with compression" do
|
274
|
+
let(:builder) {
|
275
|
+
LogStash::Outputs::SumoLogic::HeaderBuilder.new("url" => "http://localhost/1234", "compress" => true, "compress_encoding" => "gzip")
|
276
|
+
}
|
277
|
+
|
278
|
+
specify {
|
279
|
+
stats_result = builder.build_stats()
|
280
|
+
expect(stats_result["Content-Encoding"]).to eq("gzip")
|
281
|
+
}
|
282
|
+
end
|
283
|
+
|
284
|
+
context "should build headers for stats with extra_headers" do
|
285
|
+
let(:builder) {
|
286
|
+
LogStash::Outputs::SumoLogic::HeaderBuilder.new(
|
287
|
+
"url" => "http://localhost/1234",
|
288
|
+
"extra_headers" => {
|
289
|
+
"foo" => "bar"
|
290
|
+
})
|
291
|
+
}
|
292
|
+
|
293
|
+
specify {
|
294
|
+
stats_result = builder.build_stats()
|
295
|
+
expect(stats_result.count).to eq(6)
|
296
|
+
expect(stats_result["foo"]).to eq("bar")
|
297
|
+
}
|
298
|
+
end
|
299
|
+
|
300
|
+
context "should build headers for stats with extra_headers but never overwrite pre-defined headers" do
|
301
|
+
|
302
|
+
let(:builder) {
|
303
|
+
LogStash::Outputs::SumoLogic::HeaderBuilder.new(
|
304
|
+
"url" => "http://localhost/1234",
|
305
|
+
"extra_headers" => {
|
306
|
+
"foo" => "bar",
|
307
|
+
"X-Sumo-Client" => "a",
|
308
|
+
"X-Sumo-Name" => "b",
|
309
|
+
"X-Sumo-Host" => "c",
|
310
|
+
"X-Sumo-Category" => "d",
|
311
|
+
"Content-Type" => "e"
|
312
|
+
})
|
313
|
+
}
|
314
|
+
|
315
|
+
specify {
|
316
|
+
stats_result = builder.build_stats()
|
317
|
+
expected = {
|
318
|
+
"foo" => "bar",
|
319
|
+
"X-Sumo-Client" => "logstash-output-sumologic",
|
320
|
+
"X-Sumo-Name" => "logstash-output-sumologic",
|
321
|
+
"X-Sumo-Host" => Socket.gethostname,
|
322
|
+
"X-Sumo-Category" => "Logstash.stats",
|
323
|
+
"Content-Type" => "application/vnd.sumologic.carbon2"
|
324
|
+
}
|
325
|
+
expect(stats_result).to eq(expected)
|
326
|
+
}
|
327
|
+
|
328
|
+
end # context
|
329
|
+
|
244
330
|
end # describe
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstash-output-sumologic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sumo Logic
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-02-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: manticore
|