fluent-plugin-elasticsearch 4.0.3 → 4.0.4

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
  SHA256:
3
- metadata.gz: 248fd3a633d1ee967b26d0d62e20a22f8ea7b67b16bfa1222001f8a3578ab94a
4
- data.tar.gz: 0143d71c8043323f61ff94117ae973ea0f5889f4dcb3ae38156f06dcb1c0fd5d
3
+ metadata.gz: c4253b332821c59318a743dccc063cfe0bf5b6f5302727d0bf974280b41336ea
4
+ data.tar.gz: 8731c0ba69bb200b1c397fc87ad0237c16ca8f5a825d37d16c0844664afd6292
5
5
  SHA512:
6
- metadata.gz: ab8e9c8ba00a928044fbabc61cda336ee3d61b6b38f34c6d1361610016d1c9e0ecd0c70817edda0bbb58e5b0861c2e401a50b85492d8e1a051034796d48ad2ee
7
- data.tar.gz: bce6f61984f42957ca44e02e176cb7b7f11ff2959f774f38d167b978332f0e737a8edb4005c7f82a2abd717fb0aff898a068f5cfd25737c99006f7c245726224
6
+ metadata.gz: 41eff72fc9b79075b3e3c2812c43fc34d4e789ca005bbe0d722e6d75ef9d01706841bba7214495a1d1bcdc3eeb5d86008c002e4aa4686508b22f1caafce731a3
7
+ data.tar.gz: 3087f4fa5c6c008092366652ee388690bd012c6528ab01eb699fe352760a584500c83ea903d22b40693bf3d141bf7ed220f491cd64be3be08fa9a7ca2308f246
data/History.md CHANGED
@@ -2,6 +2,9 @@
2
2
 
3
3
  ### [Unreleased]
4
4
 
