fluent-plugin-honeycomb 0.4.2 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +12 -8
- data/fluent-plugin-honeycomb.gemspec +1 -1
- data/lib/fluent/plugin/out_honeycomb.rb +19 -7
- data/lib/fluent/plugin/out_honeycomb_version.rb +2 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7083d11330f158765d8eb1e0079b7e50b1c0f979
|
4
|
+
data.tar.gz: a25a7b1023946e9c3a28dbdfb700bf3046f48717
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7be1985ff4cbe433a9fd29b3e97dfb9ffe92eab9be59089f27177081fcea34be4341aa9a8dbe310bf1c11fc5f6caa5494d78358d6a01d3d88216dc6de017ce73
|
7
|
+
data.tar.gz: c8515220ffb762a2b3942795afb55460db2c2a41f64ae7a9c9b9f98d1ba22a52af110b29fcf1847004e7afce3a6fbe4203a1a0c79a271651372e7476652d43ce
|
data/README.md
CHANGED
@@ -27,9 +27,8 @@ Parameter | Type | Required? | Description
|
|
27
27
|
| `sample_rate` | integer | no | Sample your event stream by sending 1 out of every N events. |
|
28
28
|
| `include_tag_key` | bool | no | Whether to include the Fluentd tag in the submitted event. |
|
29
29
|
| `tag_key` | string | no | If `include_tag_key` is `true`, the tag key name in the event (default: `fluentd_tag`).
|
30
|
-
| `flatten_keys` | array | no | Flatten nested JSON data under these keys into
|
31
|
-
the
|
32
|
-
|
30
|
+
| `flatten_keys` | array | no | Flatten nested JSON data under these keys into the top-level event.
|
31
|
+
| `dataset_from_key` | string | no | Look for this key in each event, and use its value as the destination dataset. If an event doesn't contain the key, it'll be sent to the dataset given by the `dataset` parameter.
|
33
32
|
|
34
33
|
### Buffering options
|
35
34
|
|
@@ -55,8 +54,13 @@ A note about naming: This gem must be named `fluent-plugin-xxx` in order to auto
|
|
55
54
|
|
56
55
|
## Releasing a new version
|
57
56
|
Travis will automatically upload tagged releases to Rubygems. To release a new
|
58
|
-
version
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
57
|
+
version:
|
58
|
+
|
59
|
+
1. Update the value of `HONEYCOMB_PLUGIN_VERSION` in
|
60
|
+
lib/plugin/out_honeycomb_version.rb`
|
61
|
+
|
62
|
+
2. Run
|
63
|
+
```
|
64
|
+
bump patch --tag # Or bump minor --tag, etc.
|
65
|
+
git push --follow-tags
|
66
|
+
```
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'json'
|
2
2
|
require 'http'
|
3
3
|
require 'fluent/output'
|
4
|
+
require_relative 'out_honeycomb_version'
|
4
5
|
|
5
6
|
module Fluent
|
6
7
|
class HoneycombOutput < BufferedOutput
|
@@ -17,6 +18,7 @@ module Fluent
|
|
17
18
|
config_param :tag_key, :string, :default => "fluentd_tag"
|
18
19
|
config_param :api_host, :string, :default => "https://api.honeycomb.io"
|
19
20
|
config_param :flatten_keys, :array, value_type: :string, :default => []
|
21
|
+
config_param :dataset_from_key, :string, :default => ""
|
20
22
|
|
21
23
|
# This method is called before starting.
|
22
24
|
# 'conf' is a Hash that includes configuration parameters.
|
@@ -55,7 +57,7 @@ module Fluent
|
|
55
57
|
#
|
56
58
|
# NOTE! This method is called by internal thread, not Fluentd's main thread. So IO wait doesn't affect other plugins.
|
57
59
|
def write(chunk)
|
58
|
-
|
60
|
+
batches = Hash.new{ |h, k| h[k] = [] }
|
59
61
|
chunk.msgpack_each do |(tag, time, record)|
|
60
62
|
if !record.is_a? Hash
|
61
63
|
log.debug "Skipping record #{record}"
|
@@ -72,6 +74,14 @@ module Fluent
|
|
72
74
|
record.merge!(flatten(record[k], k))
|
73
75
|
record.delete(k)
|
74
76
|
end
|
77
|
+
|
78
|
+
if (@dataset_from_key != "" && record.has_key?(@dataset_from_key))
|
79
|
+
dataset = record[@dataset_from_key]
|
80
|
+
record.delete @dataset_from_key
|
81
|
+
else
|
82
|
+
dataset = @dataset
|
83
|
+
end
|
84
|
+
batch = batches[dataset]
|
75
85
|
batch.push({
|
76
86
|
"data" => record,
|
77
87
|
"samplerate" => @sample_rate,
|
@@ -79,27 +89,29 @@ module Fluent
|
|
79
89
|
})
|
80
90
|
end
|
81
91
|
|
82
|
-
|
92
|
+
batches.each do |dataset, batch|
|
93
|
+
publish_batch(dataset, batch, 0)
|
94
|
+
end
|
83
95
|
end
|
84
96
|
|
85
|
-
def publish_batch(batch, retry_count)
|
97
|
+
def publish_batch(dataset, batch, retry_count)
|
86
98
|
if batch.length == 0
|
87
99
|
return
|
88
100
|
end
|
89
|
-
log.info "publishing #{batch.length} records"
|
101
|
+
log.info "publishing #{batch.length} records to dataset #{dataset}"
|
90
102
|
body = JSON.dump(batch)
|
91
103
|
resp = HTTP.headers(
|
92
|
-
"User-Agent" => "fluent-plugin-honeycomb",
|
104
|
+
"User-Agent" => "fluent-plugin-honeycomb/#{HONEYCOMB_PLUGIN_VERSION}",
|
93
105
|
"Content-Type" => "application/json",
|
94
106
|
"X-Honeycomb-Team" => @writekey)
|
95
|
-
.post(URI.join(@api_host, "/1/batch/#{
|
107
|
+
.post(URI.join(@api_host, "/1/batch/#{dataset}"), {
|
96
108
|
:body => body,
|
97
109
|
})
|
98
110
|
failures = parse_response(batch, resp)
|
99
111
|
if failures.size > 0 && retry_count < @retry_limit
|
100
112
|
# sleep and retry with the set of failed events
|
101
113
|
sleep 1
|
102
|
-
publish_batch(failures, retry_count + 1)
|
114
|
+
publish_batch(dataset, failures, retry_count + 1)
|
103
115
|
end
|
104
116
|
end
|
105
117
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-honeycomb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- The Honeycomb.io Team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-10-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fluentd
|
@@ -164,6 +164,7 @@ files:
|
|
164
164
|
- Rakefile
|
165
165
|
- fluent-plugin-honeycomb.gemspec
|
166
166
|
- lib/fluent/plugin/out_honeycomb.rb
|
167
|
+
- lib/fluent/plugin/out_honeycomb_version.rb
|
167
168
|
homepage: https://github.com/honeycombio/fluent-plugin-honeycomb
|
168
169
|
licenses:
|
169
170
|
- Apache-2.0
|
@@ -184,7 +185,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
184
185
|
version: '0'
|
185
186
|
requirements: []
|
186
187
|
rubyforge_project:
|
187
|
-
rubygems_version: 2.
|
188
|
+
rubygems_version: 2.6.14
|
188
189
|
signing_key:
|
189
190
|
specification_version: 4
|
190
191
|
summary: Fluentd output plugin for Honeycomb.io
|