fluent-plugin-honeycomb 0.2.1 → 0.3.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: f396ee93f9c4da4f5257d4ded3d7e7ca01b5244a
4
- data.tar.gz: dda4097017d124e85433ace06f9dc409d5997f8e
3
+ metadata.gz: 7e07c854e49e43c551912620986819f05ebc5baf
4
+ data.tar.gz: 1bdc374296b406cd6451d88acc8d347ff492191b
5
5
  SHA512:
6
- metadata.gz: 95b38a3691f8ac6f554544dc9ee4d462d45d4e2a4affc6b61bfc730eee3cb803d4f7e3deaec11bd424c6477eb6661ece0c03b43da936e08eb58bc45ff1088da8
7
- data.tar.gz: 04c5f7435acfe97b82e2ff98a0a10e1da8d7fc4781083565dd4edbf6ed10f85fe5e08314f94fefb1921bfe903bad7c5c3d544a9f6dfabb63a3de15fb24bb2baa
6
+ metadata.gz: 548c3f9da7fcc5ef224d3f135f19c2229bfa11e3d3f8cf92a61e8728fde7c1eada8384a84d86431719d8f42154ff67447a875c50075e8a82bf0e144a4feb8386
7
+ data.tar.gz: a2eb30693c368e706f4b8488a803ccfdee2028b36c8d24a8ddd3141fdd2eaf92b229cb3bcd93663e81734636e46686f4891cda8ff9f82b1a34c20e72720aa3f2
data/README.md CHANGED
@@ -27,6 +27,9 @@ 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
33
 
31
34
  ### Buffering options
32
35
 
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = 'fluent-plugin-honeycomb'
3
- spec.version = '0.2.1'
3
+ spec.version = '0.3.0'
4
4
  spec.date = '2017-02-07'
5
5
 
6
6
  spec.summary = "Fluentd output plugin for Honeycomb.io"
@@ -16,6 +16,7 @@ module Fluent
16
16
  config_param :include_tag_key, :bool, :default => false
17
17
  config_param :tag_key, :string, :default => "fluentd_tag"
18
18
  config_param :api_host, :string, :default => "https://api.honeycomb.io"
19
+ config_param :flatten_keys, :array, value_type: :string, :default => []
19
20
 
20
21
  # This method is called before starting.
21
22
  # 'conf' is a Hash that includes configuration parameters.
@@ -57,11 +58,16 @@ module Fluent
57
58
  log.debug "Skipping record #{record}"
58
59
  next
59
60
  end
61
+ if @sample_rate > 1 && rand(1..@sample_rate) == 1
62
+ next
63
+ end
60
64
  if @include_tag_key
61
65
  record[@tag_key] = tag
62
66
  end
63
- if @sample_rate > 1 && rand(1..@sample_rate) == 1
64
- next
67
+ @flatten_keys.each do |k|
68
+ next unless record[k].is_a?(Hash)
69
+ record.merge!(flatten(record[k], k))
70
+ record.delete(k)
65
71
  end
66
72
  batch.push({
67
73
  "data" => record,
@@ -124,5 +130,17 @@ module Fluent
124
130
  end
125
131
  end
126
132
  end
133
+
134
+ def flatten(record, prefix)
135
+ ret = {}
136
+ if record.is_a? Hash
137
+ record.each { |key, value|
138
+ ret.merge! flatten(value, "#{prefix}.#{key.to_s}")
139
+ }
140
+ else
141
+ return {prefix => record}
142
+ end
143
+ ret
144
+ end
127
145
  end
128
146
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-honeycomb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - The Honeycomb.io Team