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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4327708ee0469056f9c618d2d35ebff5981436bd
4
- data.tar.gz: adad738e9a96926e5bb39e8975520d3b55732f80
3
+ metadata.gz: 7083d11330f158765d8eb1e0079b7e50b1c0f979
4
+ data.tar.gz: a25a7b1023946e9c3a28dbdfb700bf3046f48717
5
5
  SHA512:
6
- metadata.gz: 87c309c3d1c33c837d4b431b50787093d544491222cc125a7cf5d3fa6fee3353cc9ceca727f25b515df5471b7c6a27160419fbcbfb2bcb6ff0f7dd74ba5cc0ed
7
- data.tar.gz: 084e70f13259e597560dd85089a15f791485e605cc12282a29518cce979636277db5f7aaed1a0a409ab89087a9d3d58fc9f4d007fe7fbbbd2ce89d1556d9edf9
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 top-level event.
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, run
59
- ```
60
- bump patch --tag # Or bump minor --tag, etc.
61
- git push --follow-tags
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,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = 'fluent-plugin-honeycomb'
3
- spec.version = '0.4.2'
3
+ spec.version = '0.5.0'
4
4
 
5
5
  spec.summary = "Fluentd output plugin for Honeycomb.io"
6
6
  spec.description = "Fluentd output plugin for Honeycomb.io"
@@ -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
- batch = []
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
- publish_batch(batch, 0)
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/#{@dataset}"), {
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
 
@@ -0,0 +1,2 @@
1
+ # Don't just call this VERSION, conflicts with global fluentd version constant
2
+ HONEYCOMB_PLUGIN_VERSION = "0.5.0"
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.2
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-08-30 00:00:00.000000000 Z
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.4.5
188
+ rubygems_version: 2.6.14
188
189
  signing_key:
189
190
  specification_version: 4
190
191
  summary: Fluentd output plugin for Honeycomb.io