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 +4 -4
- data/README.md +3 -0
- data/fluent-plugin-honeycomb.gemspec +1 -1
- data/lib/fluent/plugin/out_honeycomb.rb +20 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7e07c854e49e43c551912620986819f05ebc5baf
|
4
|
+
data.tar.gz: 1bdc374296b406cd6451d88acc8d347ff492191b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
|
@@ -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
|
-
|
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
|