fluent-plugin-elasticsearch 1.9.1 → 1.9.2

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: 9f78bc5cd41e0fbe35c7732472cf1f12acfe5ef2
4
- data.tar.gz: 2aec9b3232cde4c37389164354f55b2f5d07ba36
3
+ metadata.gz: e4f1361244893fa6e604c50f5b85d8627fa4422d
4
+ data.tar.gz: 6adfbf2916a9383e11865724a8400c3a0d6ea208
5
5
  SHA512:
6
- metadata.gz: 9d0c83d28e364bf3c9372cad94a4f345a1f444c0eba3bbdb62bfb5ecb000ced86174b294c212d4518fcd56a781d8f2c193d6799416fe4a6a93ca5d8606d7ee0d
7
- data.tar.gz: 89345bbcb03e101010b28a3d1e10928f8ce4c2a648a613c739a5ea3bf3e46445d09f2f66b820767e54150d22ccab659ee07f3816bd6d4ed27ab8d03691b33f25
6
+ metadata.gz: cc662aea89454d7136e056eacfcfcbcd12a704afa23ed45b4998642e5922eac524cea113c3afd0b0124ba15709e9b6844d9910a2e88e39b7fc07ec8202b5067a
7
+ data.tar.gz: 6cea6d23ae9c9fb779dab7492cf2dd444252de7cb586813c0cd3807a36d0b0a97ab07ba95e0da26e52a129e932a1b3ff3981397cbae67ac3def53046bc2610df
@@ -5,5 +5,9 @@ rvm:
5
5
  - 2.2
6
6
  - 2.3.1
7
7
 
8
+ gemfile:
9
+ - Gemfile
10
+ - Gemfile.v0.12
11
+
8
12
  script: bundle exec rake test
9
13
  sudo: false
@@ -0,0 +1,11 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in fluent-plugin-elasticsearch.gemspec
4
+ gem 'fluentd', '~> 0.12.0'
5
+
6
+ gemspec
7
+
8
+
9
+ gem 'simplecov', require: false
10
+ gem 'coveralls', require: false
11
+ gem 'strptime', require: false if RUBY_ENGINE == "ruby" && RUBY_VERSION =~ /^2/
data/History.md CHANGED
@@ -2,6 +2,9 @@
2
2
 
3
3
  ### [Unreleased]
4
4
 
