fluent-plugin-kubernetes_metadata_filter 0.20.0 → 0.21.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: 5406b418d455a9baa0cd3ae7ea62cc271bb3c501
4
- data.tar.gz: ed73b4f32c33630d0ebbe441de8ca39ce85bf591
3
+ metadata.gz: b20a61e09187754c82416670f602ee2588399078
4
+ data.tar.gz: ff91664e2431bf6d419b9a9a4ef04367ce0d8dae
5
5
  SHA512:
6
- metadata.gz: cfc5fdb6c7872041f4663714fae3c22371a613eff290fd1e0bfdc647d6ee4667e43c798f8dfa9e7bd4f1a7bfa37250f8d5a9b00fe3097028ca5e39eb375c858a
7
- data.tar.gz: 949e6b18f786f4f3b267b43163834f1a689ed8c2e0226117ed2670db5984ef1a4cfbf2625bffdd77977d5e0096b97771a70e4f539b4c3020158b6941e22cf137
6
+ metadata.gz: 10d00af65128a6b779fb8aab70a39e0ac20d8cf6b3030514eec564d66e3297e04ea43689cf7296e55ab2174332c0d9aac11425bcc506459798c0820cc45ec4fa
7
+ data.tar.gz: 2bbd2911b66686211fefcf31f62a076b24b37b3784cf4998f1d5f7e5c9238adc2a1752dd8d9a3645762fbf912f787da3941d84b30d8056a9220ce04d24ed35b6
data/README.md CHANGED
@@ -24,6 +24,7 @@ This must used named capture groups for `container_name`, `pod_name` & `namespac
24
24
  * `cache_ttl` - TTL in seconds of each cached element. Set to negative value to disable TTL eviction (default: `3600` - 1 hour)
25
25
  * `watch` - set up a watch on pods on the API server for updates to metadata (default: `true`)
26
26
  * `merge_json_log` - merge logs in JSON format as top level keys (default: `true`)
27
+ * `preserve_json_log` - preserve JSON logs in raw form in the `log` key, only used if the previous option is true (default: `true`)
27
28
  * `de_dot` - replace dots in labels with configured `de_dot_separator`, required for ElasticSearch 2.x compatibility (default: `true`)
28
29
  * `de_dot_separator` - separator to use if `de_dot` is enabled (default: `_`)
29
30
 
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |gem|
6
6
  gem.name = "fluent-plugin-kubernetes_metadata_filter"
7
- gem.version = "0.20.0"
7
+ gem.version = "0.21.0"
8
8
  gem.authors = ["Jimmi Dyson"]
9
9
  gem.email = ["jimmidyson@gmail.com"]
10
10
  gem.description = %q{Filter plugin to add Kubernetes metadata}
@@ -37,6 +37,7 @@ module Fluent
37
37
  :default => 'var\.log\.containers\.(?<pod_name>[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*)_(?<namespace>[^_]+)_(?<container_name>.+)-(?<docker_id>[a-z0-9]{64})\.log$'
38
38
  config_param :bearer_token_file, :string, default: nil
39
39
  config_param :merge_json_log, :bool, default: true
40
+ config_param :preserve_json_log, :bool, default: true
40
41
  config_param :include_namespace_id, :bool, default: false
41
42
  config_param :secret_dir, :string, default: '/var/run/secrets/kubernetes.io/serviceaccount'
42
43
  config_param :de_dot, :bool, default: true
@@ -148,7 +149,7 @@ module Fluent
148
149
  begin
149
150
  @client.api_valid?
150
151
  rescue KubeException => kube_error
151
- raise Fluent::ConfigError, "Invalid Kubernetes API endpoint: #{kube_error.message}"
152
+ raise Fluent::ConfigError, "Invalid Kubernetes API #{@apiVersion} endpoint #{@kubernetes_url}: #{kube_error.message}"
152
153
  end
153
154
 
154
155
  if @watch
@@ -224,6 +225,9 @@ module Fluent
224
225
  if log[0].eql?('{') && log[-1].eql?('}')
225
226
  begin
226
227
  record = JSON.parse(log).merge(record)
228
+ unless @preserve_json_log
229
+ record.delete('log')
230
+ end
227
231
  rescue JSON::ParserError
228
232
  end
229
233
  end
@@ -320,6 +320,18 @@ class KubernetesMetadataFilterTest < Test::Unit::TestCase
320
320
  assert_equal(msg.merge(json_log), es.instance_variable_get(:@record_array)[0])
321
321
  end
322
322
 
323
+ test 'emit individual fields from json, throw out whole original string' do
324
+ json_log = {
325
+ 'hello' => 'world',
326
+ 'more' => 'data'
327
+ }
328
+ msg = {
329
+ 'log' => "#{json_log.to_json}"
330
+ }
331
+ es = emit_with_tag('non-kubernetes', msg, 'preserve_json_log false')
332
+ assert_equal(json_log, es.instance_variable_get(:@record_array)[0])
333
+ end
334
+
323
335
  test 'with kubernetes dotted labels, de_dot enabled' do
324
336
  VCR.use_cassette('kubernetes_docker_metadata_dotted_labels') do
325
337
  es = emit()
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-kubernetes_metadata_filter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.20.0
4
+ version: 0.21.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jimmi Dyson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-20 00:00:00.000000000 Z
11
+ date: 2016-04-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fluentd