5
+ ### 4.0.4
6
+ - Provide clearing caches timer (#719)
7
+
5
8
  ### 4.0.3
6
9
  - Use http.scheme settings for persisent scheme setup (#713)
7
10
 
data/README.md CHANGED
@@ -92,6 +92,7 @@ Current maintainers: @cosmo0920
92
92
  + [ilm_policy_id](#ilm_policy_id)
93
93
  + [ilm_policy](#ilm_policy)
94
94
  + [ilm_policy_overwrite](#ilm_policy_overwrite)
95
+ + [truncate_caches_interval](#truncate_caches_interval)
95
96
  * [Configuration - Elasticsearch Input](#configuration---elasticsearch-input)
96
97
  * [Troubleshooting](#troubleshooting)
97
98
  + [Cannot send events to elasticsearch](#cannot-send-events-to-elasticsearch)
@@ -1183,6 +1184,14 @@ Default value is `false`.
1183
1184
 
1184
1185
  **NOTE:** This parameter requests to install elasticsearch-xpack gem.
1185
1186
 
1187
+ ## truncate_caches_interval
1188
+
1189
+ Specify truncating caches interval.
1190
+
1191
+ If it is set, timer for clearing `alias_indexes` and `template_names` caches will be launched and executed.
1192
+
1193
+ Default value is `nil`.
1194
+
1186
1195
  ## Configuration - Elasticsearch Input
1187
1196
 
1188
1197
  See [Elasticsearch Input plugin document](README.ElasticsearchInput.md)
@@ -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 = '4.0.3'
6
+ s.version = '4.0.4'
7
7
  s.authors = ['diogo', 'pitr', 'Hiroshi Hatake']
8
8
  s.email = ['pitr.vern@gmail.com', 'me@diogoterror.com', 'cosmo0920.wp@gmail.com']
9
9
  s.description = %q{Elasticsearch output plugin for Fluent event collector}
@@ -141,16 +141,17 @@ module Fluent::ElasticsearchIndexTemplate
141
141
  client.indices.put_alias(:index => index_name_temp, :name => deflector_alias_name,
142
142
  :body => body)
143
143
  log.info("The alias '#{deflector_alias_name}' is created for the index '#{index_name_temp}'")
144
- if enable_ilm
145
- if ilm_policy.empty?
146
- setup_ilm(enable_ilm, ilm_policy_id)
147
- else
148
- setup_ilm(enable_ilm, ilm_policy_id, ilm_policy, ilm_policy_overwrite)
149
- end
150
- end
151
144
  else
152
145
  log.debug("The alias '#{deflector_alias_name}' is already present")
153
146
  end
147
+ # Create ILM policy if rollover indices exist.
148
+ if enable_ilm
149
+ if ilm_policy.empty?
150
+ setup_ilm(enable_ilm, ilm_policy_id)
151
+ else
152
+ setup_ilm(enable_ilm, ilm_policy_id, ilm_policy, ilm_policy_overwrite)
153
+ end
154
+ end
154
155
  else
155
156
  log.debug("No index and alias creation action performed because rollover_index or enable_ilm is set to: '#{rollover_index}', '#{enable_ilm}'")
156
157
  end
@@ -56,7 +56,7 @@ module Fluent::Plugin
56
56
  attr_reader :template_names
57
57
  attr_reader :ssl_version_options
58
58
 
59
- helpers :event_emitter, :compat_parameters, :record_accessor
59
+ helpers :event_emitter, :compat_parameters, :record_accessor, :timer
60
60
 
61
61
  Fluent::Plugin.register_output('elasticsearch', self)
62
62
 
@@ -158,6 +158,7 @@ EOC
158
158
  config_param :ilm_policy_id, :string, :default => DEFAULT_POLICY_ID
159
159
  config_param :ilm_policy, :hash, :default => {}
160
160
  config_param :ilm_policy_overwrite, :bool, :default => false
161
+ config_param :truncate_caches_interval, :time, :default => nil
161
162
 
162
163
  config_section :buffer do
163
164
  config_set_default :@type, DEFAULT_BUFFER_TYPE
@@ -241,6 +242,18 @@ EOC
241
242
  end
242
243
  end
243
244
 
245
+ @truncate_mutex = Mutex.new
246
+ if @truncate_caches_interval
247
+ timer_execute(:out_elasticsearch_truncate_caches, @truncate_caches_interval) do
248
+ log.info('Clean up the indices and template names cache')
249
+
250
+ @truncate_mutex.synchronize {
251
+ @alias_indexes.clear
252
+ @template_names.clear
253
+ }
254
+ end
255
+ end
256
+
244
257
  @serializer_class = nil
245
258
  begin
246
259
  require 'oj'
@@ -810,6 +810,70 @@ class ElasticsearchOutput < Test::Unit::TestCase
810
810
  assert_requested(elastic_request)
811
811
  end
812
812
 
813
+ def test_template_create_with_rollover_index_and_template_related_placeholders_with_truncating_caches
814
+ cwd = File.dirname(__FILE__)
815
+ template_file = File.join(cwd, 'test_template.json')
816
+ config = %{
817
+ host logs.google.com
818
+ port 777
819
+ scheme https
820
+ path /es/
821
+ user john
822
+ password doe
823
+ template_name logstash-${tag}
824
+ template_file #{template_file}
825
+ rollover_index true
826
+ index_date_pattern ""
827
+ index_name fluentd-${tag}
828
+ deflector_alias myapp_deflector-${tag}
829
+ truncate_caches_interval 2s
830
+ }
831
+
832
+ # connection start
833
+ stub_request(:head, "https://logs.google.com:777/es//").
834
+ with(basic_auth: ['john', 'doe']).
835
+ to_return(:status => 200, :body => "", :headers => {})
836
+ # check if template exists
837
+ stub_request(:get, "https://logs.google.com:777/es//_template/logstash-test.template").
838
+ with(basic_auth: ['john', 'doe']).
839
+ to_return(:status => 404, :body => "", :headers => {})
840
+ # create template
841
+ stub_request(:put, "https://logs.google.com:777/es//_template/logstash-test.template").
842
+ with(basic_auth: ['john', 'doe']).
843
+ to_return(:status => 200, :body => "", :headers => {})
844
+ # check if alias exists
845
+ stub_request(:head, "https://logs.google.com:777/es//_alias/myapp_deflector-test.template").
846
+ with(basic_auth: ['john', 'doe']).
847
+ to_return(:status => 404, :body => "", :headers => {})
848
+ # put the alias for the index
849
+ stub_request(:put, "https://logs.google.com:777/es//%3Cfluentd-test.template-default-000001%3E").
850
+ with(basic_auth: ['john', 'doe']).
851
+ to_return(status: 200, body: "", headers: {})
852
+ stub_request(:put, "https://logs.google.com:777/es//%3Cfluentd-test.template-default-000001%3E/_alias/myapp_deflector-test.template").
853
+ with(basic_auth: ['john', 'doe'],
854
+ body: "{\"aliases\":{\"myapp_deflector-test.template\":{\"is_write_index\":true}}}").
855
+ to_return(:status => 200, :body => "", :headers => {})
856
+
857
+ driver(config)
858
+
859
+ elastic_request = stub_elastic("https://logs.google.com:777/es//_bulk")
860
+ driver.run(default_tag: 'test.template', shutdown: false) do
861
+ driver.feed(sample_record)
862
+ end
863
+ assert_equal('fluentd-test.template', index_cmds.first['index']['_index'])
864
+
865
+ assert_equal ["myapp_deflector-test.template"], driver.instance.alias_indexes
866
+ assert_equal ["logstash-test.template"], driver.instance.template_names
867
+
868
+ assert_requested(elastic_request)
869
+
870
+ sleep 0.1 until driver.instance.alias_indexes.empty?
871
+ sleep 0.1 until driver.instance.template_names.empty?
872
+
873
+ assert_equal [], driver.instance.alias_indexes
874
+ assert_equal [], driver.instance.template_names
875
+ end
876
+
813
877
  class TemplateIndexLifecycleManagementTest < self
814
878
  def setup
815
879
  begin
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: 4.0.3
4
+ version: 4.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - diogo
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2020-02-10 00:00:00.000000000 Z
13
+ date: 2020-02-19 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: fluentd