5
+ ### 1.9.2
6
+ - Fix elasticsearch_dynamic for v0.14 (#224)
7
+
5
8
  ### 1.9.1
6
9
  - Cast `reload_*` configs in out_elasticsearch_dynamic to bool (#220)
7
10
 
@@ -3,7 +3,7 @@ $:.push File.expand_path('../lib', __FILE__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = 'fluent-plugin-elasticsearch'
6
- s.version = '1.9.1'
6
+ s.version = '1.9.2'
7
7
  s.authors = ['diogo', 'pitr']
8
8
  s.email = ['pitr.vern@gmail.com', 'me@diogoterror.com']
9
9
  s.description = %q{ElasticSearch output plugin for Fluent event collector}
@@ -7,28 +7,20 @@ class Fluent::ElasticsearchOutputDynamic < Fluent::ElasticsearchOutput
7
7
 
8
8
  config_param :delimiter, :string, :default => "."
9
9
 
10
- # params overloaded as strings
11
- config_param :port, :string, :default => "9200"
12
- config_param :logstash_format, :string, :default => "false"
13
- config_param :utc_index, :string, :default => "true"
14
- config_param :time_key_exclude_timestamp, :bool, :default => false
15
- config_param :reload_connections, :string, :default => "true"
16
- config_param :reload_on_failure, :string, :default => "false"
17
- config_param :resurrect_after, :string, :default => "60"
18
- config_param :ssl_verify, :string, :default => "true"
19
- config_param :reconnect_on_error, :bool, :default => false
10
+ DYNAMIC_PARAM_NAMES = %W[hosts host port logstash_format logstash_prefix logstash_dateformat time_key utc_index index_name tag_key type_name id_key parent_key routing_key write_operation]
11
+ DYNAMIC_PARAM_SYMBOLS = DYNAMIC_PARAM_NAMES.map { |n| "@#{n}".to_sym }
12
+
13
+ attr_reader :dynamic_config
20
14
 
21
15
  def configure(conf)
22
16
  super
23
17
 
24
18
  # evaluate all configurations here
25
- @dynamic_params ||= []
26
- @dynamic_params += self.instance_variables.select { |var| is_valid_expand_param_type(var) }
27
- @dynamic_config = Hash.new
28
- @dynamic_params.each { |var|
19
+ @dynamic_config = {}
20
+ DYNAMIC_PARAM_SYMBOLS.each_with_index { |var, i|
29
21
  value = expand_param(self.instance_variable_get(var), nil, nil, nil)
30
- var = var[1..-1]
31
- @dynamic_config[var] = value
22
+ key = DYNAMIC_PARAM_NAMES[i]
23
+ @dynamic_config[key] = value.to_s
32
24
  }
33
25
  # end eval all configs
34
26
  @current_config = nil
@@ -47,17 +39,17 @@ class Fluent::ElasticsearchOutputDynamic < Fluent::ElasticsearchOutput
47
39
 
48
40
  @_es ||= begin
49
41
  @current_config = connection_options[:hosts].clone
50
- excon_options = { client_key: @dynamic_config['client_key'], client_cert: @dynamic_config['client_cert'], client_key_pass: @dynamic_config['client_key_pass'] }
42
+ excon_options = { client_key: @client_key, client_cert: @client_cert, client_key_pass: @client_key_pass }
51
43
  adapter_conf = lambda {|f| f.adapter :excon, excon_options }
52
44
  transport = Elasticsearch::Transport::Transport::HTTP::Faraday.new(connection_options.merge(
53
45
  options: {
54
- reload_connections: Fluent::Config.bool_value(@dynamic_config['reload_connections']),
55
- reload_on_failure: Fluent::Config.bool_value(@dynamic_config['reload_on_failure']),
56
- resurrect_after: @dynamic_config['resurrect_after'].to_i,
46
+ reload_connections: @reload_connections,
47
+ reload_on_failure: @reload_on_failure,
48
+ resurrect_after: @resurrect_after,
57
49
  retry_on_failure: 5,
58
50
  transport_options: {
59
- request: { timeout: @dynamic_config['request_timeout'] },
60
- ssl: { verify: @dynamic_config['ssl_verify'], ca_file: @dynamic_config['ca_file'] }
51
+ request: { timeout: @request_timeout },
52
+ ssl: { verify: @ssl_verify, ca_file: @ca_file }
61
53
  }
62
54
  }), &adapter_conf)
63
55
  es = Elasticsearch::Client.new transport: transport
@@ -74,16 +66,16 @@ class Fluent::ElasticsearchOutputDynamic < Fluent::ElasticsearchOutput
74
66
  end
75
67
 
76
68
  def get_connection_options(con_host)
77
- raise "`password` must be present if `user` is present" if @dynamic_config['user'] && !@dynamic_config['password']
69
+ raise "`password` must be present if `user` is present" if @user && !@password
78
70
 
79
- hosts = if con_host || @dynamic_config['hosts']
80
- (con_host || @dynamic_config['hosts']).split(',').map do |host_str|
71
+ hosts = if con_host || @hosts
72
+ (con_host || @hosts).split(',').map do |host_str|
81
73
  # Support legacy hosts format host:port,host:port,host:port...
82
74
  if host_str.match(%r{^[^:]+(\:\d+)?$})
83
75
  {
84
76
  host: host_str.split(':')[0],
85
- port: (host_str.split(':')[1] || @dynamic_config['port'] || @port).to_i,
86
- scheme: @dynamic_config['scheme']
77
+ port: (host_str.split(':')[1] || @port).to_i,
78
+ scheme: @scheme
87
79
  }
88
80
  else
89
81
  # New hosts format expects URLs such as http://logs.foo.com,https://john:pass@logs2.foo.com/elastic
@@ -95,10 +87,10 @@ class Fluent::ElasticsearchOutputDynamic < Fluent::ElasticsearchOutput
95
87
  end
96
88
  end.compact
97
89
  else
98
- [{host: @dynamic_config['host'], port: @dynamic_config['port'].to_i, scheme: @dynamic_config['scheme']}]
90
+ [{host: @host, port: @port.to_i, scheme: @scheme}]
99
91
  end.each do |host|
100
- host.merge!(user: @dynamic_config['user'], password: @dynamic_config['password']) if !host[:user] && @dynamic_config['user']
101
- host.merge!(path: @dynamic_config['path']) if !host[:path] && @dynamic_config['path']
92
+ host.merge!(user: @user, password: @password) if !host[:user] && @user
93
+ host.merge!(path: @path) if !host[:path] && @path
102
94
  end
103
95
 
104
96
  {
@@ -129,8 +121,8 @@ class Fluent::ElasticsearchOutputDynamic < Fluent::ElasticsearchOutput
129
121
  next unless record.is_a? Hash
130
122
 
131
123
  # evaluate all configurations here
132
- @dynamic_params.each { |var|
133
- k = var[1..-1]
124
+ DYNAMIC_PARAM_SYMBOLS.each_with_index { |var, i|
125
+ k = DYNAMIC_PARAM_NAMES[i]
134
126
  v = self.instance_variable_get(var)
135
127
  # check here to determine if we should evaluate
136
128
  if dynamic_conf[k] != v
@@ -13,7 +13,14 @@ class ElasticsearchOutput < Test::Unit::TestCase
13
13
  end
14
14
 
15
15
  def driver(tag='test', conf='')
16
- @driver ||= Fluent::Test::BufferedOutputTestDriver.new(Fluent::ElasticsearchOutput, tag).configure(conf)
16
+ @driver ||= Fluent::Test::BufferedOutputTestDriver.new(Fluent::ElasticsearchOutput, tag) {
17
+ # v0.12's test driver assume format definition. This simulates ObjectBufferedOutput format
18
+ if !defined?(Fluent::Plugin::Output)
19
+ def format(tag, time, record)
20
+ [time, record].to_msgpack
21
+ end
22
+ end
23
+ }.configure(conf)
17
24
  end
18
25
 
19
26
  def sample_record
@@ -1134,5 +1141,4 @@ class ElasticsearchOutput < Test::Unit::TestCase
1134
1141
  driver.run
1135
1142
  assert(index_cmds[0].has_key?("create"))
1136
1143
  end
1137
-
1138
1144
  end
@@ -11,7 +11,14 @@ class ElasticsearchOutputDynamic < Test::Unit::TestCase
11
11
  end
12
12
 
13
13
  def driver(tag='test', conf='')
14
- @driver ||= Fluent::Test::BufferedOutputTestDriver.new(Fluent::ElasticsearchOutputDynamic, tag).configure(conf)
14
+ @driver ||= Fluent::Test::BufferedOutputTestDriver.new(Fluent::ElasticsearchOutputDynamic, tag) {
15
+ # v0.12's test driver assume format definition. This simulates ObjectBufferedOutput format
16
+ if !defined?(Fluent::Plugin::Output)
17
+ def format(tag, time, record)
18
+ [time, record].to_msgpack
19
+ end
20
+ end
21
+ }.configure(conf)
15
22
  end
16
23
 
17
24
  def sample_record
@@ -55,12 +62,12 @@ class ElasticsearchOutputDynamic < Test::Unit::TestCase
55
62
  }
56
63
  instance = driver('test', config).instance
57
64
 
58
- assert_equal 'logs.google.com', instance.host
59
- assert_equal 777, instance.port
60
- assert_equal 'https', instance.scheme
61
- assert_equal '/es/', instance.path
65
+ conf = instance.dynamic_config
66
+ assert_equal 'logs.google.com', conf['host']
67
+ assert_equal "777", conf['port']
62
68
  assert_equal 'john', instance.user
63
69
  assert_equal 'doe', instance.password
70
+ assert_equal '/es/', instance.path
64
71
  end
65
72
 
66
73
  def test_defaults
@@ -73,14 +80,11 @@ class ElasticsearchOutputDynamic < Test::Unit::TestCase
73
80
  }
74
81
  instance = driver('test', config).instance
75
82
 
76
- assert_equal "9200", instance.port
77
- assert_equal "false", instance.logstash_format
78
- assert_equal "true", instance.utc_index
83
+ conf = instance.dynamic_config
84
+ assert_equal "9200", conf['port']
85
+ assert_equal "false", conf['logstash_format']
86
+ assert_equal "true", conf['utc_index']
79
87
  assert_equal false, instance.time_key_exclude_timestamp
80
- assert_equal "true", instance.reload_connections
81
- assert_equal "false", instance.reload_on_failure
82
- assert_equal "60", instance.resurrect_after
83
- assert_equal "true", instance.ssl_verify
84
88
  end
85
89
 
86
90
  def test_legacy_hosts_list
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-elasticsearch
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.9.1
4
+ version: 1.9.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - diogo
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-12-14 00:00:00.000000000 Z
12
+ date: 2016-12-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: fluentd
@@ -122,6 +122,7 @@ files:
122
122
  - ".gitignore"
123
123
  - ".travis.yml"
124
124
  - Gemfile
125
+ - Gemfile.v0.12
125
126
  - History.md
126
127
  - ISSUE_TEMPLATE.md
127
128
  - LICENSE.txt