logstash-output-honeycomb_json_batch 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +33 -0
- data/lib/logstash/outputs/honeycomb_json_batch.rb +20 -9
- data/logstash-output-honeycomb_json_batch.gemspec +1 -1
- data/spec/outputs/honeycomb_json_batch_spec.rb +16 -0
- metadata +30 -32
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c90c885174ae440377b402eac734980422d3192d
|
4
|
+
data.tar.gz: c6e29760a336290dece1dd18bbc33f10b2b2fd2d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b9c755b2655e7218d4141c822a0a784cc1fc6006f943c891c1d7d2a993ce2f1c7436717dca1c860a9e016ce8cde6355f4a4c8f98647240d4951b855fca7986d1
|
7
|
+
data.tar.gz: 6584d584c082375794988dd6cbe94c4410acc89d478c760ff62c03de8f5817421b4e358f6a6d4956285ada7c8da390441f0d2f09c880aab910fcf168cea49866
|
data/README.md
CHANGED
@@ -34,6 +34,39 @@ output {
|
|
34
34
|
}
|
35
35
|
```
|
36
36
|
|
37
|
+
Additional arguments to `honeycomb_json_batch`:
|
38
|
+
|
39
|
+
Consider these when tuning performance:
|
40
|
+
|
41
|
+
- `flush_size`: Default batch size, defaults to 50
|
42
|
+
- `idle_flush_time`: Default flush interval in seconds, defaults to 5
|
43
|
+
- `pool_max`: Maximum number of requests to be run in parallel, defaults to 10
|
44
|
+
- `retry_individual`: On failed requests, whether to retry event sends individually, defaults to true
|
45
|
+
- `api_host`: Allows you to override the Honeycomb host, defaults to https://api.honeycomb.io
|
46
|
+
|
47
|
+
Special logstash fields that will be extracted:
|
48
|
+
|
49
|
+
- `@timestamp`: Logstash events contain timestamps by default, and this output will extract it for use as the Honeycomb timestamp
|
50
|
+
- `@samplerate`: If this special field is populated (e.g. via the `filter` section, this particular event will be weighted as `@samplerate` events in Honeycomb). See the **Sampling** section below.
|
51
|
+
|
52
|
+
### Sampling
|
53
|
+
|
54
|
+
High volume sites may want to send only a fraction of all traffic to Honeycomb. The drop filter can drop a portion of your traffic, and a mutate filter will ensure that Honeycomb understands that transmitted events are coming through as the result of sampling.
|
55
|
+
|
56
|
+
```
|
57
|
+
filter {
|
58
|
+
drop {
|
59
|
+
# keep 1/4 of the event stream
|
60
|
+
percentage => 75
|
61
|
+
}
|
62
|
+
mutate {
|
63
|
+
add_field => {
|
64
|
+
# the events that do make it through represent 4 events
|
65
|
+
"@samplerate" => "4"
|
66
|
+
}
|
67
|
+
}
|
68
|
+
}
|
69
|
+
```
|
37
70
|
|
38
71
|
## Development
|
39
72
|
|
@@ -12,7 +12,6 @@ class LogStash::Outputs::HoneycombJSONBatch < LogStash::Outputs::Base
|
|
12
12
|
|
13
13
|
config_name "honeycomb_json_batch"
|
14
14
|
|
15
|
-
# URL host to use, defaults to https://api.honeycomb.io
|
16
15
|
config :api_host, :validate => :string
|
17
16
|
|
18
17
|
config :write_key, :validate => :string, :required => true
|
@@ -25,7 +24,7 @@ class LogStash::Outputs::HoneycombJSONBatch < LogStash::Outputs::Base
|
|
25
24
|
|
26
25
|
config :retry_individual, :validate => :boolean, :default => true
|
27
26
|
|
28
|
-
config :pool_max, :validate => :number, :default =>
|
27
|
+
config :pool_max, :validate => :number, :default => 10
|
29
28
|
|
30
29
|
def register
|
31
30
|
# We count outstanding requests with this queue
|
@@ -64,6 +63,11 @@ class LogStash::Outputs::HoneycombJSONBatch < LogStash::Outputs::Base
|
|
64
63
|
buffer_receive(event)
|
65
64
|
end
|
66
65
|
|
66
|
+
def close
|
67
|
+
buffer_flush(:final => true)
|
68
|
+
client.close
|
69
|
+
end
|
70
|
+
|
67
71
|
public
|
68
72
|
def flush(events, close=false)
|
69
73
|
documents = [] #this is the array of hashes that we push to Fusion as documents
|
@@ -71,7 +75,11 @@ class LogStash::Outputs::HoneycombJSONBatch < LogStash::Outputs::Base
|
|
71
75
|
events.each do |event|
|
72
76
|
data = event.to_hash()
|
73
77
|
timestamp = data.delete("@timestamp")
|
74
|
-
|
78
|
+
doc = { "time" => timestamp, "data" => data }
|
79
|
+
if samplerate = data.delete("@samplerate")
|
80
|
+
doc["samplerate"] = samplerate.to_i
|
81
|
+
end
|
82
|
+
documents.push(doc)
|
75
83
|
end
|
76
84
|
|
77
85
|
make_request(documents)
|
@@ -116,8 +124,11 @@ class LogStash::Outputs::HoneycombJSONBatch < LogStash::Outputs::Base
|
|
116
124
|
:total => @total)
|
117
125
|
else
|
118
126
|
if documents.length > 1 && @retry_individual
|
119
|
-
|
120
|
-
|
127
|
+
if statuses = JSON.parse(response.body).values.first
|
128
|
+
status.each_with_index do |status, i|
|
129
|
+
next if status >= 200 && status < 300
|
130
|
+
make_request([documents[i]])
|
131
|
+
end
|
121
132
|
end
|
122
133
|
else
|
123
134
|
@total_failed += documents.length
|
@@ -147,14 +158,14 @@ class LogStash::Outputs::HoneycombJSONBatch < LogStash::Outputs::Base
|
|
147
158
|
)
|
148
159
|
end
|
149
160
|
|
150
|
-
|
151
|
-
|
152
|
-
|
161
|
+
client.execute!
|
162
|
+
rescue Exception => e
|
163
|
+
log_failure("Got totally unexpected exception #{e.message}", :docs => documents.length)
|
153
164
|
end
|
154
165
|
|
155
166
|
# This is split into a separate method mostly to help testing
|
156
167
|
def log_failure(message, opts)
|
157
|
-
@logger.error("[
|
168
|
+
@logger.error("[Honeycomb Batch Output Failure] #{message}", opts)
|
158
169
|
end
|
159
170
|
|
160
171
|
def request_headers()
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'logstash-output-honeycomb_json_batch'
|
3
|
-
s.version = '0.1.
|
3
|
+
s.version = '0.1.2'
|
4
4
|
s.licenses = ['Apache-2.0']
|
5
5
|
s.summary = "This output lets you `POST` batches of events to the Honeycomb.io API endpoint"
|
6
6
|
s.description = "This gem is a Logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/logstash-plugin install gemname. This gem is not a stand-alone program"
|
@@ -76,6 +76,22 @@ describe LogStash::Outputs::HoneycombJSONBatch do
|
|
76
76
|
@honeycomb.buffer_flush(:force => true)
|
77
77
|
end
|
78
78
|
|
79
|
+
it "should extract timestamp and samplerate from the data" do
|
80
|
+
with_samplerate = LogStash::Event.new("alpha" => 1.0, "@samplerate" => "17.5")
|
81
|
+
data = with_samplerate.to_hash()
|
82
|
+
data.delete("@timestamp")
|
83
|
+
data.delete("@samplerate")
|
84
|
+
|
85
|
+
expect(client).to receive(:post).
|
86
|
+
with("#{ api_host }/1/batch", hash_including(:body => LogStash::Json.dump({
|
87
|
+
DATASET => [ { "time" => event.timestamp.to_s, "data" => data, "samplerate" => 17 } ]
|
88
|
+
}))).once.
|
89
|
+
and_call_original
|
90
|
+
|
91
|
+
@honeycomb.receive(with_samplerate)
|
92
|
+
@honeycomb.buffer_flush(:force => true)
|
93
|
+
end
|
94
|
+
|
79
95
|
it "should wrap multiple events up in the right structure" do
|
80
96
|
event1 = LogStash::Event.new("alpha" => 1.0)
|
81
97
|
event2 = LogStash::Event.new("beta" => 2.0)
|
metadata
CHANGED
@@ -1,107 +1,105 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstash-output-honeycomb_json_batch
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Honeycomb
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-02-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name: logstash-core-plugin-api
|
15
14
|
requirement: !ruby/object:Gem::Requirement
|
16
15
|
requirements:
|
17
|
-
- -
|
16
|
+
- - ">="
|
18
17
|
- !ruby/object:Gem::Version
|
19
18
|
version: '1.60'
|
20
|
-
- - <=
|
19
|
+
- - "<="
|
21
20
|
- !ruby/object:Gem::Version
|
22
21
|
version: '2.99'
|
23
|
-
|
22
|
+
name: logstash-core-plugin-api
|
24
23
|
prerelease: false
|
24
|
+
type: :runtime
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
|
-
- -
|
27
|
+
- - ">="
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
version: '1.60'
|
30
|
-
- - <=
|
30
|
+
- - "<="
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: '2.99'
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
|
-
name: logstash-mixin-http_client
|
35
34
|
requirement: !ruby/object:Gem::Requirement
|
36
35
|
requirements:
|
37
|
-
- -
|
36
|
+
- - ">="
|
38
37
|
- !ruby/object:Gem::Version
|
39
38
|
version: 2.2.1
|
40
|
-
- - <
|
39
|
+
- - "<"
|
41
40
|
- !ruby/object:Gem::Version
|
42
41
|
version: 5.0.0
|
43
|
-
|
42
|
+
name: logstash-mixin-http_client
|
44
43
|
prerelease: false
|
44
|
+
type: :runtime
|
45
45
|
version_requirements: !ruby/object:Gem::Requirement
|
46
46
|
requirements:
|
47
|
-
- -
|
47
|
+
- - ">="
|
48
48
|
- !ruby/object:Gem::Version
|
49
49
|
version: 2.2.1
|
50
|
-
- - <
|
50
|
+
- - "<"
|
51
51
|
- !ruby/object:Gem::Version
|
52
52
|
version: 5.0.0
|
53
53
|
- !ruby/object:Gem::Dependency
|
54
|
-
name: logstash-devutils
|
55
54
|
requirement: !ruby/object:Gem::Requirement
|
56
55
|
requirements:
|
57
|
-
- -
|
56
|
+
- - ">="
|
58
57
|
- !ruby/object:Gem::Version
|
59
58
|
version: '0'
|
60
|
-
|
59
|
+
name: logstash-devutils
|
61
60
|
prerelease: false
|
61
|
+
type: :development
|
62
62
|
version_requirements: !ruby/object:Gem::Requirement
|
63
63
|
requirements:
|
64
|
-
- -
|
64
|
+
- - ">="
|
65
65
|
- !ruby/object:Gem::Version
|
66
66
|
version: '0'
|
67
|
-
description: This gem is a Logstash plugin required to be installed on top of the
|
68
|
-
Logstash core pipeline using $LS_HOME/bin/logstash-plugin install gemname. This
|
69
|
-
gem is not a stand-alone program
|
67
|
+
description: This gem is a Logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/logstash-plugin install gemname. This gem is not a stand-alone program
|
70
68
|
email: support@honeycomb.io
|
71
69
|
executables: []
|
72
70
|
extensions: []
|
73
71
|
extra_rdoc_files: []
|
74
72
|
files:
|
75
|
-
- lib/logstash/outputs/honeycomb_json_batch.rb
|
76
|
-
- spec/outputs/honeycomb_json_batch_spec.rb
|
77
|
-
- logstash-output-honeycomb_json_batch.gemspec
|
78
|
-
- README.md
|
79
73
|
- Gemfile
|
80
74
|
- LICENSE
|
75
|
+
- README.md
|
76
|
+
- lib/logstash/outputs/honeycomb_json_batch.rb
|
77
|
+
- logstash-output-honeycomb_json_batch.gemspec
|
78
|
+
- spec/outputs/honeycomb_json_batch_spec.rb
|
81
79
|
homepage: https://honeycomb.io
|
82
80
|
licenses:
|
83
81
|
- Apache-2.0
|
84
82
|
metadata:
|
85
83
|
logstash_plugin: 'true'
|
86
84
|
logstash_group: output
|
87
|
-
post_install_message:
|
85
|
+
post_install_message:
|
88
86
|
rdoc_options: []
|
89
87
|
require_paths:
|
90
88
|
- lib
|
91
89
|
required_ruby_version: !ruby/object:Gem::Requirement
|
92
90
|
requirements:
|
93
|
-
- -
|
91
|
+
- - ">="
|
94
92
|
- !ruby/object:Gem::Version
|
95
93
|
version: '0'
|
96
94
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
97
95
|
requirements:
|
98
|
-
- -
|
96
|
+
- - ">="
|
99
97
|
- !ruby/object:Gem::Version
|
100
98
|
version: '0'
|
101
99
|
requirements: []
|
102
|
-
rubyforge_project:
|
103
|
-
rubygems_version: 2.
|
104
|
-
signing_key:
|
100
|
+
rubyforge_project:
|
101
|
+
rubygems_version: 2.6.8
|
102
|
+
signing_key:
|
105
103
|
specification_version: 4
|
106
104
|
summary: This output lets you `POST` batches of events to the Honeycomb.io API endpoint
|
107
105
|
test_files:
|