fluent-plugin-elasticsearch 5.3.0 → 5.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -57,6 +57,10 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
57
57
  Gem::Version.create(::TRANSPORT_CLASS::VERSION) >= Gem::Version.new("7.14.0")
58
58
  end
59
59
 
60
+ def elastic_perform_request_refactored?
61
+ Gem::Version.create(Elasticsearch::VERSION) >= Gem::Version.new("8.8.0")
62
+ end
63
+
60
64
  def elastic_transport_layer?
61
65
  Gem::Version.create(::TRANSPORT_CLASS::VERSION) >= Gem::Version.new("8.0.0")
62
66
  end
@@ -84,7 +88,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
84
88
  def stub_elastic(url="http://localhost:9200/_bulk")
85
89
  stub_request(:post, url).with do |req|
86
90
  @index_cmds = req.body.split("\n").map {|r| JSON.parse(r) }
87
- end
91
+ end.to_return({:status => 200, :body => "", :headers => { 'Content-Type' => 'json', 'x-elastic-product' => 'Elasticsearch' } })
88
92
  end
89
93
 
90
94
  def stub_elastic_all_requests(url="http://localhost:9200/_bulk")
@@ -92,7 +96,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
92
96
  stub_request(:post, url).with do |req|
93
97
  @index_cmds = req.body.split("\n").map {|r| JSON.parse(r) }
94
98
  @index_cmds_all_requests << @index_cmds
95
- end
99
+ end.to_return({:status => 200, :body => "", :headers => { 'Content-Type' => 'json', 'x-elastic-product' => 'Elasticsearch' } })
96
100
  end
97
101
 
98
102
  def stub_elastic_unavailable(url="http://localhost:9200/_bulk")
@@ -112,7 +116,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
112
116
  stub_request(:post, url).with do |req|
113
117
  index_cmds = req.body.split("\n").map {|r| JSON.parse(r) }
114
118
  @index_command_counts[url] += index_cmds.size
115
- end
119
+ end.to_return({:status => 200, :body => "{}", :headers => { 'Content-Type' => 'json', 'x-elastic-product' => 'Elasticsearch' } })
116
120
  end
117
121
 
118
122
  def make_response_body(req, error_el = nil, error_status = nil, error = nil)
@@ -179,7 +183,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
179
183
  "reason" => "Invalid format: \"...\""
180
184
  }
181
185
  }
182
- stub_request(:post, url).to_return(lambda { |req| { :status => 200, :body => make_response_body(req, 1, 400, error), :headers => { 'Content-Type' => 'json' } } })
186
+ stub_request(:post, url).to_return(lambda { |req| { :status => 200, :body => make_response_body(req, 1, 400, error), :headers => { 'Content-Type' => 'json', 'x-elastic-product' => 'Elasticsearch' } } })
183
187
  end
184
188
 
185
189
  def stub_elastic_bulk_error(url="http://localhost:9200/_bulk")
@@ -187,7 +191,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
187
191
  "type" => "some-unrecognized-error",
188
192
  "reason" => "some message printed here ...",
189
193
  }
190
- stub_request(:post, url).to_return(lambda { |req| { :status => 200, :body => make_response_body(req, 1, 500, error), :headers => { 'Content-Type' => 'json' } } })
194
+ stub_request(:post, url).to_return(lambda { |req| { :status => 200, :body => make_response_body(req, 1, 500, error), :headers => { 'Content-Type' => 'json', 'x-elastic-product' => 'Elasticsearch' } } })
191
195
  end
192
196
 
193
197
  def stub_elastic_bulk_rejected(url="http://localhost:9200/_bulk")
@@ -196,7 +200,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
196
200
  "type" => "es_rejected_execution_exception",
197
201
  "reason" => "rejected execution of org.elasticsearch.transport.TransportService$4@1a34d37a on EsThreadPoolExecutor[bulk, queue capacity = 50, org.elasticsearch.common.util.concurrent.EsThreadPoolExecutor@312a2162[Running, pool size = 32, active threads = 32, queued tasks = 50, completed tasks = 327053]]"
198
202
  }
199
- stub_request(:post, url).to_return(lambda { |req| { :status => 200, :body => make_response_body(req, 1, 429, error), :headers => { 'Content-Type' => 'json' } } })
203
+ stub_request(:post, url).to_return(lambda { |req| { :status => 200, :body => make_response_body(req, 1, 429, error), :headers => { 'Content-Type' => 'json', 'x-elastic-product' => 'Elasticsearch' } } })
200
204
  end
201
205
 
202
206
  def stub_elastic_out_of_memory(url="http://localhost:9200/_bulk")
@@ -205,7 +209,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
205
209
  "type" => "out_of_memory_error",
206
210
  "reason" => "Java heap space"
207
211
  }
208
- stub_request(:post, url).to_return(lambda { |req| { :status => 200, :body => make_response_body(req, 1, 500, error), :headers => { 'Content-Type' => 'json' } } })
212
+ stub_request(:post, url).to_return(lambda { |req| { :status => 200, :body => make_response_body(req, 1, 500, error), :headers => { 'Content-Type' => 'json', 'x-elastic-product' => 'Elasticsearch' } } })
209
213
  end
210
214
 
211
215
  def stub_elastic_unexpected_response_op(url="http://localhost:9200/_bulk")
@@ -213,7 +217,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
213
217
  "category" => "some-other-type",
214
218
  "reason" => "some-other-reason"
215
219
  }
216
- stub_request(:post, url).to_return(lambda { |req| bodystr = make_response_body(req, 0, 500, error); body = JSON.parse(bodystr); body['items'][0]['unknown'] = body['items'][0].delete('create'); { :status => 200, :body => body.to_json, :headers => { 'Content-Type' => 'json' } } })
220
+ stub_request(:post, url).to_return(lambda { |req| bodystr = make_response_body(req, 0, 500, error); body = JSON.parse(bodystr); body['items'][0]['unknown'] = body['items'][0].delete('create'); { :status => 200, :body => body.to_json, :headers => { 'Content-Type' => 'json', 'x-elastic-product' => 'Elasticsearch' } } })
217
221
  end
218
222
 
219
223
  def assert_logs_include(logs, msg, exp_matches=1)
@@ -324,7 +328,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
324
328
  end
325
329
 
326
330
  stub_request(:post, "http://localhost:9200/_bulk").
327
- to_return(status: 200, body: "", headers: {})
331
+ to_return(status: 200, body: "", headers: {'x-elastic-product' => 'Elasticsearch'})
328
332
  stub_elastic_info
329
333
  driver.run(default_tag: 'test') do
330
334
  driver.feed(sample_record)
@@ -357,7 +361,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
357
361
  end
358
362
 
359
363
  stub_request(:post, "http://localhost:9200/_bulk").
360
- to_return(status: 200, body: "", headers: {})
364
+ to_return(status: 200, body: "", headers: {'x-elastic-product' => 'Elasticsearch' })
361
365
  stub_elastic_info
362
366
  driver.run(default_tag: 'test') do
363
367
  driver.feed(sample_record)
@@ -458,7 +462,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
458
462
 
459
463
  def stub_elastic_info_bad(url="http://localhost:9200/", version="6.4.2")
460
464
  body ="{\"version\":{\"number\":\"#{version}\",\"build_flavor\":\"default\"},\"tagline\":\"You Know, for Search\"}"
461
- stub_request(:get, url).to_return({:status => 200, :body => body, :headers => { 'Content-Type' => 'text/plain' } })
465
+ stub_request(:get, url).to_return({:status => 200, :body => body, :headers => { 'Content-Type' => 'text/plain', 'x-elastic-product' => 'Elasticsearch'} })
462
466
  end
463
467
 
464
468
  test 'handle invalid client.info' do
@@ -474,7 +478,11 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
474
478
  scheme https
475
479
  @log_level info
476
480
  }
477
- if elastic_transport_layer?
481
+ if elastic_perform_request_refactored?
482
+ d = create_driver(config, 8, "\"8.8.0\"")
483
+ logs = d.logs
484
+ assert_logs_include(logs, /Detected ES 7.x: `_doc` will be used as the document `_type`./)
485
+ elsif elastic_transport_layer?
478
486
  assert_raise(NoMethodError) do
479
487
  d = create_driver(config, 8, "\"8.0.0\"")
480
488
  end
@@ -543,22 +551,22 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
543
551
  use_legacy_template #{use_legacy_template_flag}
544
552
  }
545
553
  stub_request(:get, "http://localhost:9200/#{endpoint}/fluentd").
546
- to_return(status: 200, body: "", headers: {})
554
+ to_return(status: 200, body: "", headers: {'x-elastic-product' => 'Elasticsearch'})
547
555
  stub_request(:head, "http://localhost:9200/_alias/fluentd").
548
- to_return(status: 404, body: "", headers: {})
556
+ to_return(status: 404, body: "", headers: {'x-elastic-product' => 'Elasticsearch'})
549
557
  stub_request(:put, "http://localhost:9200/%3Cfluentd-default-%7Bnow%2Fd%7D-000001%3E/#{alias_endpoint}/fluentd").
550
558
  with(body: "{\"aliases\":{\"fluentd\":{\"is_write_index\":true}}}").
551
- to_return(status: 200, body: "", headers: {})
559
+ to_return(status: 200, body: "", headers: {'x-elastic-product' => 'Elasticsearch'})
552
560
  stub_request(:put, "http://localhost:9200/%3Cfluentd-default-%7Bnow%2Fd%7D-000001%3E").
553
- to_return(status: 200, body: "", headers: {})
561
+ to_return(status: 200, body: "", headers: {'x-elastic-product' => 'Elasticsearch'})
554
562
  stub_request(:get, "http://localhost:9200/_xpack").
555
563
  to_return(:status => 200, :body => '{"features":{"ilm":{"available":true,"enabled":true}}}',
556
- :headers => {"Content-Type"=> "application/json"})
564
+ :headers => {"Content-Type"=> "application/json", 'x-elastic-product' => 'Elasticsearch'})
557
565
  stub_request(:get, "http://localhost:9200/#{ilm_endpoint}/policy/logstash-policy").
558
- to_return(status: 404, body: "", headers: {})
566
+ to_return(status: 404, body: "", headers: {'x-elastic-product' => 'Elasticsearch'})
559
567
  stub_request(:put, "http://localhost:9200/#{ilm_endpoint}/policy/logstash-policy").
560
568
  with(body: "{\"policy\":{\"phases\":{\"hot\":{\"actions\":{\"rollover\":{\"max_size\":\"50gb\",\"max_age\":\"30d\"}}}}}}").
561
- to_return(status: 200, body: "", headers: {})
569
+ to_return(status: 200, body: "", headers: {'x-elastic-product' => 'Elasticsearch'})
562
570
  stub_elastic_info
563
571
 
564
572
  assert_nothing_raised {
@@ -588,22 +596,22 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
588
596
  use_legacy_template #{use_legacy_template_flag}
589
597
  }
590
598
  stub_request(:get, "http://localhost:9200/#{endpoint}/fluentd").
591
- to_return(status: 200, body: "", headers: {})
599
+ to_return(status: 200, body: "", headers: {'x-elastic-product' => 'Elasticsearch'})
592
600
  stub_request(:head, "http://localhost:9200/_alias/fluentd").
593
- to_return(status: 404, body: "", headers: {})
601
+ to_return(status: 404, body: "", headers: {'x-elastic-product' => 'Elasticsearch'})
594
602
  stub_request(:put, "http://localhost:9200/%3Cfluentd-default-%7Bnow%2Fd%7D-000001%3E/#{alias_endpoint}/fluentd").
595
603
  with(body: "{\"aliases\":{\"fluentd\":{\"is_write_index\":true}}}").
596
- to_return(status: 200, body: "", headers: {})
604
+ to_return(status: 200, body: "", headers: {'x-elastic-product' => 'Elasticsearch'})
597
605
  stub_request(:put, "http://localhost:9200/%3Cfluentd-default-%7Bnow%2Fd%7D-000001%3E").
598
- to_return(status: 200, body: "", headers: {})
606
+ to_return(status: 200, body: "", headers: {'x-elastic-product' => 'Elasticsearch'})
599
607
  stub_request(:get, "http://localhost:9200/_xpack").
600
608
  to_return(:status => 200, :body => '{"features":{"ilm":{"available":true,"enabled":true}}}',
601
- :headers => {"Content-Type"=> "application/json"})
609
+ :headers => {"Content-Type"=> "application/json", 'x-elastic-product' => 'Elasticsearch'})
602
610
  stub_request(:get, "http://localhost:9200/#{ilm_endpoint}/policy/logstash-policy").
603
- to_return(status: 200, body: "", headers: {})
611
+ to_return(status: 200, body: "", headers: {'x-elastic-product' => 'Elasticsearch'})
604
612
  stub_request(:put, "http://localhost:9200/#{ilm_endpoint}/policy/logstash-policy").
605
613
  with(body: "{\"policy\":{\"phases\":{\"hot\":{\"actions\":{\"rollover\":{\"max_size\":\"75gb\",\"max_age\":\"50d\"}}}}}}").
606
- to_return(status: 200, body: "", headers: {})
614
+ to_return(status: 200, body: "", headers: {'x-elastic-product' => 'Elasticsearch'})
607
615
  stub_elastic_info
608
616
 
609
617
  assert_nothing_raised {
@@ -954,11 +962,11 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
954
962
  # connection start
955
963
  stub_request(:head, "https://logs.google.com:777/es//").
956
964
  with(basic_auth: ['john', 'doe']).
957
- to_return(:status => 200, :body => "", :headers => {})
965
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
958
966
  # check if template exists
959
967
  stub_request(:get, "https://logs.google.com:777/es//#{endpoint}/logstash").
960
968
  with(basic_auth: ['john', 'doe']).
961
- to_return(:status => 200, :body => "", :headers => {})
969
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
962
970
  stub_elastic_info("https://logs.google.com:777/es//")
963
971
 
964
972
  driver(config)
@@ -995,15 +1003,15 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
995
1003
  # connection start
996
1004
  stub_request(:head, "https://logs.google.com:777/es//").
997
1005
  with(basic_auth: ['john', 'doe']).
998
- to_return(:status => 200, :body => "", :headers => {})
1006
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
999
1007
  # check if template exists
1000
1008
  stub_request(:get, "https://logs.google.com:777/es//#{endpoint}/logstash").
1001
1009
  with(basic_auth: ['john', 'doe']).
1002
- to_return(:status => 404, :body => "", :headers => {})
1010
+ to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
1003
1011
  # creation
1004
1012
  stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/logstash").
1005
1013
  with(basic_auth: ['john', 'doe']).
1006
- to_return(:status => 200, :body => "", :headers => {})
1014
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
1007
1015
  stub_elastic_info("https://logs.google.com:777/es//")
1008
1016
 
1009
1017
  driver(config)
@@ -1043,27 +1051,27 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
1043
1051
  # connection start
1044
1052
  stub_request(:head, "https://logs.google.com:777/es//").
1045
1053
  with(basic_auth: ['john', 'doe']).
1046
- to_return(:status => 200, :body => "", :headers => {})
1054
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
1047
1055
  # check if template exists
1048
1056
  stub_request(:get, "https://logs.google.com:777/es//#{endpoint}/logstash-test.template").
1049
1057
  with(basic_auth: ['john', 'doe']).
1050
- to_return(:status => 404, :body => "", :headers => {})
1058
+ to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
1051
1059
  # create template
1052
1060
  stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/logstash-test.template").
1053
1061
  with(basic_auth: ['john', 'doe']).
1054
- to_return(:status => 200, :body => "", :headers => {})
1062
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
1055
1063
  # check if alias exists
1056
1064
  stub_request(:head, "https://logs.google.com:777/es//_alias/myapp_deflector-test.template").
1057
1065
  with(basic_auth: ['john', 'doe']).
1058
- to_return(:status => 404, :body => "", :headers => {})
1066
+ to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
1059
1067
  # put the alias for the index
1060
1068
  stub_request(:put, "https://logs.google.com:777/es//%3Cfluentd-test.template-default-000001%3E").
1061
1069
  with(basic_auth: ['john', 'doe']).
1062
- to_return(status: 200, body: "", headers: {})
1070
+ to_return(status: 200, body: "", headers: {'x-elastic-product' => 'Elasticsearch'})
1063
1071
  stub_request(:put, "https://logs.google.com:777/es//%3Cfluentd-test.template-default-000001%3E/#{alias_endpoint}/myapp_deflector-test.template").
1064
1072
  with(basic_auth: ['john', 'doe'],
1065
1073
  body: "{\"aliases\":{\"myapp_deflector-test.template\":{\"is_write_index\":true}}}").
1066
- to_return(:status => 200, :body => "", :headers => {})
1074
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
1067
1075
 
1068
1076
  driver(config)
1069
1077
 
@@ -1113,27 +1121,27 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
1113
1121
  # connection start
1114
1122
  stub_request(:head, "https://logs.google.com:777/es//").
1115
1123
  with(basic_auth: ['john', 'doe']).
1116
- to_return(:status => 200, :body => "", :headers => {})
1124
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
1117
1125
  # check if template exists
1118
1126
  stub_request(:get, "https://logs.google.com:777/es//#{endpoint}/logstash-test.template").
1119
1127
  with(basic_auth: ['john', 'doe']).
1120
- to_return(:status => 404, :body => "", :headers => {})
1128
+ to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
1121
1129
  # create template
1122
1130
  stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/logstash-test.template").
1123
1131
  with(basic_auth: ['john', 'doe']).
1124
- to_return(:status => 200, :body => "", :headers => {})
1132
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
1125
1133
  # check if alias exists
1126
1134
  stub_request(:head, "https://logs.google.com:777/es//_alias/myapp_deflector-test.template").
1127
1135
  with(basic_auth: ['john', 'doe']).
1128
- to_return(:status => 404, :body => "", :headers => {})
1136
+ to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
1129
1137
  # put the alias for the index
1130
1138
  stub_request(:put, "https://logs.google.com:777/es//%3Cfluentd-test.template-default-000001%3E").
1131
1139
  with(basic_auth: ['john', 'doe']).
1132
- to_return(status: 200, body: "", headers: {})
1140
+ to_return(status: 200, body: "", headers: {'x-elastic-product' => 'Elasticsearch'})
1133
1141
  stub_request(:put, "https://logs.google.com:777/es//%3Cfluentd-test.template-default-000001%3E/#{alias_endpoint}/myapp_deflector-test.template").
1134
1142
  with(basic_auth: ['john', 'doe'],
1135
1143
  body: "{\"aliases\":{\"myapp_deflector-test.template\":{\"is_write_index\":true}}}").
1136
- to_return(:status => 200, :body => "", :headers => {})
1144
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
1137
1145
  stub_elastic_info("https://logs.google.com:777/es//")
1138
1146
 
1139
1147
  driver(config)
@@ -1210,51 +1218,51 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
1210
1218
  # connection start
1211
1219
  stub_request(:head, "https://logs.google.com:777/es//").
1212
1220
  with(basic_auth: ['john', 'doe']).
1213
- to_return(:status => 200, :body => "", :headers => {})
1221
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
1214
1222
  # check if template exists
1215
1223
  stub_request(:get, "https://logs.google.com:777/es//#{endpoint}/logstash").
1216
1224
  with(basic_auth: ['john', 'doe']).
1217
- to_return(:status => 404, :body => "", :headers => {})
1225
+ to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
1218
1226
  # creation
1219
1227
  stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/logstash").
1220
1228
  with(basic_auth: ['john', 'doe']).
1221
- to_return(:status => 200, :body => "", :headers => {})
1229
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
1222
1230
  # check if alias exists
1223
1231
  stub_request(:head, "https://logs.google.com:777/es//_alias/logstash").
1224
1232
  with(basic_auth: ['john', 'doe']).
1225
- to_return(:status => 404, :body => "", :headers => {})
1233
+ to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
1226
1234
  stub_request(:get, "https://logs.google.com:777/es//#{endpoint}/logstash").
1227
1235
  with(basic_auth: ['john', 'doe']).
1228
- to_return(status: 404, body: "", headers: {})
1236
+ to_return(status: 404, body: "", headers: {'x-elastic-product' => 'Elasticsearch'})
1229
1237
  if use_legacy_template_flag
1230
1238
  stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/logstash").
1231
1239
  with(basic_auth: ['john', 'doe'],
1232
1240
  body: "{\"settings\":{\"number_of_shards\":1,\"index.lifecycle.name\":\"logstash-policy\",\"index.lifecycle.rollover_alias\":\"logstash\"},\"mappings\":{\"type1\":{\"_source\":{\"enabled\":false},\"properties\":{\"host_name\":{\"type\":\"string\",\"index\":\"not_analyzed\"},\"created_at\":{\"type\":\"date\",\"format\":\"EEE MMM dd HH:mm:ss Z YYYY\"}}}},\"index_patterns\":\"logstash-*\",\"order\":51}").
1233
- to_return(status: 200, body: "", headers: {})
1241
+ to_return(status: 200, body: "", headers: {'x-elastic-product' => 'Elasticsearch'})
1234
1242
  else
1235
1243
  stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/logstash").
1236
1244
  with(basic_auth: ['john', 'doe'],
1237
1245
  body: "{\"index_patterns\":\"logstash-*\",\"template\":{\"settings\":{\"number_of_shards\":1,\"index.lifecycle.name\":\"logstash-policy\",\"index.lifecycle.rollover_alias\":\"logstash\"},\"mappings\":{\"type1\":{\"_source\":{\"enabled\":false},\"properties\":{\"host_name\":{\"type\":\"string\",\"index\":\"not_analyzed\"},\"created_at\":{\"type\":\"date\",\"format\":\"EEE MMM dd HH:mm:ss Z YYYY\"}}}}},\"priority\":101}").
1238
- to_return(status: 200, body: "", headers: {})
1246
+ to_return(status: 200, body: "", headers: {'x-elastic-product' => 'Elasticsearch'})
1239
1247
  end
1240
1248
  # put the alias for the index
1241
1249
  stub_request(:put, "https://logs.google.com:777/es//%3Clogstash-default-%7Bnow%2Fw%7Bxxxx.ww%7D%7D-000001%3E").
1242
1250
  with(basic_auth: ['john', 'doe']).
1243
- to_return(:status => 200, :body => "", :headers => {})
1251
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
1244
1252
  stub_request(:put, "https://logs.google.com:777/es//%3Clogstash-default-%7Bnow%2Fw%7Bxxxx.ww%7D%7D-000001%3E/#{alias_endpoint}/logstash").
1245
1253
  with(basic_auth: ['john', 'doe'],
1246
1254
  :body => "{\"aliases\":{\"logstash\":{\"is_write_index\":true}}}").
1247
- to_return(:status => 200, :body => "", :headers => {})
1255
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
1248
1256
  stub_request(:get, "https://logs.google.com:777/es//_xpack").
1249
1257
  with(basic_auth: ['john', 'doe']).
1250
- to_return(:status => 200, :body => '{"features":{"ilm":{"available":true,"enabled":true}}}', :headers => {"Content-Type"=> "application/json"})
1258
+ to_return(:status => 200, :body => '{"features":{"ilm":{"available":true,"enabled":true}}}', :headers => {"Content-Type"=> "application/json", 'x-elastic-product' => 'Elasticsearch'})
1251
1259
  stub_request(:get, "https://logs.google.com:777/es//#{ilm_endpoint}/policy/logstash-policy").
1252
1260
  with(basic_auth: ['john', 'doe']).
1253
- to_return(:status => 404, :body => "", :headers => {})
1261
+ to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
1254
1262
  stub_request(:put, "https://logs.google.com:777/es//#{ilm_endpoint}/policy/logstash-policy").
1255
1263
  with(basic_auth: ['john', 'doe'],
1256
1264
  :body => "{\"policy\":{\"phases\":{\"hot\":{\"actions\":{\"rollover\":{\"max_size\":\"50gb\",\"max_age\":\"30d\"}}}}}}").
1257
- to_return(:status => 200, :body => "", :headers => {})
1265
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
1258
1266
  stub_elastic_info("https://logs.google.com:777/es//")
1259
1267
 
1260
1268
  driver(config)
@@ -1296,52 +1304,52 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
1296
1304
  # connection start
1297
1305
  stub_request(:head, "https://logs.google.com:777/es//").
1298
1306
  with(basic_auth: ['john', 'doe']).
1299
- to_return(:status => 200, :body => "", :headers => {})
1307
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
1300
1308
  # check if template exists
1301
1309
  stub_request(:get, "https://logs.google.com:777/es//#{endpoint}/logstash-#{date_str}").
1302
1310
  with(basic_auth: ['john', 'doe']).
1303
- to_return(:status => 404, :body => "", :headers => {})
1311
+ to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
1304
1312
  # creation
1305
1313
  stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/logstash-#{date_str}").
1306
1314
  with(basic_auth: ['john', 'doe']).
1307
- to_return(:status => 200, :body => "", :headers => {})
1315
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
1308
1316
  # check if alias exists
1309
1317
  stub_request(:head, "https://logs.google.com:777/es//_alias/logstash-#{date_str}").
1310
1318
  with(basic_auth: ['john', 'doe']).
1311
- to_return(:status => 404, :body => "", :headers => {})
1319
+ to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
1312
1320
  stub_request(:get, "https://logs.google.com:777/es//#{endpoint}/logstash-#{date_str}").
1313
1321
  with(basic_auth: ['john', 'doe']).
1314
- to_return(status: 404, body: "", headers: {})
1322
+ to_return(status: 404, body: "", headers: {'x-elastic-product' => 'Elasticsearch'})
1315
1323
  if use_legacy_template_flag
1316
1324
  stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/logstash-#{date_str}").
1317
1325
  with(basic_auth: ['john', 'doe'],
1318
1326
  body: "{\"settings\":{\"number_of_shards\":1,\"index.lifecycle.name\":\"logstash-policy\",\"index.lifecycle.rollover_alias\":\"logstash-log-#{date_str}\"},\"mappings\":{\"type1\":{\"_source\":{\"enabled\":false},\"properties\":{\"host_name\":{\"type\":\"string\",\"index\":\"not_analyzed\"},\"created_at\":{\"type\":\"date\",\"format\":\"EEE MMM dd HH:mm:ss Z YYYY\"}}}},\"index_patterns\":\"logstash-log-#{date_str}-*\",\"order\":53}").
1319
- to_return(status: 200, body: "", headers: {})
1327
+ to_return(status: 200, body: "", headers: {'x-elastic-product' => 'Elasticsearch'})
1320
1328
  else
1321
1329
  stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/logstash-#{date_str}").
1322
1330
  with(basic_auth: ['john', 'doe'],
1323
1331
  body: "{\"index_patterns\":\"logstash-log-2020.09.21-*\",\"template\":{\"settings\":{\"number_of_shards\":1,\"index.lifecycle.name\":\"logstash-policy\",\"index.lifecycle.rollover_alias\":\"logstash-2020.09.21\"},\"mappings\":{\"type1\":{\"_source\":{\"enabled\":false},\"properties\":{\"host_name\":{\"type\":\"string\",\"index\":\"not_analyzed\"},\"created_at\":{\"type\":\"date\",\"format\":\"EEE MMM dd HH:mm:ss Z YYYY\"}}}}},\"priority\":103}").
1324
- to_return(status: 200, body: "", headers: {})
1332
+ to_return(status: 200, body: "", headers: {'x-elastic-product' => 'Elasticsearch'})
1325
1333
  end
1326
1334
  # put the alias for the index
1327
1335
  stub_request(:put, "https://logs.google.com:777/es//%3Clogstash-log-#{date_str}-000001%3E").
1328
1336
  with(basic_auth: ['john', 'doe']).
1329
- to_return(:status => 200, :body => "", :headers => {})
1337
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
1330
1338
 
1331
1339
  stub_request(:put, "https://logs.google.com:777/es//%3Clogstash-log-#{date_str}-000001%3E/#{alias_endpoint}/logstash-#{date_str}").
1332
1340
  with(basic_auth: ['john', 'doe'],
1333
1341
  body: "{\"aliases\":{\"logstash-#{date_str}\":{\"is_write_index\":true}}}").
1334
- to_return(status: 200, body: "", headers: {})
1342
+ to_return(status: 200, body: "", headers: {'x-elastic-product' => 'Elasticsearch'})
1335
1343
  stub_request(:get, "https://logs.google.com:777/es//_xpack").
1336
1344
  with(basic_auth: ['john', 'doe']).
1337
- to_return(:status => 200, :body => '{"features":{"ilm":{"available":true,"enabled":true}}}', :headers => {"Content-Type"=> "application/json"})
1345
+ to_return(:status => 200, :body => '{"features":{"ilm":{"available":true,"enabled":true}}}', :headers => {"Content-Type"=> "application/json", 'x-elastic-product' => 'Elasticsearch'})
1338
1346
  stub_request(:get, "https://logs.google.com:777/es//#{ilm_endpoint}/policy/logstash-policy").
1339
1347
  with(basic_auth: ['john', 'doe']).
1340
- to_return(:status => 404, :body => "", :headers => {})
1348
+ to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
1341
1349
  stub_request(:put, "https://logs.google.com:777/es//#{ilm_endpoint}/policy/logstash-policy").
1342
1350
  with(basic_auth: ['john', 'doe'],
1343
1351
  :body => "{\"policy\":{\"phases\":{\"hot\":{\"actions\":{\"rollover\":{\"max_size\":\"50gb\",\"max_age\":\"30d\"}}}}}}").
1344
- to_return(:status => 200, :body => "", :headers => {})
1352
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
1345
1353
  stub_elastic_info("https://logs.google.com:777/es//")
1346
1354
 
1347
1355
  driver(config)
@@ -1389,51 +1397,51 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
1389
1397
  # connection start
1390
1398
  stub_request(:head, "https://logs.google.com:777/es//").
1391
1399
  with(basic_auth: ['john', 'doe']).
1392
- to_return(:status => 200, :body => "", :headers => {})
1400
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
1393
1401
  # check if template exists
1394
1402
  stub_request(:get, "https://logs.google.com:777/es//#{endpoint}/logstash").
1395
1403
  with(basic_auth: ['john', 'doe']).
1396
- to_return(:status => 404, :body => "", :headers => {})
1404
+ to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
1397
1405
  # creation
1398
1406
  stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/logstash").
1399
1407
  with(basic_auth: ['john', 'doe']).
1400
- to_return(:status => 200, :body => "", :headers => {})
1408
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
1401
1409
  # check if alias exists
1402
1410
  stub_request(:head, "https://logs.google.com:777/es//_alias/logstash").
1403
1411
  with(basic_auth: ['john', 'doe']).
1404
- to_return(:status => 404, :body => "", :headers => {})
1412
+ to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
1405
1413
  stub_request(:get, "https://logs.google.com:777/es//#{endpoint}/logstash").
1406
1414
  with(basic_auth: ['john', 'doe']).
1407
- to_return(status: 404, body: "", headers: {})
1415
+ to_return(status: 404, body: "", headers: {'x-elastic-product' => 'Elasticsearch'})
1408
1416
  if use_legacy_template_flag
1409
1417
  stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/logstash").
1410
1418
  with(basic_auth: ['john', 'doe'],
1411
1419
  body: "{\"settings\":{\"number_of_shards\":1,\"index.lifecycle.name\":\"logstash-policy\",\"index.lifecycle.rollover_alias\":\"logstash\"},\"mappings\":{\"type1\":{\"_source\":{\"enabled\":false},\"properties\":{\"host_name\":{\"type\":\"string\",\"index\":\"not_analyzed\"},\"created_at\":{\"type\":\"date\",\"format\":\"EEE MMM dd HH:mm:ss Z YYYY\"}}}},\"index_patterns\":\"logstash-*\",\"order\":51}").
1412
- to_return(status: 200, body: "", headers: {})
1420
+ to_return(status: 200, body: "", headers: {'x-elastic-product' => 'Elasticsearch'})
1413
1421
  else
1414
1422
  stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/logstash").
1415
1423
  with(basic_auth: ['john', 'doe'],
1416
1424
  body: "{\"index_patterns\":\"logstash-*\",\"template\":{\"settings\":{\"number_of_shards\":1,\"index.lifecycle.name\":\"logstash-policy\",\"index.lifecycle.rollover_alias\":\"logstash\"},\"mappings\":{\"type1\":{\"_source\":{\"enabled\":false},\"properties\":{\"host_name\":{\"type\":\"string\",\"index\":\"not_analyzed\"},\"created_at\":{\"type\":\"date\",\"format\":\"EEE MMM dd HH:mm:ss Z YYYY\"}}}}},\"priority\":101}").
1417
- to_return(status: 200, body: "", headers: {})
1425
+ to_return(status: 200, body: "", headers: {'x-elastic-product' => 'Elasticsearch'})
1418
1426
  end
1419
1427
  # put the alias for the index
1420
1428
  stub_request(:put, "https://logs.google.com:777/es//%3Clogstash-default-%7Bnow%2Fw%7Bxxxx.ww%7D%7D-000001%3E").
1421
1429
  with(basic_auth: ['john', 'doe']).
1422
- to_return(:status => 200, :body => "", :headers => {})
1430
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
1423
1431
  stub_request(:put, "https://logs.google.com:777/es//%3Clogstash-default-%7Bnow%2Fw%7Bxxxx.ww%7D%7D-000001%3E/#{alias_endpoint}/logstash").
1424
1432
  with(basic_auth: ['john', 'doe'],
1425
1433
  :body => "{\"aliases\":{\"logstash\":{\"is_write_index\":true}}}").
1426
- to_return(:status => 200, :body => "", :headers => {})
1434
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
1427
1435
  stub_request(:get, "https://logs.google.com:777/es//_xpack").
1428
1436
  with(basic_auth: ['john', 'doe']).
1429
- to_return(:status => 200, :body => '{"features":{"ilm":{"available":true,"enabled":true}}}', :headers => {"Content-Type"=> "application/json"})
1437
+ to_return(:status => 200, :body => '{"features":{"ilm":{"available":true,"enabled":true}}}', :headers => {"Content-Type"=> "application/json", 'x-elastic-product' => 'Elasticsearch'})
1430
1438
  stub_request(:get, "https://logs.google.com:777/es//#{ilm_endpoint}/policy/logstash-policy").
1431
1439
  with(basic_auth: ['john', 'doe']).
1432
- to_return(:status => 200, :body => "", :headers => {})
1440
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
1433
1441
  stub_request(:put, "https://logs.google.com:777/es//#{ilm_endpoint}/policy/logstash-policy").
1434
1442
  with(basic_auth: ['john', 'doe'],
1435
1443
  :body => "{\"policy\":{\"phases\":{\"hot\":{\"actions\":{\"rollover\":{\"max_size\":\"60gb\",\"max_age\":\"45d\"}}}}}}").
1436
- to_return(:status => 200, :body => "", :headers => {})
1444
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
1437
1445
  stub_elastic_info("https://logs.google.com:777/es//")
1438
1446
 
1439
1447
  driver(config)
@@ -1498,51 +1506,51 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
1498
1506
  # connection start
1499
1507
  stub_request(:head, "https://logs.google.com:777/es//").
1500
1508
  with(basic_auth: ['john', 'doe']).
1501
- to_return(:status => 200, :body => "", :headers => {})
1509
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
1502
1510
  # check if template exists
1503
1511
  stub_request(:get, "https://logs.google.com:777/es//#{endpoint}/logstash").
1504
1512
  with(basic_auth: ['john', 'doe']).
1505
- to_return(:status => 404, :body => "", :headers => {})
1513
+ to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
1506
1514
  # creation
1507
1515
  stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/logstash").
1508
1516
  with(basic_auth: ['john', 'doe']).
1509
- to_return(:status => 200, :body => "", :headers => {})
1517
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
1510
1518
  # check if alias exists
1511
1519
  stub_request(:head, "https://logs.google.com:777/es//_alias/logstash").
1512
1520
  with(basic_auth: ['john', 'doe']).
1513
- to_return(:status => 404, :body => "", :headers => {})
1521
+ to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
1514
1522
  stub_request(:get, "https://logs.google.com:777/es//#{endpoint}/logstash").
1515
1523
  with(basic_auth: ['john', 'doe']).
1516
- to_return(status: 404, body: "", headers: {})
1524
+ to_return(status: 404, body: "", headers: {'x-elastic-product' => 'Elasticsearch'})
1517
1525
  if use_legacy_template_flag
1518
1526
  stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/myapp_deflector").
1519
1527
  with(basic_auth: ['john', 'doe'],
1520
1528
  body: "{\"settings\":{\"number_of_shards\":1,\"index.lifecycle.name\":\"logstash-policy\",\"index.lifecycle.rollover_alias\":\"logstash\"},\"mappings\":{\"type1\":{\"_source\":{\"enabled\":false},\"properties\":{\"host_name\":{\"type\":\"string\",\"index\":\"not_analyzed\"},\"created_at\":{\"type\":\"date\",\"format\":\"EEE MMM dd HH:mm:ss Z YYYY\"}}}},\"index_patterns\":\"logstash-*\",\"order\":51}").
1521
- to_return(status: 200, body: "", headers: {})
1529
+ to_return(status: 200, body: "", headers: {'x-elastic-product' => 'Elasticsearch'})
1522
1530
  else
1523
1531
  stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/myapp_deflector").
1524
1532
  with(basic_auth: ['john', 'doe'],
1525
1533
  body: "{\"index_patterns\":\"logstash-*\",\"template\":{\"settings\":{\"number_of_shards\":1,\"index.lifecycle.name\":\"logstash-policy\",\"index.lifecycle.rollover_alias\":\"logstash\"},\"mappings\":{\"type1\":{\"_source\":{\"enabled\":false},\"properties\":{\"host_name\":{\"type\":\"string\",\"index\":\"not_analyzed\"},\"created_at\":{\"type\":\"date\",\"format\":\"EEE MMM dd HH:mm:ss Z YYYY\"}}}}},\"priority\":101}").
1526
- to_return(status: 200, body: "", headers: {})
1534
+ to_return(status: 200, body: "", headers: {'x-elastic-product' => 'Elasticsearch'})
1527
1535
  end
1528
1536
  # put the alias for the index
1529
1537
  stub_request(:put, "https://logs.google.com:777/es//%3Clogstash-default-000001%3E").
1530
1538
  with(basic_auth: ['john', 'doe']).
1531
- to_return(:status => 200, :body => "", :headers => {})
1539
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
1532
1540
  stub_request(:put, "https://logs.google.com:777/es//%3Clogstash-default-000001%3E/#{alias_endpoint}/logstash").
1533
1541
  with(basic_auth: ['john', 'doe'],
1534
1542
  :body => "{\"aliases\":{\"logstash\":{\"is_write_index\":true}}}").
1535
- to_return(:status => 200, :body => "", :headers => {})
1543
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
1536
1544
  stub_request(:get, "https://logs.google.com:777/es//_xpack").
1537
1545
  with(basic_auth: ['john', 'doe']).
1538
- to_return(:status => 200, :body => '{"features":{"ilm":{"available":true,"enabled":true}}}', :headers => {"Content-Type"=> "application/json"})
1546
+ to_return(:status => 200, :body => '{"features":{"ilm":{"available":true,"enabled":true}}}', :headers => {"Content-Type"=> "application/json", 'x-elastic-product' => 'Elasticsearch'})
1539
1547
  stub_request(:get, "https://logs.google.com:777/es//#{ilm_endpoint}/policy/logstash-policy").
1540
1548
  with(basic_auth: ['john', 'doe']).
1541
- to_return(:status => 404, :body => "", :headers => {})
1549
+ to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
1542
1550
  stub_request(:put, "https://logs.google.com:777/es//#{ilm_endpoint}/policy/logstash-policy").
1543
1551
  with(basic_auth: ['john', 'doe'],
1544
1552
  :body => "{\"policy\":{\"phases\":{\"hot\":{\"actions\":{\"rollover\":{\"max_size\":\"50gb\",\"max_age\":\"30d\"}}}}}}").
1545
- to_return(:status => 200, :body => "", :headers => {})
1553
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
1546
1554
  stub_elastic_info("https://logs.google.com:777/es//")
1547
1555
 
1548
1556
  driver(config)
@@ -1584,50 +1592,50 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
1584
1592
  # connection start
1585
1593
  stub_request(:head, "https://logs.google.com:777/es//").
1586
1594
  with(basic_auth: ['john', 'doe']).
1587
- to_return(:status => 200, :body => "", :headers => {})
1595
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
1588
1596
  # check if template exists
1589
1597
  stub_request(:get, "https://logs.google.com:777/es//#{endpoint}/logstash").
1590
1598
  with(basic_auth: ['john', 'doe']).
1591
- to_return(:status => 404, :body => "", :headers => {})
1599
+ to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
1592
1600
  # creation
1593
1601
  stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/logstash").
1594
1602
  with(basic_auth: ['john', 'doe']).
1595
- to_return(:status => 200, :body => "", :headers => {})
1603
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
1596
1604
  # check if alias exists
1597
1605
  stub_request(:head, "https://logs.google.com:777/es//_alias/logstash").
1598
1606
  with(basic_auth: ['john', 'doe']).
1599
- to_return(:status => 404, :body => "", :headers => {})
1607
+ to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
1600
1608
  stub_request(:get, "https://logs.google.com:777/es//#{endpoint}/logstash").
1601
1609
  with(basic_auth: ['john', 'doe']).
1602
- to_return(status: 404, body: "", headers: {})
1610
+ to_return(status: 404, body: "", headers: {'x-elastic-product' => 'Elasticsearch'})
1603
1611
  if use_legacy_template_flag
1604
1612
  stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/logstash").
1605
1613
  with(basic_auth: ['john', 'doe'],
1606
1614
  body: "{\"settings\":{\"number_of_shards\":1,\"index.lifecycle.name\":\"fluentd-policy\",\"index.lifecycle.rollover_alias\":\"myalogs\"},\"mappings\":{\"type1\":{\"_source\":{\"enabled\":false},\"properties\":{\"host_name\":{\"type\":\"string\",\"index\":\"not_analyzed\"},\"created_at\":{\"type\":\"date\",\"format\":\"EEE MMM dd HH:mm:ss Z YYYY\"}}}},\"index_patterns\":\"mylogs-*\",\"order\":51}").
1607
- to_return(status: 200, body: "", headers: {})
1615
+ to_return(status: 200, body: "", headers: {'x-elastic-product' => 'Elasticsearch'})
1608
1616
  else
1609
1617
  stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/logstash").
1610
1618
  with(basic_auth: ['john', 'doe'],
1611
1619
  body: "{\"index_patterns\":\"logstash-*\",\"template\":{\"settings\":{\"number_of_shards\":1,\"index.lifecycle.name\":\"fluentd-policy\",\"index.lifecycle.rollover_alias\":\"logstash\"},\"mappings\":{\"type1\":{\"_source\":{\"enabled\":false},\"properties\":{\"host_name\":{\"type\":\"string\",\"index\":\"not_analyzed\"},\"created_at\":{\"type\":\"date\",\"format\":\"EEE MMM dd HH:mm:ss Z YYYY\"}}}}},\"priority\":101}").
1612
- to_return(status: 200, body: "", headers: {})
1620
+ to_return(status: 200, body: "", headers: {'x-elastic-product' => 'Elasticsearch'})
1613
1621
  end
1614
1622
  # put the alias for the index
1615
1623
  stub_request(:put, "https://logs.google.com:777/es//%3Clogstash-default-%7Bnow%2Fw%7Bxxxx.ww%7D%7D-000001%3E").
1616
1624
  with(basic_auth: ['john', 'doe']).
1617
- to_return(:status => 200, :body => "", :headers => {})
1625
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
1618
1626
  stub_request(:put, "https://logs.google.com:777/es//%3Clogstash-default-%7Bnow%2Fw%7Bxxxx.ww%7D%7D-000001%3E/#{alias_endpoint}/logstash").
1619
1627
  with(body: "{\"aliases\":{\"logstash\":{\"is_write_index\":true}}}").
1620
- to_return(status: 200, body: "", headers: {})
1628
+ to_return(status: 200, body: "", headers: {'x-elastic-product' => 'Elasticsearch'})
1621
1629
  stub_request(:get, "https://logs.google.com:777/es//_xpack").
1622
1630
  with(basic_auth: ['john', 'doe']).
1623
- to_return(:status => 200, :body => '{"features":{"ilm":{"available":true,"enabled":true}}}', :headers => {"Content-Type"=> "application/json"})
1631
+ to_return(:status => 200, :body => '{"features":{"ilm":{"available":true,"enabled":true}}}', :headers => {"Content-Type"=> "application/json", 'x-elastic-product' => 'Elasticsearch'})
1624
1632
  stub_request(:get, "https://logs.google.com:777/es//#{ilm_endpoint}/policy/fluentd-policy").
1625
1633
  with(basic_auth: ['john', 'doe']).
1626
- to_return(:status => 404, :body => "", :headers => {})
1634
+ to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
1627
1635
  stub_request(:put, "https://logs.google.com:777/es//#{ilm_endpoint}/policy/fluentd-policy").
1628
1636
  with(basic_auth: ['john', 'doe'],
1629
1637
  :body => "{\"policy\":{\"phases\":{\"hot\":{\"actions\":{\"rollover\":{\"max_size\":\"70gb\",\"max_age\":\"30d\"}}}}}}").
1630
- to_return(:status => 200, :body => "", :headers => {})
1638
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
1631
1639
  stub_elastic_info("https://logs.google.com:777/es//")
1632
1640
 
1633
1641
  driver(config)
@@ -1669,50 +1677,50 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
1669
1677
  # connection start
1670
1678
  stub_request(:head, "https://logs.google.com:777/es//").
1671
1679
  with(basic_auth: ['john', 'doe']).
1672
- to_return(:status => 200, :body => "", :headers => {})
1680
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
1673
1681
  # check if template exists
1674
1682
  stub_request(:get, "https://logs.google.com:777/es//#{endpoint}/logstash").
1675
1683
  with(basic_auth: ['john', 'doe']).
1676
- to_return(:status => 404, :body => "", :headers => {})
1684
+ to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
1677
1685
  # creation
1678
1686
  stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/logstash").
1679
1687
  with(basic_auth: ['john', 'doe']).
1680
- to_return(:status => 200, :body => "", :headers => {})
1688
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
1681
1689
  # check if alias exists
1682
1690
  stub_request(:head, "https://logs.google.com:777/es//_alias/logstash").
1683
1691
  with(basic_auth: ['john', 'doe']).
1684
- to_return(:status => 404, :body => "", :headers => {})
1692
+ to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
1685
1693
  stub_request(:get, "https://logs.google.com:777/es//#{endpoint}/logstash").
1686
1694
  with(basic_auth: ['john', 'doe']).
1687
- to_return(status: 404, body: "", headers: {})
1695
+ to_return(status: 404, body: "", headers: {'x-elastic-product' => 'Elasticsearch'})
1688
1696
  if use_legacy_template_flag
1689
1697
  stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/logstash").
1690
1698
  with(basic_auth: ['john', 'doe'],
1691
1699
  body: "{\"settings\":{\"number_of_shards\":1,\"index.lifecycle.name\":\"fluentd-policy\",\"index.lifecycle.rollover_alias\":\"myalogs\"},\"mappings\":{\"type1\":{\"_source\":{\"enabled\":false},\"properties\":{\"host_name\":{\"type\":\"string\",\"index\":\"not_analyzed\"},\"created_at\":{\"type\":\"date\",\"format\":\"EEE MMM dd HH:mm:ss Z YYYY\"}}}},\"index_patterns\":\"mylogs-*\",\"order\":51}").
1692
- to_return(status: 200, body: "", headers: {})
1700
+ to_return(status: 200, body: "", headers: {'x-elastic-product' => 'Elasticsearch'})
1693
1701
  else
1694
1702
  stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/logstash").
1695
1703
  with(basic_auth: ['john', 'doe'],
1696
1704
  body: "{\"index_patterns\":\"logstash-*\",\"template\":{\"settings\":{\"number_of_shards\":1,\"index.lifecycle.name\":\"fluentd-policy\",\"index.lifecycle.rollover_alias\":\"logstash\"},\"mappings\":{\"type1\":{\"_source\":{\"enabled\":false},\"properties\":{\"host_name\":{\"type\":\"string\",\"index\":\"not_analyzed\"},\"created_at\":{\"type\":\"date\",\"format\":\"EEE MMM dd HH:mm:ss Z YYYY\"}}}}},\"priority\":101}").
1697
- to_return(status: 200, body: "", headers: {})
1705
+ to_return(status: 200, body: "", headers: {'x-elastic-product' => 'Elasticsearch'})
1698
1706
  end
1699
1707
  # put the alias for the index
1700
1708
  stub_request(:put, "https://logs.google.com:777/es//%3Clogstash-default-%7Bnow%2Fw%7Bxxxx.ww%7D%7D-000001%3E").
1701
1709
  with(basic_auth: ['john', 'doe']).
1702
- to_return(:status => 200, :body => "", :headers => {})
1710
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
1703
1711
  stub_request(:put, "https://logs.google.com:777/es//%3Clogstash-default-%7Bnow%2Fw%7Bxxxx.ww%7D%7D-000001%3E/#{alias_endpoint}/logstash").
1704
1712
  with(body: "{\"aliases\":{\"logstash\":{\"is_write_index\":true}}}").
1705
- to_return(status: 200, body: "", headers: {})
1713
+ to_return(status: 200, body: "", headers: {'x-elastic-product' => 'Elasticsearch'})
1706
1714
  stub_request(:get, "https://logs.google.com:777/es//_xpack").
1707
1715
  with(basic_auth: ['john', 'doe']).
1708
- to_return(:status => 200, :body => '{"features":{"ilm":{"available":true,"enabled":true}}}', :headers => {"Content-Type"=> "application/json"})
1716
+ to_return(:status => 200, :body => '{"features":{"ilm":{"available":true,"enabled":true}}}', :headers => {"Content-Type"=> "application/json", 'x-elastic-product' => 'Elasticsearch'})
1709
1717
  stub_request(:get, "https://logs.google.com:777/es//#{ilm_endpoint}/policy/fluentd-policy").
1710
1718
  with(basic_auth: ['john', 'doe']).
1711
- to_return(:status => 404, :body => "", :headers => {})
1719
+ to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
1712
1720
  stub_request(:put, "https://logs.google.com:777/es//#{ilm_endpoint}/policy/fluentd-policy").
1713
1721
  with(basic_auth: ['john', 'doe'],
1714
1722
  :body => "{\"policy\":{\"phases\":{\"hot\":{\"actions\":{\"rollover\":{\"max_size\":\"70gb\",\"max_age\":\"30d\"}}}}}}").
1715
- to_return(:status => 200, :body => "", :headers => {})
1723
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
1716
1724
  stub_elastic_info("https://logs.google.com:777/es//")
1717
1725
 
1718
1726
  driver(config)
@@ -1761,50 +1769,50 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
1761
1769
  # connection start
1762
1770
  stub_request(:head, "https://logs.google.com:777/es//").
1763
1771
  with(basic_auth: ['john', 'doe']).
1764
- to_return(:status => 200, :body => "", :headers => {})
1772
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
1765
1773
  # check if template exists
1766
1774
  stub_request(:get, "https://logs.google.com:777/es//#{endpoint}/logstash").
1767
1775
  with(basic_auth: ['john', 'doe']).
1768
- to_return(:status => 404, :body => "", :headers => {})
1776
+ to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
1769
1777
  # creation
1770
1778
  stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/logstash").
1771
1779
  with(basic_auth: ['john', 'doe']).
1772
- to_return(:status => 200, :body => "", :headers => {})
1780
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
1773
1781
  # check if alias exists
1774
1782
  stub_request(:head, "https://logs.google.com:777/es//_alias/logstash").
1775
1783
  with(basic_auth: ['john', 'doe']).
1776
- to_return(:status => 404, :body => "", :headers => {})
1784
+ to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
1777
1785
  stub_request(:get, "https://logs.google.com:777/es//#{endpoint}/logstash").
1778
1786
  with(basic_auth: ['john', 'doe']).
1779
- to_return(status: 404, body: "", headers: {})
1787
+ to_return(status: 404, body: "", headers: {'x-elastic-product' => 'Elasticsearch'})
1780
1788
  if use_legacy_template_flag
1781
1789
  stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/logstash").
1782
1790
  with(basic_auth: ['john', 'doe'],
1783
1791
  body: "{\"settings\":{\"number_of_shards\":1,\"index.lifecycle.name\":\"fluentd-policy\",\"index.lifecycle.rollover_alias\":\"myalogs\"},\"mappings\":{\"type1\":{\"_source\":{\"enabled\":false},\"properties\":{\"host_name\":{\"type\":\"string\",\"index\":\"not_analyzed\"},\"created_at\":{\"type\":\"date\",\"format\":\"EEE MMM dd HH:mm:ss Z YYYY\"}}}},\"index_patterns\":\"mylogs-*\",\"order\":51}").
1784
- to_return(status: 200, body: "", headers: {})
1792
+ to_return(status: 200, body: "", headers: {'x-elastic-product' => 'Elasticsearch'})
1785
1793
  else
1786
1794
  stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/logstash").
1787
1795
  with(basic_auth: ['john', 'doe'],
1788
1796
  body: "{\"index_patterns\":\"logstash-*\",\"template\":{\"settings\":{\"number_of_shards\":1,\"index.lifecycle.name\":\"fluentd-policy\",\"index.lifecycle.rollover_alias\":\"logstash\"},\"mappings\":{\"type1\":{\"_source\":{\"enabled\":false},\"properties\":{\"host_name\":{\"type\":\"string\",\"index\":\"not_analyzed\"},\"created_at\":{\"type\":\"date\",\"format\":\"EEE MMM dd HH:mm:ss Z YYYY\"}}}}},\"priority\":101}").
1789
- to_return(status: 200, body: "", headers: {})
1797
+ to_return(status: 200, body: "", headers: {'x-elastic-product' => 'Elasticsearch'})
1790
1798
  end
1791
1799
  # put the alias for the index
1792
1800
  stub_request(:put, "https://logs.google.com:777/es//%3Clogstash-default-%7Bnow%2Fw%7Bxxxx.ww%7D%7D-000001%3E").
1793
1801
  with(basic_auth: ['john', 'doe']).
1794
- to_return(:status => 200, :body => "", :headers => {})
1802
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
1795
1803
  stub_request(:put, "https://logs.google.com:777/es//%3Clogstash-default-%7Bnow%2Fw%7Bxxxx.ww%7D%7D-000001%3E/#{alias_endpoint}/logstash").
1796
1804
  with(body: "{\"aliases\":{\"logstash\":{\"is_write_index\":true}}}").
1797
- to_return(status: 200, body: "", headers: {})
1805
+ to_return(status: 200, body: "", headers: {'x-elastic-product' => 'Elasticsearch'})
1798
1806
  stub_request(:get, "https://logs.google.com:777/es//_xpack").
1799
1807
  with(basic_auth: ['john', 'doe']).
1800
- to_return(:status => 200, :body => '{"features":{"ilm":{"available":true,"enabled":true}}}', :headers => {"Content-Type"=> "application/json"})
1808
+ to_return(:status => 200, :body => '{"features":{"ilm":{"available":true,"enabled":true}}}', :headers => {"Content-Type"=> "application/json", 'x-elastic-product' => 'Elasticsearch'})
1801
1809
  stub_request(:get, "https://logs.google.com:777/es//#{ilm_endpoint}/policy/fluentd-policy").
1802
1810
  with(basic_auth: ['john', 'doe']).
1803
- to_return(:status => 404, :body => "", :headers => {})
1811
+ to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
1804
1812
  stub_request(:put, "https://logs.google.com:777/es//#{ilm_endpoint}/policy/fluentd-policy").
1805
1813
  with(basic_auth: ['john', 'doe'],
1806
1814
  body: "{\"policy\":{\"phases\":{\"hot\":{\"actions\":{\"rollover\":{\"max_size\":\"70gb\",\"max_age\":\"30d\"}}}}}}").
1807
- to_return(:status => 200, :body => "", :headers => {})
1815
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
1808
1816
  stub_elastic_info("https://logs.google.com:777/es//")
1809
1817
 
1810
1818
  driver(config)
@@ -1852,50 +1860,50 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
1852
1860
  # connection start
1853
1861
  stub_request(:head, "https://logs.google.com:777/es//").
1854
1862
  with(basic_auth: ['john', 'doe']).
1855
- to_return(:status => 200, :body => "", :headers => {})
1863
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
1856
1864
  # check if template exists
1857
1865
  stub_request(:get, "https://logs.google.com:777/es//#{endpoint}/logstash").
1858
1866
  with(basic_auth: ['john', 'doe']).
1859
- to_return(:status => 404, :body => "", :headers => {})
1867
+ to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
1860
1868
  # creation
1861
1869
  stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/logstash").
1862
1870
  with(basic_auth: ['john', 'doe']).
1863
- to_return(:status => 200, :body => "", :headers => {})
1871
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
1864
1872
  # check if alias exists
1865
1873
  stub_request(:head, "https://logs.google.com:777/es//_alias/logstash").
1866
1874
  with(basic_auth: ['john', 'doe']).
1867
- to_return(:status => 404, :body => "", :headers => {})
1875
+ to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
1868
1876
  stub_request(:get, "https://logs.google.com:777/es//#{endpoint}/logstash").
1869
1877
  with(basic_auth: ['john', 'doe']).
1870
- to_return(status: 404, body: "", headers: {})
1878
+ to_return(status: 404, body: "", headers: {'x-elastic-product' => 'Elasticsearch'})
1871
1879
  if use_legacy_template_flag
1872
1880
  stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/logstash").
1873
1881
  with(basic_auth: ['john', 'doe'],
1874
1882
  body: "{\"settings\":{\"number_of_shards\":1,\"index.lifecycle.name\":\"fluentd-policy2\",\"index.lifecycle.rollover_alias\":\"logstash\"},\"mappings\":{\"type1\":{\"_source\":{\"enabled\":false},\"properties\":{\"host_name\":{\"type\":\"string\",\"index\":\"not_analyzed\"},\"created_at\":{\"type\":\"date\",\"format\":\"EEE MMM dd HH:mm:ss Z YYYY\"}}}},\"index_patterns\":\"logstash-*\",\"order\":51}").
1875
- to_return(status: 200, body: "", headers: {})
1883
+ to_return(status: 200, body: "", headers: {'x-elastic-product' => 'Elasticsearch'})
1876
1884
  else
1877
1885
  stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/logstash").
1878
1886
  with(basic_auth: ['john', 'doe'],
1879
1887
  body: "{\"index_patterns\":\"logstash-*\",\"template\":{\"settings\":{\"number_of_shards\":1,\"index.lifecycle.name\":\"fluentd-policy2\",\"index.lifecycle.rollover_alias\":\"logstash\"},\"mappings\":{\"type1\":{\"_source\":{\"enabled\":false},\"properties\":{\"host_name\":{\"type\":\"string\",\"index\":\"not_analyzed\"},\"created_at\":{\"type\":\"date\",\"format\":\"EEE MMM dd HH:mm:ss Z YYYY\"}}}}},\"priority\":101}").
1880
- to_return(status: 200, body: "", headers: {})
1888
+ to_return(status: 200, body: "", headers: {'x-elastic-product' => 'Elasticsearch'})
1881
1889
  end
1882
1890
  # put the alias for the index
1883
1891
  stub_request(:put, "https://logs.google.com:777/es//%3Clogstash-default-%7Bnow%2Fw%7Bxxxx.ww%7D%7D-000001%3E").
1884
1892
  with(basic_auth: ['john', 'doe']).
1885
- to_return(:status => 200, :body => "", :headers => {})
1893
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
1886
1894
  stub_request(:put, "https://logs.google.com:777/es//%3Clogstash-default-%7Bnow%2Fw%7Bxxxx.ww%7D%7D-000001%3E/#{alias_endpoint}/logstash").
1887
1895
  with(body: "{\"aliases\":{\"logstash\":{\"is_write_index\":true}}}").
1888
- to_return(status: 200, body: "", headers: {})
1896
+ to_return(status: 200, body: "", headers: {'x-elastic-product' => 'Elasticsearch'})
1889
1897
  stub_request(:get, "https://logs.google.com:777/es//_xpack").
1890
1898
  with(basic_auth: ['john', 'doe']).
1891
- to_return(:status => 200, :body => '{"features":{"ilm":{"available":true,"enabled":true}}}', :headers => {"Content-Type"=> "application/json"})
1899
+ to_return(:status => 200, :body => '{"features":{"ilm":{"available":true,"enabled":true}}}', :headers => {"Content-Type"=> "application/json", 'x-elastic-product' => 'Elasticsearch'})
1892
1900
  stub_request(:get, "https://logs.google.com:777/es//#{ilm_endpoint}/policy/fluentd-policy2").
1893
1901
  with(basic_auth: ['john', 'doe']).
1894
- to_return(:status => 404, :body => "", :headers => {})
1902
+ to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
1895
1903
  stub_request(:put, "https://logs.google.com:777/es//#{ilm_endpoint}/policy/fluentd-policy2").
1896
1904
  with(basic_auth: ['john', 'doe'],
1897
1905
  body: "{\"policy\":{\"phases\":{\"hot\":{\"actions\":{\"rollover\":{\"max_size\":\"80gb\",\"max_age\":\"20d\"}}}}}}").
1898
- to_return(:status => 200, :body => "", :headers => {})
1906
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
1899
1907
  stub_elastic_info("https://logs.google.com:777/es//")
1900
1908
 
1901
1909
  driver(config)
@@ -1942,86 +1950,86 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
1942
1950
  # connection start
1943
1951
  stub_request(:head, "https://logs.google.com:777/es//").
1944
1952
  with(basic_auth: ['john', 'doe']).
1945
- to_return(:status => 200, :body => "", :headers => {})
1953
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
1946
1954
  # check if template exists
1947
1955
  stub_request(:get, "https://logs.google.com:777/es//#{endpoint}/logstash").
1948
1956
  with(basic_auth: ['john', 'doe']).
1949
- to_return(:status => 404, :body => "", :headers => {})
1957
+ to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
1950
1958
  # creation
1951
1959
  stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/logstash").
1952
1960
  with(basic_auth: ['john', 'doe']).
1953
- to_return(:status => 200, :body => "", :headers => {})
1961
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
1954
1962
  # check if alias exists
1955
1963
  stub_request(:head, "https://logs.google.com:777/es//_alias/logstash-tag1").
1956
1964
  with(basic_auth: ['john', 'doe']).
1957
- to_return(:status => 404, :body => "", :headers => {})
1965
+ to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
1958
1966
  stub_request(:get, "https://logs.google.com:777/es//#{endpoint}/logstash-tag1").
1959
1967
  with(basic_auth: ['john', 'doe']).
1960
- to_return(status: 404, body: "", headers: {})
1968
+ to_return(status: 404, body: "", headers: {'x-elastic-product' => 'Elasticsearch'})
1961
1969
  if use_legacy_template_flag
1962
1970
  stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/logstash-tag1").
1963
1971
  with(basic_auth: ['john', 'doe'],
1964
1972
  body: "{\"settings\":{\"number_of_shards\":1,\"index.lifecycle.name\":\"logstash-policy\",\"index.lifecycle.rollover_alias\":\"logstash-tag1\"},\"mappings\":{\"type1\":{\"_source\":{\"enabled\":false},\"properties\":{\"host_name\":{\"type\":\"string\",\"index\":\"not_analyzed\"},\"created_at\":{\"type\":\"date\",\"format\":\"EEE MMM dd HH:mm:ss Z YYYY\"}}}},\"index_patterns\":\"logstash-tag1-*\",\"order\":52}").
1965
- to_return(status: 200, body: "", headers: {})
1973
+ to_return(status: 200, body: "", headers: {'x-elastic-product' => 'Elasticsearch'})
1966
1974
  else
1967
1975
  stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/logstash-tag1").
1968
1976
  with(basic_auth: ['john', 'doe'],
1969
1977
  body: "{\"index_patterns\":\"logstash-tag1-*\",\"template\":{\"settings\":{\"number_of_shards\":1,\"index.lifecycle.name\":\"logstash-policy\",\"index.lifecycle.rollover_alias\":\"logstash-tag1\"},\"mappings\":{\"type1\":{\"_source\":{\"enabled\":false},\"properties\":{\"host_name\":{\"type\":\"string\",\"index\":\"not_analyzed\"},\"created_at\":{\"type\":\"date\",\"format\":\"EEE MMM dd HH:mm:ss Z YYYY\"}}}}},\"priority\":102}").
1970
- to_return(status: 200, body: "", headers: {})
1978
+ to_return(status: 200, body: "", headers: {'x-elastic-product' => 'Elasticsearch'})
1971
1979
  end
1972
1980
  # put the alias for the index
1973
1981
  stub_request(:put, "https://logs.google.com:777/es//%3Clogstash-tag1-default-%7Bnow%2Fw%7Bxxxx.ww%7D%7D-000001%3E").
1974
1982
  with(basic_auth: ['john', 'doe']).
1975
- to_return(:status => 200, :body => "", :headers => {})
1983
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
1976
1984
  stub_request(:put, "https://logs.google.com:777/es//%3Clogstash-tag1-default-%7Bnow%2Fw%7Bxxxx.ww%7D%7D-000001%3E/#{alias_endpoint}/logstash-tag1").
1977
1985
  with(basic_auth: ['john', 'doe'],
1978
1986
  :body => "{\"aliases\":{\"logstash-tag1\":{\"is_write_index\":true}}}").
1979
- to_return(:status => 200, :body => "", :headers => {})
1987
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
1980
1988
  stub_request(:get, "https://logs.google.com:777/es//_xpack").
1981
1989
  with(basic_auth: ['john', 'doe']).
1982
- to_return(:status => 200, :body => '{"features":{"ilm":{"available":true,"enabled":true}}}', :headers => {"Content-Type"=> "application/json"})
1990
+ to_return(:status => 200, :body => '{"features":{"ilm":{"available":true,"enabled":true}}}', :headers => {"Content-Type"=> "application/json", 'x-elastic-product' => 'Elasticsearch'})
1983
1991
  stub_request(:get, "https://logs.google.com:777/es//#{ilm_endpoint}/policy/logstash-policy").
1984
1992
  with(basic_auth: ['john', 'doe']).
1985
- to_return(:status => 404, :body => "", :headers => {})
1993
+ to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
1986
1994
  stub_request(:put, "https://logs.google.com:777/es//#{ilm_endpoint}/policy/logstash-policy").
1987
1995
  with(basic_auth: ['john', 'doe'],
1988
1996
  :body => "{\"policy\":{\"phases\":{\"hot\":{\"actions\":{\"rollover\":{\"max_size\":\"50gb\",\"max_age\":\"30d\"}}}}}}").
1989
- to_return(:status => 200, :body => "", :headers => {})
1997
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
1990
1998
  # check if alias exists
1991
1999
  stub_request(:head, "https://logs.google.com:777/es//_alias/logstash-tag2").
1992
2000
  with(basic_auth: ['john', 'doe']).
1993
- to_return(:status => 404, :body => "", :headers => {})
2001
+ to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
1994
2002
  stub_request(:get, "https://logs.google.com:777/es//#{endpoint}/logstash-tag2").
1995
2003
  with(basic_auth: ['john', 'doe']).
1996
- to_return(status: 404, body: "", headers: {})
2004
+ to_return(status: 404, body: "", headers: {'x-elastic-product' => 'Elasticsearch'})
1997
2005
  if use_legacy_template_flag
1998
2006
  stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/logstash-tag2").
1999
2007
  with(basic_auth: ['john', 'doe'],
2000
2008
  body: "{\"settings\":{\"number_of_shards\":1,\"index.lifecycle.name\":\"logstash-policy\",\"index.lifecycle.rollover_alias\":\"logstash-tag2\"},\"mappings\":{\"type1\":{\"_source\":{\"enabled\":false},\"properties\":{\"host_name\":{\"type\":\"string\",\"index\":\"not_analyzed\"},\"created_at\":{\"type\":\"date\",\"format\":\"EEE MMM dd HH:mm:ss Z YYYY\"}}}},\"index_patterns\":\"logstash-tag2-*\",\"order\":52}").
2001
- to_return(status: 200, body: "", headers: {})
2009
+ to_return(status: 200, body: "", headers: {'x-elastic-product' => 'Elasticsearch'})
2002
2010
  else
2003
2011
  stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/logstash-tag2").
2004
2012
  with(basic_auth: ['john', 'doe'],
2005
2013
  body: "{\"index_patterns\":\"logstash-tag2-*\",\"template\":{\"settings\":{\"number_of_shards\":1,\"index.lifecycle.name\":\"logstash-policy\",\"index.lifecycle.rollover_alias\":\"logstash-tag2\"},\"mappings\":{\"type1\":{\"_source\":{\"enabled\":false},\"properties\":{\"host_name\":{\"type\":\"string\",\"index\":\"not_analyzed\"},\"created_at\":{\"type\":\"date\",\"format\":\"EEE MMM dd HH:mm:ss Z YYYY\"}}}}},\"priority\":102}").
2006
- to_return(status: 200, body: "", headers: {})
2014
+ to_return(status: 200, body: "", headers: {'x-elastic-product' => 'Elasticsearch'})
2007
2015
  end # put the alias for the index
2008
2016
  stub_request(:put, "https://logs.google.com:777/es//%3Clogstash-tag2-default-%7Bnow%2Fw%7Bxxxx.ww%7D%7D-000001%3E").
2009
2017
  with(basic_auth: ['john', 'doe']).
2010
- to_return(:status => 200, :body => "", :headers => {})
2018
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
2011
2019
  stub_request(:put, "https://logs.google.com:777/es//%3Clogstash-tag2-default-%7Bnow%2Fw%7Bxxxx.ww%7D%7D-000001%3E/#{alias_endpoint}/logstash-tag2").
2012
2020
  with(basic_auth: ['john', 'doe'],
2013
2021
  :body => "{\"aliases\":{\"logstash-tag2\":{\"is_write_index\":true}}}").
2014
- to_return(:status => 200, :body => "", :headers => {})
2022
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
2015
2023
  stub_request(:get, "https://logs.google.com:777/es//_xpack").
2016
2024
  with(basic_auth: ['john', 'doe']).
2017
- to_return(:status => 200, :body => '{"features":{"ilm":{"available":true,"enabled":true}}}', :headers => {"Content-Type"=> "application/json"})
2025
+ to_return(:status => 200, :body => '{"features":{"ilm":{"available":true,"enabled":true}}}', :headers => {"Content-Type"=> "application/json", 'x-elastic-product' => 'Elasticsearch'})
2018
2026
  stub_request(:get, "https://logs.google.com:777/es//#{ilm_endpoint}/policy/logstash-policy").
2019
2027
  with(basic_auth: ['john', 'doe']).
2020
- to_return(:status => 404, :body => "", :headers => {})
2028
+ to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
2021
2029
  stub_request(:put, "https://logs.google.com:777/es//#{ilm_endpoint}/policy/logstash-policy").
2022
2030
  with(basic_auth: ['john', 'doe'],
2023
2031
  :body => "{\"policy\":{\"phases\":{\"hot\":{\"actions\":{\"rollover\":{\"max_size\":\"50gb\",\"max_age\":\"30d\"}}}}}}").
2024
- to_return(:status => 200, :body => "", :headers => {})
2032
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
2025
2033
  stub_elastic_info("https://logs.google.com:777/es//")
2026
2034
 
2027
2035
  driver(config)
@@ -2074,51 +2082,51 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
2074
2082
  # connection start
2075
2083
  stub_request(:head, "https://logs.google.com:777/es//").
2076
2084
  with(basic_auth: ['john', 'doe']).
2077
- to_return(:status => 200, :body => "", :headers => {})
2085
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
2078
2086
  # check if template exists
2079
2087
  stub_request(:get, "https://logs.google.com:777/es//#{endpoint}/logstash").
2080
2088
  with(basic_auth: ['john', 'doe']).
2081
- to_return(:status => 404, :body => "", :headers => {})
2089
+ to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
2082
2090
  # creation
2083
2091
  stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/logstash").
2084
2092
  with(basic_auth: ['john', 'doe']).
2085
- to_return(:status => 200, :body => "", :headers => {})
2093
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
2086
2094
  # check if alias exists
2087
2095
  stub_request(:head, "https://logs.google.com:777/es//_alias/logstash.tag1").
2088
2096
  with(basic_auth: ['john', 'doe']).
2089
- to_return(:status => 404, :body => "", :headers => {})
2097
+ to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
2090
2098
  stub_request(:get, "https://logs.google.com:777/es//#{endpoint}/logstash.tag1").
2091
2099
  with(basic_auth: ['john', 'doe']).
2092
- to_return(status: 404, body: "", headers: {})
2100
+ to_return(status: 404, body: "", headers: {'x-elastic-product' => 'Elasticsearch'})
2093
2101
  if use_legacy_template_flag
2094
2102
  stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/logstash.tag1").
2095
2103
  with(basic_auth: ['john', 'doe'],
2096
2104
  body: "{\"settings\":{\"number_of_shards\":1,\"index.lifecycle.name\":\"logstash-policy\",\"index.lifecycle.rollover_alias\":\"logstash.tag1\"},\"mappings\":{\"type1\":{\"_source\":{\"enabled\":false},\"properties\":{\"host_name\":{\"type\":\"string\",\"index\":\"not_analyzed\"},\"created_at\":{\"type\":\"date\",\"format\":\"EEE MMM dd HH:mm:ss Z YYYY\"}}}},\"index_patterns\":\"logstash.tag1.*\",\"order\":52}").
2097
- to_return(status: 200, body: "", headers: {})
2105
+ to_return(status: 200, body: "", headers: {'x-elastic-product' => 'Elasticsearch'})
2098
2106
  else
2099
2107
  stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/logstash.tag1").
2100
2108
  with(basic_auth: ['john', 'doe'],
2101
2109
  body: "{\"index_patterns\":\"logstash.tag1.*\",\"template\":{\"settings\":{\"number_of_shards\":1,\"index.lifecycle.name\":\"logstash-policy\",\"index.lifecycle.rollover_alias\":\"logstash.tag1\"},\"mappings\":{\"type1\":{\"_source\":{\"enabled\":false},\"properties\":{\"host_name\":{\"type\":\"string\",\"index\":\"not_analyzed\"},\"created_at\":{\"type\":\"date\",\"format\":\"EEE MMM dd HH:mm:ss Z YYYY\"}}}}},\"priority\":102}").
2102
- to_return(status: 200, body: "", headers: {})
2110
+ to_return(status: 200, body: "", headers: {'x-elastic-product' => 'Elasticsearch'})
2103
2111
  end
2104
2112
  # put the alias for the index
2105
2113
  stub_request(:put, "https://logs.google.com:777/es//%3Clogstash.tag1.default-%7Bnow%2Fw%7Bxxxx.ww%7D%7D-000001%3E").
2106
2114
  with(basic_auth: ['john', 'doe']).
2107
- to_return(:status => 200, :body => "", :headers => {})
2115
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
2108
2116
  stub_request(:put, "https://logs.google.com:777/es//%3Clogstash.tag1.default-%7Bnow%2Fw%7Bxxxx.ww%7D%7D-000001%3E/#{alias_endpoint}/logstash.tag1").
2109
2117
  with(basic_auth: ['john', 'doe'],
2110
2118
  :body => "{\"aliases\":{\"logstash.tag1\":{\"is_write_index\":true}}}").
2111
- to_return(:status => 200, :body => "", :headers => {})
2119
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
2112
2120
  stub_request(:get, "https://logs.google.com:777/es//_xpack").
2113
2121
  with(basic_auth: ['john', 'doe']).
2114
- to_return(:status => 200, :body => '{"features":{"ilm":{"available":true,"enabled":true}}}', :headers => {"Content-Type"=> "application/json"})
2122
+ to_return(:status => 200, :body => '{"features":{"ilm":{"available":true,"enabled":true}}}', :headers => {"Content-Type"=> "application/json", 'x-elastic-product' => 'Elasticsearch'})
2115
2123
  stub_request(:get, "https://logs.google.com:777/es//#{ilm_endpoint}/policy/logstash-policy").
2116
2124
  with(basic_auth: ['john', 'doe']).
2117
- to_return(:status => 404, :body => "", :headers => {})
2125
+ to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
2118
2126
  stub_request(:put, "https://logs.google.com:777/es//#{ilm_endpoint}/policy/logstash-policy").
2119
2127
  with(basic_auth: ['john', 'doe'],
2120
2128
  :body => "{\"policy\":{\"phases\":{\"hot\":{\"actions\":{\"rollover\":{\"max_size\":\"50gb\",\"max_age\":\"30d\"}}}}}}").
2121
- to_return(:status => 200, :body => "", :headers => {})
2129
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
2122
2130
  stub_elastic_info("https://logs.google.com:777/es//")
2123
2131
 
2124
2132
  driver(config)
@@ -2177,45 +2185,45 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
2177
2185
  # connection start
2178
2186
  stub_request(:head, "https://logs.google.com:777/es//").
2179
2187
  with(basic_auth: ['john', 'doe']).
2180
- to_return(:status => 200, :body => "", :headers => {})
2188
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
2181
2189
  # check if template exists
2182
2190
  stub_request(:get, "https://logs.google.com:777/es//#{endpoint}/#{task_def_value}-#{date_str}").
2183
2191
  with(basic_auth: ['john', 'doe']).
2184
- to_return(:status => 404, :body => "", :headers => {})
2192
+ to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
2185
2193
  # creation
2186
2194
  if use_legacy_template_flag
2187
2195
  stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/#{task_def_value}-#{date_str}").
2188
2196
  with(basic_auth: ['john', 'doe'],
2189
2197
  body: "{\"settings\":{\"number_of_shards\":1,\"index.lifecycle.name\":\"logstash-policy\",\"index.lifecycle.rollover_alias\":\"#{task_def_value}-#{date_str}\"},\"mappings\":{\"type1\":{\"_source\":{\"enabled\":false},\"properties\":{\"host_name\":{\"type\":\"string\",\"index\":\"not_analyzed\"},\"created_at\":{\"type\":\"date\",\"format\":\"EEE MMM dd HH:mm:ss Z YYYY\"}}}},\"index_patterns\":\"#{task_def_value}-#{date_str}-*\",\"order\":52}").
2190
- to_return(:status => 200, :body => "", :headers => {})
2198
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
2191
2199
  else
2192
2200
  stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/#{task_def_value}-#{date_str}").
2193
2201
  with(basic_auth: ['john', 'doe'],
2194
2202
  body: "{\"index_patterns\":\"task_definition-#{date_str}-*\",\"template\":{\"settings\":{\"number_of_shards\":1,\"index.lifecycle.name\":\"logstash-policy\",\"index.lifecycle.rollover_alias\":\"task_definition-#{date_str}\"},\"mappings\":{\"type1\":{\"_source\":{\"enabled\":false},\"properties\":{\"host_name\":{\"type\":\"string\",\"index\":\"not_analyzed\"},\"created_at\":{\"type\":\"date\",\"format\":\"EEE MMM dd HH:mm:ss Z YYYY\"}}}}},\"priority\":102}").
2195
- to_return(:status => 200, :body => "", :headers => {})
2203
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
2196
2204
  end
2197
2205
  # check if alias exists
2198
2206
  stub_request(:head, "https://logs.google.com:777/es//_alias/#{task_def_value}-#{date_str}").
2199
2207
  with(basic_auth: ['john', 'doe']).
2200
- to_return(:status => 404, :body => "", :headers => {})
2208
+ to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
2201
2209
  # put the alias for the index
2202
2210
  stub_request(:put, "https://logs.google.com:777/es//%3C#{task_def_value}-#{date_str}-default-%7Bnow%2Fw%7Bxxxx.ww%7D%7D-000001%3E").
2203
2211
  with(basic_auth: ['john', 'doe']).
2204
- to_return(:status => 200, :body => "", :headers => {})
2212
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
2205
2213
  stub_request(:put, "https://logs.google.com:777/es//%3C#{task_def_value}-#{date_str}-default-%7Bnow%2Fw%7Bxxxx.ww%7D%7D-000001%3E/#{alias_endpoint}/#{task_def_value}-#{date_str}").
2206
2214
  with(basic_auth: ['john', 'doe'],
2207
2215
  :body => "{\"aliases\":{\"#{task_def_value}-#{date_str}\":{\"is_write_index\":true}}}").
2208
- to_return(:status => 200, :body => "", :headers => {})
2216
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
2209
2217
  stub_request(:get, "https://logs.google.com:777/es//_xpack").
2210
2218
  with(basic_auth: ['john', 'doe']).
2211
- to_return(:status => 200, :body => '{"features":{"ilm":{"available":true,"enabled":true}}}', :headers => {"Content-Type"=> "application/json"})
2219
+ to_return(:status => 200, :body => '{"features":{"ilm":{"available":true,"enabled":true}}}', :headers => {"Content-Type"=> "application/json", 'x-elastic-product' => 'Elasticsearch'})
2212
2220
  stub_request(:get, "https://logs.google.com:777/es//#{ilm_endpoint}/policy/logstash-policy").
2213
2221
  with(basic_auth: ['john', 'doe']).
2214
- to_return(:status => 404, :body => "", :headers => {})
2222
+ to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
2215
2223
  stub_request(:put, "https://logs.google.com:777/es//#{ilm_endpoint}/policy/logstash-policy").
2216
2224
  with(basic_auth: ['john', 'doe'],
2217
2225
  :body => "{\"policy\":{\"phases\":{\"hot\":{\"actions\":{\"rollover\":{\"max_size\":\"50gb\",\"max_age\":\"30d\"}}}}}}").
2218
- to_return(:status => 200, :body => "", :headers => {})
2226
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
2219
2227
  stub_elastic_info("https://logs.google.com:777/es//")
2220
2228
 
2221
2229
  driver(config)
@@ -2263,15 +2271,15 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
2263
2271
  # connection start
2264
2272
  stub_request(:head, "https://logs.google.com:777/es//").
2265
2273
  with(basic_auth: ['john', 'doe']).
2266
- to_return(:status => 200, :body => "", :headers => {})
2274
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
2267
2275
  # check if template exists
2268
2276
  stub_request(:get, "https://logs.google.com:777/es//#{endpoint}/myapp_alias_template").
2269
2277
  with(basic_auth: ['john', 'doe']).
2270
- to_return(:status => 404, :body => "", :headers => {})
2278
+ to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
2271
2279
  # creation
2272
2280
  stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/myapp_alias_template").
2273
2281
  with(basic_auth: ['john', 'doe']).
2274
- to_return(:status => 200, :body => "", :headers => {})
2282
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
2275
2283
  stub_elastic_info("https://logs.google.com:777/es//")
2276
2284
 
2277
2285
  driver(config)
@@ -2309,18 +2317,18 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
2309
2317
  # connection start
2310
2318
  stub_request(:head, "https://logs.google.com:777/es//").
2311
2319
  with(basic_auth: ['john', 'doe']).
2312
- to_return(:status => 200, :body => "", :headers => {})
2320
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
2313
2321
  # check if template exists
2314
2322
  stub_request(:get, "https://logs.google.com:777/es//#{endpoint}/myapp_alias_template-test.template").
2315
2323
  with(basic_auth: ['john', 'doe']).
2316
- to_return(:status => 404, :body => "", :headers => {})
2324
+ to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
2317
2325
  # creation
2318
2326
  stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/myapp_alias_template-test.template").
2319
2327
  with(basic_auth: ['john', 'doe']).
2320
- to_return(:status => 200, :body => "", :headers => {})
2328
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
2321
2329
 
2322
2330
  stub_request(:put, "https://logs.google.com:777/es//%3Cfluentd-test-default-000001%3E").
2323
- to_return(status: 200, body: "", headers: {})
2331
+ to_return(status: 200, body: "", headers: {'x-elastic-product' => 'Elasticsearch'})
2324
2332
 
2325
2333
  driver(config)
2326
2334
 
@@ -2365,14 +2373,14 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
2365
2373
  # connection start
2366
2374
  stub_request(:head, "https://logs-test.google.com:777/es//").
2367
2375
  with(basic_auth: ['john', 'doe']).
2368
- to_return(:status => 200, :body => "", :headers => {})
2376
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
2369
2377
  # check if template exists
2370
2378
  stub_request(:get, "https://logs-test.google.com:777/es//#{endpoint}/logstash").
2371
2379
  with(basic_auth: ['john', 'doe']).
2372
- to_return(:status => 404, :body => "", :headers => {})
2380
+ to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
2373
2381
  stub_request(:put, "https://logs-test.google.com:777/es//#{endpoint}/logstash").
2374
2382
  with(basic_auth: ['john', 'doe']).
2375
- to_return(status: 200, body: "", headers: {})
2383
+ to_return(status: 200, body: "", headers: {'x-elastic-product' => 'Elasticsearch'})
2376
2384
 
2377
2385
  driver(config)
2378
2386
 
@@ -2417,27 +2425,27 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
2417
2425
  # connection start
2418
2426
  stub_request(:head, "https://logs.google.com:777/es//").
2419
2427
  with(basic_auth: ['john', 'doe']).
2420
- to_return(:status => 200, :body => "", :headers => {})
2428
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
2421
2429
  # check if template exists
2422
2430
  stub_request(:get, "https://logs.google.com:777/es//#{endpoint}/myapp_alias_template").
2423
2431
  with(basic_auth: ['john', 'doe']).
2424
- to_return(:status => 404, :body => "", :headers => {})
2432
+ to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
2425
2433
  # creation
2426
2434
  stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/myapp_alias_template").
2427
2435
  with(basic_auth: ['john', 'doe']).
2428
- to_return(:status => 200, :body => "", :headers => {})
2436
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
2429
2437
  # creation of index which can rollover
2430
2438
  stub_request(:put, "https://logs.google.com:777/es//%3Cmylogs-myapp-%7Bnow%2Fw%7Bxxxx.ww%7D%7D-000001%3E").
2431
2439
  with(basic_auth: ['john', 'doe']).
2432
- to_return(:status => 200, :body => "", :headers => {})
2440
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
2433
2441
  # check if alias exists
2434
2442
  stub_request(:head, "https://logs.google.com:777/es//_alias/mylogs").
2435
2443
  with(basic_auth: ['john', 'doe']).
2436
- to_return(:status => 404, :body => "", :headers => {})
2444
+ to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
2437
2445
  # put the alias for the index
2438
2446
  stub_request(:put, "https://logs.google.com:777/es//%3Cmylogs-myapp-%7Bnow%2Fw%7Bxxxx.ww%7D%7D-000001%3E/#{alias_endpoint}/mylogs").
2439
2447
  with(basic_auth: ['john', 'doe']).
2440
- to_return(:status => 200, :body => "", :headers => {})
2448
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
2441
2449
  stub_elastic_info("https://logs.google.com:777/es//")
2442
2450
 
2443
2451
  driver(config)
@@ -2480,27 +2488,27 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
2480
2488
  # connection start
2481
2489
  stub_request(:head, "https://logs.google.com:777/es//").
2482
2490
  with(basic_auth: ['john', 'doe']).
2483
- to_return(:status => 200, :body => "", :headers => {})
2491
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
2484
2492
  # check if template exists
2485
2493
  stub_request(:get, "https://logs.google.com:777/es//#{endpoint}/myapp_alias_template").
2486
2494
  with(basic_auth: ['john', 'doe']).
2487
- to_return(:status => 404, :body => "", :headers => {})
2495
+ to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
2488
2496
  # creation
2489
2497
  stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/myapp_alias_template").
2490
2498
  with(basic_auth: ['john', 'doe']).
2491
- to_return(:status => 200, :body => "", :headers => {})
2499
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
2492
2500
  # creation of index which can rollover
2493
2501
  stub_request(:put, "https://logs.google.com:777/es//%3Cmylogs-myapp-%7Bnow%2Fw%7Bxxxx.ww%7D%7D-000001%3E").
2494
2502
  with(basic_auth: ['john', 'doe']).
2495
- to_return(:status => 200, :body => "", :headers => {})
2503
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
2496
2504
  # check if alias exists
2497
2505
  stub_request(:head, "https://logs.google.com:777/es//_alias/myapp_deflector").
2498
2506
  with(basic_auth: ['john', 'doe']).
2499
- to_return(:status => 404, :body => "", :headers => {})
2507
+ to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
2500
2508
  # put the alias for the index
2501
2509
  stub_request(:put, "https://logs.google.com:777/es//%3Cmylogs-myapp-%7Bnow%2Fw%7Bxxxx.ww%7D%7D-000001%3E/#{alias_endpoint}/myapp_deflector").
2502
2510
  with(basic_auth: ['john', 'doe']).
2503
- to_return(:status => 200, :body => "", :headers => {})
2511
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
2504
2512
  stub_elastic_info("https://logs.google.com:777/es//")
2505
2513
 
2506
2514
  driver(config)
@@ -2544,28 +2552,28 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
2544
2552
  # connection start
2545
2553
  stub_request(:head, "https://logs.google.com:777/es//").
2546
2554
  with(basic_auth: ['john', 'doe']).
2547
- to_return(:status => 200, :body => "", :headers => {})
2555
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
2548
2556
  # check if template exists
2549
2557
  stub_request(:get, "https://logs.google.com:777/es//#{endpoint}/myapp_alias_template").
2550
2558
  with(basic_auth: ['john', 'doe']).
2551
- to_return(:status => 404, :body => "", :headers => {})
2559
+ to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
2552
2560
  # creation
2553
2561
  stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/myapp_alias_template").
2554
2562
  with(basic_auth: ['john', 'doe']).
2555
- to_return(:status => 200, :body => "", :headers => {})
2563
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
2556
2564
  # creation of index which can rollover
2557
2565
  stub_request(:put, "https://logs.google.com:777/es//%3Cmylogs-myapp-#{timestr}-000001%3E").
2558
2566
  with(basic_auth: ['john', 'doe']).
2559
- to_return(:status => 200, :body => "", :headers => {})
2567
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
2560
2568
  # check if alias exists
2561
2569
  stub_request(:head, "https://logs.google.com:777/es//_alias/mylogs-#{timestr}").
2562
2570
  with(basic_auth: ['john', 'doe']).
2563
- to_return(:status => 404, :body => "", :headers => {})
2571
+ to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
2564
2572
  # put the alias for the index
2565
2573
  stub_request(:put, "https://logs.google.com:777/es//%3Cmylogs-myapp-#{timestr}-000001%3E/#{alias_endpoint}/mylogs-#{timestr}").
2566
2574
  with(basic_auth: ['john', 'doe'],
2567
2575
  body: "{\"aliases\":{\"mylogs-#{timestr}\":{\"is_write_index\":true}}}").
2568
- to_return(:status => 200, :body => "", :headers => {})
2576
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
2569
2577
 
2570
2578
  driver(config)
2571
2579
 
@@ -2635,52 +2643,52 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
2635
2643
  # connection start
2636
2644
  stub_request(:head, "https://logs.google.com:777/es//").
2637
2645
  with(basic_auth: ['john', 'doe']).
2638
- to_return(:status => 200, :body => "", :headers => {})
2646
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
2639
2647
  # check if template exists
2640
2648
  stub_request(:get, "https://logs.google.com:777/es//#{endpoint}/myapp_alias_template").
2641
2649
  with(basic_auth: ['john', 'doe']).
2642
- to_return(:status => 404, :body => "", :headers => {})
2650
+ to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
2643
2651
  # creation
2644
2652
  stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/myapp_alias_template").
2645
2653
  with(basic_auth: ['john', 'doe']).
2646
- to_return(:status => 200, :body => "", :headers => {})
2654
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
2647
2655
  # creation of index which can rollover
2648
2656
  stub_request(:put, "https://logs.google.com:777/es//%3Cmylogs-myapp-%7Bnow%2Fw%7Bxxxx.ww%7D%7D-000001%3E").
2649
2657
  with(basic_auth: ['john', 'doe']).
2650
- to_return(:status => 200, :body => "", :headers => {})
2658
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
2651
2659
  # check if alias exists
2652
2660
  stub_request(:head, "https://logs.google.com:777/es//_alias/mylogs").
2653
2661
  with(basic_auth: ['john', 'doe']).
2654
- to_return(:status => 404, :body => "", :headers => {})
2662
+ to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
2655
2663
  stub_request(:get, "https://logs.google.com:777/es//#{endpoint}/mylogs").
2656
2664
  with(basic_auth: ['john', 'doe']).
2657
- to_return(status: 404, body: "", headers: {})
2665
+ to_return(status: 404, body: "", headers: {'x-elastic-product' => 'Elasticsearch'})
2658
2666
  if use_legacy_template_flag
2659
2667
  stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/mylogs").
2660
2668
  with(basic_auth: ['john', 'doe'],
2661
2669
  body: "{\"order\":6,\"settings\":{\"index.lifecycle.name\":\"fluentd-policy\",\"index.lifecycle.rollover_alias\":\"mylogs\"},\"mappings\":{},\"aliases\":{\"myapp-logs-alias\":{}},\"index_patterns\":\"mylogs-*\"}").
2662
- to_return(status: 200, body: "", headers: {})
2670
+ to_return(status: 200, body: "", headers: {'x-elastic-product' => 'Elasticsearch'})
2663
2671
  else
2664
2672
  stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/mylogs").
2665
2673
  with(basic_auth: ['john', 'doe'],
2666
2674
  body: "{\"priority\":106,\"index_patterns\":\"mylogs-*\",\"template\":{\"settings\":{\"index.lifecycle.name\":\"fluentd-policy\",\"index.lifecycle.rollover_alias\":\"mylogs\"},\"mappings\":{},\"aliases\":{\"myapp-logs-alias\":{}}}}").
2667
- to_return(status: 200, body: "", headers: {})
2675
+ to_return(status: 200, body: "", headers: {'x-elastic-product' => 'Elasticsearch'})
2668
2676
  end
2669
2677
  # put the alias for the index
2670
2678
  stub_request(:put, "https://logs.google.com:777/es//%3Cmylogs-myapp-%7Bnow%2Fw%7Bxxxx.ww%7D%7D-000001%3E/#{alias_endpoint}/mylogs").
2671
2679
  with(basic_auth: ['john', 'doe'],
2672
2680
  :body => "{\"aliases\":{\"mylogs\":{\"is_write_index\":true}}}").
2673
- to_return(:status => 200, :body => "", :headers => {})
2681
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
2674
2682
  stub_request(:get, "https://logs.google.com:777/es//_xpack").
2675
2683
  with(basic_auth: ['john', 'doe']).
2676
- to_return(:status => 200, :body => '{"features":{"ilm":{"available":true,"enabled":true}}}', :headers => {"Content-Type"=> "application/json"})
2684
+ to_return(:status => 200, :body => '{"features":{"ilm":{"available":true,"enabled":true}}}', :headers => {"Content-Type"=> "application/json", 'x-elastic-product' => 'Elasticsearch'})
2677
2685
  stub_request(:get, "https://logs.google.com:777/es//#{ilm_endpoint}/policy/fluentd-policy").
2678
2686
  with(basic_auth: ['john', 'doe']).
2679
- to_return(:status => 404, :body => "", :headers => {})
2687
+ to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
2680
2688
  stub_request(:put, "https://logs.google.com:777/es//#{ilm_endpoint}/policy/fluentd-policy").
2681
2689
  with(basic_auth: ['john', 'doe'],
2682
2690
  :body => "{\"policy\":{\"phases\":{\"hot\":{\"actions\":{\"rollover\":{\"max_size\":\"50gb\",\"max_age\":\"30d\"}}}}}}").
2683
- to_return(:status => 200, :body => "", :headers => {})
2691
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
2684
2692
  stub_elastic_info("https://logs.google.com:777/es//")
2685
2693
  driver(config)
2686
2694
 
@@ -2724,52 +2732,52 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
2724
2732
  # connection start
2725
2733
  stub_request(:head, "https://logs.google.com:777/es//").
2726
2734
  with(basic_auth: ['john', 'doe']).
2727
- to_return(:status => 200, :body => "", :headers => {})
2735
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
2728
2736
  # check if template exists
2729
2737
  stub_request(:get, "https://logs.google.com:777/es//#{endpoint}/myapp_alias_template").
2730
2738
  with(basic_auth: ['john', 'doe']).
2731
- to_return(:status => 404, :body => "", :headers => {})
2739
+ to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
2732
2740
  # creation
2733
2741
  stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/myapp_alias_template").
2734
2742
  with(basic_auth: ['john', 'doe']).
2735
- to_return(:status => 200, :body => "", :headers => {})
2743
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
2736
2744
  # creation of index which can rollover
2737
2745
  stub_request(:put, "https://logs.google.com:777/es//%3Cmylogs-myapp-%7Bnow%2Fw%7Bxxxx.ww%7D%7D-000001%3E").
2738
2746
  with(basic_auth: ['john', 'doe']).
2739
- to_return(:status => 200, :body => "", :headers => {})
2747
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
2740
2748
  # check if alias exists
2741
2749
  stub_request(:head, "https://logs.google.com:777/es//_alias/mylogs").
2742
2750
  with(basic_auth: ['john', 'doe']).
2743
- to_return(:status => 404, :body => "", :headers => {})
2751
+ to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
2744
2752
  stub_request(:get, "https://logs.google.com:777/es//#{endpoint}/mylogs").
2745
2753
  with(basic_auth: ['john', 'doe']).
2746
- to_return(status: 404, body: "", headers: {})
2754
+ to_return(status: 404, body: "", headers: {'x-elastic-product' => 'Elasticsearch'})
2747
2755
  if use_legacy_template_flag
2748
2756
  stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/mylogs").
2749
2757
  with(basic_auth: ['john', 'doe'],
2750
2758
  body: "{\"order\":6,\"settings\":{\"index.lifecycle.name\":\"fluentd-policy\",\"index.lifecycle.rollover_alias\":\"mylogs\"},\"mappings\":{},\"aliases\":{\"myapp-logs-alias\":{}},\"index_patterns\":\"mylogs-*\"}").
2751
- to_return(status: 200, body: "", headers: {})
2759
+ to_return(status: 200, body: "", headers: {'x-elastic-product' => 'Elasticsearch'})
2752
2760
  else
2753
2761
  stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/mylogs").
2754
2762
  with(basic_auth: ['john', 'doe'],
2755
2763
  body: "{\"priority\":106,\"index_patterns\":\"mylogs-*\",\"template\":{\"settings\":{\"index.lifecycle.name\":\"fluentd-policy\",\"index.lifecycle.rollover_alias\":\"mylogs\"},\"mappings\":{},\"aliases\":{\"myapp-logs-alias\":{}}}}").
2756
- to_return(status: 200, body: "", headers: {})
2764
+ to_return(status: 200, body: "", headers: {'x-elastic-product' => 'Elasticsearch'})
2757
2765
  end
2758
2766
  # put the alias for the index
2759
2767
  stub_request(:put, "https://logs.google.com:777/es//%3Cmylogs-myapp-%7Bnow%2Fw%7Bxxxx.ww%7D%7D-000001%3E/#{alias_endpoint}/mylogs").
2760
2768
  with(basic_auth: ['john', 'doe'],
2761
2769
  :body => "{\"aliases\":{\"mylogs\":{\"is_write_index\":true}}}").
2762
- to_return(:status => 200, :body => "", :headers => {})
2770
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
2763
2771
  stub_request(:get, "https://logs.google.com:777/es//_xpack").
2764
2772
  with(basic_auth: ['john', 'doe']).
2765
- to_return(:status => 200, :body => '{"features":{"ilm":{"available":true,"enabled":true}}}', :headers => {"Content-Type"=> "application/json"})
2773
+ to_return(:status => 200, :body => '{"features":{"ilm":{"available":true,"enabled":true}}}', :headers => {"Content-Type"=> "application/json", 'x-elastic-product' => 'Elasticsearch'})
2766
2774
  stub_request(:get, "https://logs.google.com:777/es//#{ilm_endpoint}/policy/fluentd-policy").
2767
2775
  with(basic_auth: ['john', 'doe']).
2768
- to_return(:status => 200, :body => "", :headers => {})
2776
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
2769
2777
  stub_request(:put, "https://logs.google.com:777/es//#{ilm_endpoint}/policy/fluentd-policy").
2770
2778
  with(basic_auth: ['john', 'doe'],
2771
2779
  :body => "{\"policy\":{\"phases\":{\"hot\":{\"actions\":{\"rollover\":{\"max_size\":\"60gb\",\"max_age\":\"45d\"}}}}}}").
2772
- to_return(:status => 200, :body => "", :headers => {})
2780
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
2773
2781
  stub_elastic_info("https://logs.google.com:777/es//")
2774
2782
 
2775
2783
  driver(config)
@@ -2841,101 +2849,101 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
2841
2849
  # connection start
2842
2850
  stub_request(:head, "https://logs.google.com:777/es//").
2843
2851
  with(basic_auth: ['john', 'doe']).
2844
- to_return(:status => 200, :body => "", :headers => {})
2852
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
2845
2853
 
2846
2854
  # test-tag1
2847
2855
  # check if template exists
2848
2856
  stub_request(:get, "https://logs.google.com:777/es//#{endpoint}/myapp_alias_template").
2849
2857
  with(basic_auth: ['john', 'doe']).
2850
- to_return(:status => 404, :body => "", :headers => {})
2858
+ to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
2851
2859
  # creation
2852
2860
  stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/myapp_alias_template").
2853
2861
  with(basic_auth: ['john', 'doe']).
2854
- to_return(:status => 200, :body => "", :headers => {})
2862
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
2855
2863
  # creation of index which can rollover
2856
2864
  stub_request(:put, "https://logs.google.com:777/es//%3Cmylogs-test-tag1-myapp-%7Bnow%2Fw%7Bxxxx.ww%7D%7D-000001%3E").
2857
2865
  with(basic_auth: ['john', 'doe']).
2858
- to_return(:status => 200, :body => "", :headers => {})
2866
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
2859
2867
  # check if alias exists
2860
2868
  stub_request(:head, "https://logs.google.com:777/es//_alias/mylogs-test-tag1").
2861
2869
  with(basic_auth: ['john', 'doe']).
2862
- to_return(:status => 404, :body => "", :headers => {})
2870
+ to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
2863
2871
  stub_request(:get, "https://logs.google.com:777/es//#{endpoint}/mylogs-test-tag1").
2864
2872
  with(basic_auth: ['john', 'doe']).
2865
- to_return(status: 404, body: "", headers: {})
2873
+ to_return(status: 404, body: "", headers: {'x-elastic-product' => 'Elasticsearch'})
2866
2874
  if use_legacy_template_flag
2867
2875
  stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/mylogs-test-tag1").
2868
2876
  with(basic_auth: ['john', 'doe'],
2869
2877
  body: "{\"order\":8,\"settings\":{\"index.lifecycle.name\":\"fluentd-policy\",\"index.lifecycle.rollover_alias\":\"mylogs-test-tag1\"},\"mappings\":{},\"aliases\":{\"myapp-logs-alias\":{}},\"index_patterns\":\"mylogs-test-tag1-*\"}").
2870
- to_return(status: 200, body: "", headers: {})
2878
+ to_return(status: 200, body: "", headers: {'x-elastic-product' => 'Elasticsearch'})
2871
2879
  else
2872
2880
  stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/mylogs-test-tag1").
2873
2881
  with(basic_auth: ['john', 'doe'],
2874
2882
  body: "{\"priority\":108,\"index_patterns\":\"mylogs-test-tag1-*\",\"template\":{\"settings\":{\"index.lifecycle.name\":\"fluentd-policy\",\"index.lifecycle.rollover_alias\":\"mylogs-test-tag1\"},\"mappings\":{},\"aliases\":{\"myapp-logs-alias\":{}}}}").
2875
- to_return(status: 200, body: "", headers: {})
2883
+ to_return(status: 200, body: "", headers: {'x-elastic-product' => 'Elasticsearch'})
2876
2884
  end
2877
2885
  # put the alias for the index
2878
2886
  stub_request(:put, "https://logs.google.com:777/es//%3Cmylogs-test-tag1-myapp-%7Bnow%2Fw%7Bxxxx.ww%7D%7D-000001%3E/#{alias_endpoint}/mylogs-test-tag1").
2879
2887
  with(basic_auth: ['john', 'doe'],
2880
2888
  :body => "{\"aliases\":{\"mylogs-test-tag1\":{\"is_write_index\":true}}}").
2881
- to_return(:status => 200, :body => "", :headers => {})
2889
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
2882
2890
  stub_request(:get, "https://logs.google.com:777/es//_xpack").
2883
2891
  with(basic_auth: ['john', 'doe']).
2884
- to_return(:status => 200, :body => '{"features":{"ilm":{"available":true,"enabled":true}}}', :headers => {"Content-Type"=> "application/json"})
2892
+ to_return(:status => 200, :body => '{"features":{"ilm":{"available":true,"enabled":true}}}', :headers => {"Content-Type"=> "application/json", 'x-elastic-product' => 'Elasticsearch'})
2885
2893
  stub_request(:get, "https://logs.google.com:777/es//#{ilm_endpoint}/policy/fluentd-policy").
2886
2894
  with(basic_auth: ['john', 'doe']).
2887
- to_return(:status => 404, :body => "", :headers => {})
2895
+ to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
2888
2896
  stub_request(:put, "https://logs.google.com:777/es//#{ilm_endpoint}/policy/fluentd-policy").
2889
2897
  with(basic_auth: ['john', 'doe'],
2890
2898
  :body => "{\"policy\":{\"phases\":{\"hot\":{\"actions\":{\"rollover\":{\"max_size\":\"50gb\",\"max_age\":\"30d\"}}}}}}").
2891
- to_return(:status => 200, :body => "", :headers => {})
2899
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
2892
2900
 
2893
2901
  # test-tag2
2894
2902
  # check if template exists
2895
2903
  stub_request(:get, "https://logs.google.com:777/es//_template/myapp_alias_template").
2896
2904
  with(basic_auth: ['john', 'doe']).
2897
- to_return(:status => 404, :body => "", :headers => {})
2905
+ to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
2898
2906
  # creation
2899
2907
  stub_request(:put, "https://logs.google.com:777/es//_template/myapp_alias_template").
2900
2908
  with(basic_auth: ['john', 'doe']).
2901
- to_return(:status => 200, :body => "", :headers => {})
2909
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
2902
2910
  # creation of index which can rollover
2903
2911
  stub_request(:put, "https://logs.google.com:777/es//%3Cmylogs-test-tag2-myapp-%7Bnow%2Fw%7Bxxxx.ww%7D%7D-000001%3E").
2904
2912
  with(basic_auth: ['john', 'doe']).
2905
- to_return(:status => 200, :body => "", :headers => {})
2913
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
2906
2914
  # check if alias exists
2907
2915
  stub_request(:head, "https://logs.google.com:777/es//_alias/mylogs-test-tag2").
2908
2916
  with(basic_auth: ['john', 'doe']).
2909
- to_return(:status => 404, :body => "", :headers => {})
2917
+ to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
2910
2918
  stub_request(:get, "https://logs.google.com:777/es//#{endpoint}/mylogs-test-tag2").
2911
2919
  with(basic_auth: ['john', 'doe']).
2912
- to_return(status: 404, body: "", headers: {})
2920
+ to_return(status: 404, body: "", headers: {'x-elastic-product' => 'Elasticsearch'})
2913
2921
  if use_legacy_template_flag
2914
2922
  stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/mylogs-test-tag2").
2915
2923
  with(basic_auth: ['john', 'doe'],
2916
2924
  body: "{\"order\":8,\"settings\":{\"index.lifecycle.name\":\"fluentd-policy\",\"index.lifecycle.rollover_alias\":\"mylogs-test-tag2\"},\"mappings\":{},\"aliases\":{\"myapp-logs-alias\":{}},\"index_patterns\":\"mylogs-test-tag2-*\"}").
2917
- to_return(status: 200, body: "", headers: {})
2925
+ to_return(status: 200, body: "", headers: {'x-elastic-product' => 'Elasticsearch'})
2918
2926
  else
2919
2927
  stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/mylogs-test-tag2").
2920
2928
  with(basic_auth: ['john', 'doe'],
2921
2929
  body: "{\"priority\":108,\"index_patterns\":\"mylogs-test-tag2-*\",\"template\":{\"settings\":{\"index.lifecycle.name\":\"fluentd-policy\",\"index.lifecycle.rollover_alias\":\"mylogs-test-tag2\"},\"mappings\":{},\"aliases\":{\"myapp-logs-alias\":{}}}}").
2922
- to_return(status: 200, body: "", headers: {})
2930
+ to_return(status: 200, body: "", headers: {'x-elastic-product' => 'Elasticsearch'})
2923
2931
  end
2924
2932
  # put the alias for the index
2925
2933
  stub_request(:put, "https://logs.google.com:777/es//%3Cmylogs-test-tag2-myapp-%7Bnow%2Fw%7Bxxxx.ww%7D%7D-000001%3E/#{alias_endpoint}/mylogs-test-tag2").
2926
2934
  with(basic_auth: ['john', 'doe'],
2927
2935
  :body => "{\"aliases\":{\"mylogs-test-tag2\":{\"is_write_index\":true}}}").
2928
- to_return(:status => 200, :body => "", :headers => {})
2936
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
2929
2937
  stub_request(:get, "https://logs.google.com:777/es//_xpack").
2930
2938
  with(basic_auth: ['john', 'doe']).
2931
- to_return(:status => 200, :body => '{"features":{"ilm":{"available":true,"enabled":true}}}', :headers => {"Content-Type"=> "application/json"})
2939
+ to_return(:status => 200, :body => '{"features":{"ilm":{"available":true,"enabled":true}}}', :headers => {"Content-Type"=> "application/json", 'x-elastic-product' => 'Elasticsearch'})
2932
2940
  stub_request(:get, "https://logs.google.com:777/es//#{ilm_endpoint}/policy/fluentd-policy").
2933
2941
  with(basic_auth: ['john', 'doe']).
2934
- to_return(:status => 404, :body => "", :headers => {})
2942
+ to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
2935
2943
  stub_request(:put, "https://logs.google.com:777/es//#{ilm_endpoint}/policy/fluentd-policy").
2936
2944
  with(basic_auth: ['john', 'doe'],
2937
2945
  :body => "{\"policy\":{\"phases\":{\"hot\":{\"actions\":{\"rollover\":{\"max_size\":\"50gb\",\"max_age\":\"30d\"}}}}}}").
2938
- to_return(:status => 200, :body => "", :headers => {})
2946
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
2939
2947
  stub_elastic_info("https://logs.google.com:777/es//")
2940
2948
 
2941
2949
  driver(config)
@@ -2989,44 +2997,44 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
2989
2997
  # connection start
2990
2998
  stub_request(:head, "https://logs.google.com:777/es//").
2991
2999
  with(basic_auth: ['john', 'doe']).
2992
- to_return(:status => 200, :body => "", :headers => {})
3000
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
2993
3001
  # check if template exists
2994
3002
  stub_request(:get, "https://logs.google.com:777/es//#{endpoint}/myapp_alias_template").
2995
3003
  with(basic_auth: ['john', 'doe']).
2996
- to_return(:status => 404, :body => "", :headers => {})
3004
+ to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
2997
3005
  # creation
2998
3006
  stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/myapp_alias_template").
2999
3007
  with(basic_auth: ['john', 'doe']).
3000
- to_return(:status => 200, :body => "", :headers => {})
3008
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
3001
3009
  # creation of index which can rollover
3002
3010
  stub_request(:put, "https://logs.google.com:777/es//%3Cmylogs-myapp-%7Bnow%2Fw%7Bxxxx.ww%7D%7D-000001%3E").
3003
3011
  with(basic_auth: ['john', 'doe']).
3004
- to_return(:status => 200, :body => "", :headers => {})
3012
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
3005
3013
  # check if alias exists
3006
3014
  stub_request(:head, "https://logs.google.com:777/es//_alias/mylogs").
3007
3015
  with(basic_auth: ['john', 'doe']).
3008
- to_return(:status => 404, :body => "", :headers => {})
3016
+ to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
3009
3017
  stub_request(:get, "https://logs.google.com:777/es//#{endpoint}/mylogs").
3010
3018
  with(basic_auth: ['john', 'doe']).
3011
- to_return(status: 404, body: "", headers: {})
3019
+ to_return(status: 404, body: "", headers: {'x-elastic-product' => 'Elasticsearch'})
3012
3020
  stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/mylogs").
3013
3021
  with(basic_auth: ['john', 'doe']).
3014
- to_return(status: 200, body: "", headers: {})
3022
+ to_return(status: 200, body: "", headers: {'x-elastic-product' => 'Elasticsearch'})
3015
3023
  # put the alias for the index
3016
3024
  stub_request(:put, "https://logs.google.com:777/es//%3Cmylogs-myapp-%7Bnow%2Fw%7Bxxxx.ww%7D%7D-000001%3E/#{alias_endpoint}/mylogs").
3017
3025
  with(basic_auth: ['john', 'doe'],
3018
3026
  :body => "{\"aliases\":{\"mylogs\":{\"is_write_index\":true}}}").
3019
- to_return(:status => 200, :body => "", :headers => {})
3027
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
3020
3028
  stub_request(:get, "https://logs.google.com:777/es//_xpack").
3021
3029
  with(basic_auth: ['john', 'doe']).
3022
- to_return(:status => 200, :body => '{"features":{"ilm":{"available":true,"enabled":true}}}', :headers => {"Content-Type"=> "application/json"})
3030
+ to_return(:status => 200, :body => '{"features":{"ilm":{"available":true,"enabled":true}}}', :headers => {"Content-Type"=> "application/json", 'x-elastic-product' => 'Elasticsearch'})
3023
3031
  stub_request(:get, "https://logs.google.com:777/es//#{ilm_endpoint}/policy/fluentd-policy").
3024
3032
  with(basic_auth: ['john', 'doe']).
3025
- to_return(:status => 404, :body => "", :headers => {})
3033
+ to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
3026
3034
  stub_request(:put, "https://logs.google.com:777/es//#{ilm_endpoint}/policy/fluentd-policy").
3027
3035
  with(basic_auth: ['john', 'doe'],
3028
3036
  :body => "{\"policy\":{\"phases\":{\"hot\":{\"actions\":{\"rollover\":{\"max_size\":\"70gb\",\"max_age\":\"30d\"}}}}}}").
3029
- to_return(:status => 200, :body => "", :headers => {})
3037
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
3030
3038
  stub_elastic_info("https://logs.google.com:777/es//")
3031
3039
  driver(config)
3032
3040
 
@@ -3064,15 +3072,15 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
3064
3072
  # connection start
3065
3073
  stub_request(:head, "https://logs.google.com:777/es//").
3066
3074
  with(basic_auth: ['john', 'doe']).
3067
- to_return(:status => 200, :body => "", :headers => {})
3075
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
3068
3076
  # check if template exists
3069
3077
  stub_request(:get, "https://logs.google.com:777/es//#{endpoint}/logstash").
3070
3078
  with(basic_auth: ['john', 'doe']).
3071
- to_return(:status => 200, :body => "", :headers => {})
3079
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
3072
3080
  # creation
3073
3081
  stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/logstash").
3074
3082
  with(basic_auth: ['john', 'doe']).
3075
- to_return(:status => 200, :body => "", :headers => {})
3083
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
3076
3084
  stub_elastic_info("https://logs.google.com:777/es//")
3077
3085
 
3078
3086
  driver(config)
@@ -3111,15 +3119,15 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
3111
3119
  # connection start
3112
3120
  stub_request(:head, "https://logs.google.com:777/es//").
3113
3121
  with(basic_auth: ['john', 'doe']).
3114
- to_return(:status => 200, :body => "", :headers => {})
3122
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
3115
3123
  # check if template exists
3116
3124
  stub_request(:get, "https://logs.google.com:777/es//#{endpoint}/myapp_alias_template").
3117
3125
  with(basic_auth: ['john', 'doe']).
3118
- to_return(:status => 200, :body => "", :headers => {})
3126
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
3119
3127
  # creation
3120
3128
  stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/myapp_alias_template").
3121
3129
  with(basic_auth: ['john', 'doe']).
3122
- to_return(:status => 200, :body => "", :headers => {})
3130
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
3123
3131
  stub_elastic_info("https://logs.google.com:777/es//")
3124
3132
 
3125
3133
  driver(config)
@@ -3162,27 +3170,27 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
3162
3170
  # connection start
3163
3171
  stub_request(:head, "https://logs.google.com:777/es//").
3164
3172
  with(basic_auth: ['john', 'doe']).
3165
- to_return(:status => 200, :body => "", :headers => {})
3173
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
3166
3174
  # check if template exists
3167
3175
  stub_request(:get, "https://logs.google.com:777/es//#{endpoint}/myapp_alias_template").
3168
3176
  with(basic_auth: ['john', 'doe']).
3169
- to_return(:status => 200, :body => "", :headers => {})
3177
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
3170
3178
  # creation
3171
3179
  stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/myapp_alias_template").
3172
3180
  with(basic_auth: ['john', 'doe']).
3173
- to_return(:status => 200, :body => "", :headers => {})
3181
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
3174
3182
  # creation of index which can rollover
3175
3183
  stub_request(:put, "https://logs.google.com:777/es//%3Cmylogs-myapp-%7Bnow%2Fd%7D-000001%3E").
3176
3184
  with(basic_auth: ['john', 'doe']).
3177
- to_return(:status => 200, :body => "", :headers => {})
3185
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
3178
3186
  # check if alias exists
3179
3187
  stub_request(:head, "https://logs.google.com:777/es//_alias/myapp_deflector").
3180
3188
  with(basic_auth: ['john', 'doe']).
3181
- to_return(:status => 404, :body => "", :headers => {})
3189
+ to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
3182
3190
  # put the alias for the index
3183
3191
  stub_request(:put, "https://logs.google.com:777/es//%3Cmylogs-myapp-%7Bnow%2Fd%7D-000001%3E/#{alias_endpoint}/myapp_deflector").
3184
3192
  with(basic_auth: ['john', 'doe']).
3185
- to_return(:status => 200, :body => "", :headers => {})
3193
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
3186
3194
  stub_elastic_info("https://logs.google.com:777/es//")
3187
3195
 
3188
3196
  driver(config)
@@ -3205,11 +3213,11 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
3205
3213
  # connection start
3206
3214
  stub_request(:head, "https://logs.google.com:777/es//").
3207
3215
  with(basic_auth: ['john', 'doe']).
3208
- to_return(:status => 200, :body => "", :headers => {})
3216
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
3209
3217
  # check if template exists
3210
3218
  stub_request(:get, "https://logs.google.com:777/es//_template/logstash").
3211
3219
  with(basic_auth: ['john', 'doe']).
3212
- to_return(:status => 404, :body => "", :headers => {})
3220
+ to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
3213
3221
  stub_elastic_info("https://logs.google.com:777/es//")
3214
3222
 
3215
3223
  assert_raise(RuntimeError) {
@@ -3248,17 +3256,17 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
3248
3256
  # connection start
3249
3257
  stub_request(:head, "https://logs-test.google.com:777/es//").
3250
3258
  with(basic_auth: ['john', 'doe']).
3251
- to_return(:status => 200, :body => "", :headers => {})
3259
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
3252
3260
  # check if template exists
3253
3261
  stub_request(:get, "https://logs-test.google.com:777/es//#{endpoint}/logstash").
3254
3262
  with(basic_auth: ['john', 'doe']).
3255
- to_return(:status => 404, :body => "", :headers => {})
3263
+ to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
3256
3264
  stub_request(:put, "https://logs-test.google.com:777/es//#{endpoint}/logstash").
3257
3265
  with(basic_auth: ['john', 'doe']).
3258
- to_return(status: 200, body: "", headers: {})
3266
+ to_return(status: 200, body: "", headers: {'x-elastic-product' => 'Elasticsearch'})
3259
3267
  stub_request(:post, "https://logs-test.google.com:777/es//_bulk").
3260
3268
  with(basic_auth: ['john', 'doe']).
3261
- to_return(status: 200, body: "", headers: {})
3269
+ to_return(status: 200, body: "", headers: {'x-elastic-product' => 'Elasticsearch'})
3262
3270
 
3263
3271
  driver(config)
3264
3272
 
@@ -3339,28 +3347,28 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
3339
3347
 
3340
3348
  stub_request(:head, "https://logs.google.com:777/es//").
3341
3349
  with(basic_auth: ['john', 'doe']).
3342
- to_return(:status => 200, :body => "", :headers => {})
3350
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
3343
3351
  # check if template exists
3344
3352
  stub_request(:get, "https://logs.google.com:777/es//#{endpoint}/logstash1").
3345
3353
  with(basic_auth: ['john', 'doe']).
3346
- to_return(:status => 404, :body => "", :headers => {})
3354
+ to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
3347
3355
  stub_request(:get, "https://logs.google.com:777/es//#{endpoint}/logstash2").
3348
3356
  with(basic_auth: ['john', 'doe']).
3349
- to_return(:status => 404, :body => "", :headers => {})
3357
+ to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
3350
3358
 
3351
3359
  stub_request(:get, "https://logs.google.com:777/es//#{endpoint}/logstash3").
3352
3360
  with(basic_auth: ['john', 'doe']).
3353
- to_return(:status => 200, :body => "", :headers => {}) #exists
3361
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) #exists
3354
3362
 
3355
3363
  stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/logstash1").
3356
3364
  with(basic_auth: ['john', 'doe']).
3357
- to_return(:status => 200, :body => "", :headers => {})
3365
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
3358
3366
  stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/logstash2").
3359
3367
  with(basic_auth: ['john', 'doe']).
3360
- to_return(:status => 200, :body => "", :headers => {})
3368
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
3361
3369
  stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/logstash3").
3362
3370
  with(basic_auth: ['john', 'doe']).
3363
- to_return(:status => 200, :body => "", :headers => {})
3371
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
3364
3372
  stub_elastic_info("https://logs.google.com:777/es//")
3365
3373
 
3366
3374
  driver(config)
@@ -3398,27 +3406,27 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
3398
3406
 
3399
3407
  stub_request(:head, "https://logs.google.com:777/es//").
3400
3408
  with(basic_auth: ['john', 'doe']).
3401
- to_return(:status => 200, :body => "", :headers => {})
3409
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
3402
3410
  # check if template exists
3403
3411
  stub_request(:get, "https://logs.google.com:777/es//#{endpoint}/logstash1").
3404
3412
  with(basic_auth: ['john', 'doe']).
3405
- to_return(:status => 200, :body => "", :headers => {})
3413
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
3406
3414
  stub_request(:get, "https://logs.google.com:777/es//#{endpoint}/logstash2").
3407
3415
  with(basic_auth: ['john', 'doe']).
3408
- to_return(:status => 200, :body => "", :headers => {})
3416
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
3409
3417
  stub_request(:get, "https://logs.google.com:777/es//#{endpoint}/logstash3").
3410
3418
  with(basic_auth: ['john', 'doe']).
3411
- to_return(:status => 200, :body => "", :headers => {}) #exists
3419
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'}) #exists
3412
3420
 
3413
3421
  stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/logstash1").
3414
3422
  with(basic_auth: ['john', 'doe']).
3415
- to_return(:status => 200, :body => "", :headers => {})
3423
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
3416
3424
  stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/logstash2").
3417
3425
  with(basic_auth: ['john', 'doe']).
3418
- to_return(:status => 200, :body => "", :headers => {})
3426
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
3419
3427
  stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/logstash3").
3420
3428
  with(basic_auth: ['john', 'doe']).
3421
- to_return(:status => 200, :body => "", :headers => {})
3429
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
3422
3430
  stub_elastic_info("https://logs.google.com:777/es//")
3423
3431
 
3424
3432
  driver(config)
@@ -3457,27 +3465,27 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
3457
3465
  # connection start
3458
3466
  stub_request(:head, "https://logs.google.com:777/es//").
3459
3467
  with(basic_auth: ['john', 'doe']).
3460
- to_return(:status => 200, :body => "", :headers => {})
3468
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
3461
3469
  # check if template exists
3462
3470
  stub_request(:get, "https://logs.google.com:777/es//#{endpoint}/logstash").
3463
3471
  with(basic_auth: ['john', 'doe']).
3464
- to_return(:status => 404, :body => "", :headers => {})
3472
+ to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
3465
3473
  stub_request(:get, "https://logs.google.com:777/es//#{endpoint}/logstash1").
3466
3474
  with(basic_auth: ['john', 'doe']).
3467
- to_return(:status => 404, :body => "", :headers => {})
3475
+ to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
3468
3476
  stub_request(:get, "https://logs.google.com:777/es//#{endpoint}/logstash2").
3469
3477
  with(basic_auth: ['john', 'doe']).
3470
- to_return(:status => 404, :body => "", :headers => {})
3478
+ to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
3471
3479
  #creation
3472
3480
  stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/logstash").
3473
3481
  with(basic_auth: ['john', 'doe']).
3474
- to_return(:status => 200, :body => "", :headers => {})
3482
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
3475
3483
  stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/logstash1").
3476
3484
  with(basic_auth: ['john', 'doe']).
3477
- to_return(:status => 200, :body => "", :headers => {})
3485
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
3478
3486
  stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/logstash2").
3479
3487
  with(basic_auth: ['john', 'doe']).
3480
- to_return(:status => 200, :body => "", :headers => {})
3488
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
3481
3489
  stub_elastic_info("https://logs.google.com:777/es//")
3482
3490
 
3483
3491
  driver(config)
@@ -3514,21 +3522,21 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
3514
3522
  }
3515
3523
  stub_request(:head, "https://logs.google.com:777/es//").
3516
3524
  with(basic_auth: ['john', 'doe']).
3517
- to_return(:status => 200, :body => "", :headers => {})
3525
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
3518
3526
  # check if template exists
3519
3527
  stub_request(:get, "https://logs.google.com:777/es//#{endpoint}/logstash1").
3520
3528
  with(basic_auth: ['john', 'doe']).
3521
- to_return(:status => 404, :body => "", :headers => {})
3529
+ to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
3522
3530
  stub_request(:get, "https://logs.google.com:777/es//#{endpoint}/logstash2").
3523
3531
  with(basic_auth: ['john', 'doe']).
3524
- to_return(:status => 404, :body => "", :headers => {})
3532
+ to_return(:status => 404, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
3525
3533
 
3526
3534
  stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/logstash1").
3527
3535
  with(basic_auth: ['john', 'doe']).
3528
- to_return(:status => 200, :body => "", :headers => {})
3536
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
3529
3537
  stub_request(:put, "https://logs.google.com:777/es//#{endpoint}/logstash2").
3530
3538
  with(basic_auth: ['john', 'doe']).
3531
- to_return(:status => 200, :body => "", :headers => {})
3539
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
3532
3540
  stub_elastic_info("https://logs.google.com:777/es//")
3533
3541
 
3534
3542
  assert_raise(RuntimeError) {
@@ -3592,6 +3600,33 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
3592
3600
  assert_equal '/default_path', host2[:path]
3593
3601
  end
3594
3602
 
3603
+ def test_hosts_list_with_existing_connection
3604
+ stub_elastic_info("https://john:password@host1:443/elastic/")
3605
+ stub_elastic_info("http://host2")
3606
+ config = %{
3607
+ path /default_path
3608
+ user default_user
3609
+ password default_password
3610
+ }
3611
+ instance = driver(config).instance
3612
+
3613
+ assert_equal 2, instance.get_connection_options("https://john:password@host1:443/elastic/,http://host2")[:hosts].length
3614
+ host1, host2 = instance.get_connection_options("https://john:password@host1:443/elastic/,http://host2")[:hosts]
3615
+
3616
+ assert_equal 'host1', host1[:host]
3617
+ assert_equal 443, host1[:port]
3618
+ assert_equal 'https', host1[:scheme]
3619
+ assert_equal 'john', host1[:user]
3620
+ assert_equal 'password', host1[:password]
3621
+ assert_equal '/elastic/', host1[:path]
3622
+
3623
+ assert_equal 'host2', host2[:host]
3624
+ assert_equal 'http', host2[:scheme]
3625
+ assert_equal 'default_user', host2[:user]
3626
+ assert_equal 'default_password', host2[:password]
3627
+ assert_equal '/default_path', host2[:path]
3628
+ end
3629
+
3595
3630
  def test_hosts_list_with_escape_placeholders
3596
3631
  config = %{
3597
3632
  hosts https://%{j+hn}:%{passw@rd}@host1:443/elastic/,http://host2
@@ -3662,6 +3697,31 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
3662
3697
  assert_equal '/default_path', host2[:path]
3663
3698
  end
3664
3699
 
3700
+ def test_hosts_list_with_existing_connection
3701
+ config = %{
3702
+ path /default_path
3703
+ user default_user
3704
+ password default_password
3705
+ }
3706
+ instance = driver(config).instance
3707
+
3708
+ assert_equal 2, instance.get_connection_options("https://john:password@[2404:7a80:d440:3000:192a:a292:bd7f:ca19]:443/elastic/,http://host2")[:hosts].length
3709
+ host1, host2 = instance.get_connection_options("https://john:password@[2404:7a80:d440:3000:192a:a292:bd7f:ca19]:443/elastic/,http://host2")[:hosts]
3710
+
3711
+ assert_equal '[2404:7a80:d440:3000:192a:a292:bd7f:ca19]', host1[:host]
3712
+ assert_equal 443, host1[:port]
3713
+ assert_equal 'https', host1[:scheme]
3714
+ assert_equal 'john', host1[:user]
3715
+ assert_equal 'password', host1[:password]
3716
+ assert_equal '/elastic/', host1[:path]
3717
+
3718
+ assert_equal 'host2', host2[:host]
3719
+ assert_equal 'http', host2[:scheme]
3720
+ assert_equal 'default_user', host2[:user]
3721
+ assert_equal 'default_password', host2[:password]
3722
+ assert_equal '/default_path', host2[:path]
3723
+ end
3724
+
3665
3725
  def test_hosts_list_with_escape_placeholders
3666
3726
  config = %{
3667
3727
  hosts https://%{j+hn}:%{passw@rd}@[2404:7a80:d440:3000:192a:a292:bd7f:ca19]:443/elastic/,http://host2
@@ -3708,6 +3768,24 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
3708
3768
  assert_equal nil, host1[:path]
3709
3769
  end
3710
3770
 
3771
+ def test_single_existing_connection
3772
+ config = %{
3773
+ user john
3774
+ password doe
3775
+ }
3776
+ instance = driver(config).instance
3777
+
3778
+ assert_equal 1, instance.get_connection_options("logs.google.com")[:hosts].length
3779
+ host1 = instance.get_connection_options("logs.google.com")[:hosts][0]
3780
+
3781
+ assert_equal 'logs.google.com', host1[:host]
3782
+ assert_equal 9200, host1[:port]
3783
+ assert_equal 'http', host1[:scheme]
3784
+ assert_equal 'john', host1[:user]
3785
+ assert_equal 'doe', host1[:password]
3786
+ assert_equal nil, host1[:path]
3787
+ end
3788
+
3711
3789
  def test_single_host_params_and_defaults_with_escape_placeholders
3712
3790
  config = %{
3713
3791
  host logs.google.com
@@ -3762,6 +3840,34 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
3762
3840
  assert_equal nil, host1[:path]
3763
3841
  end
3764
3842
 
3843
+ def test_single_existing_connection
3844
+ config = %{
3845
+ user john
3846
+ password doe
3847
+ }
3848
+ instance = driver(config).instance
3849
+
3850
+ assert_equal 1, instance.get_connection_options("2404:7a80:d440:3000:192a:a292:bd7f:ca19")[:hosts].length
3851
+ host1 = instance.get_connection_options("2404:7a80:d440:3000:192a:a292:bd7f:ca19")[:hosts][0]
3852
+
3853
+ assert_equal 1, instance.get_connection_options("[2404:7a80:d440:3000:192a:a292:bd7f:ca19]")[:hosts].length
3854
+ host2 = instance.get_connection_options("[2404:7a80:d440:3000:192a:a292:bd7f:ca19]")[:hosts][0]
3855
+
3856
+ assert_equal '[2404:7a80:d440:3000:192a:a292:bd7f:ca19]', host1[:host]
3857
+ assert_equal 9200, host1[:port]
3858
+ assert_equal 'http', host1[:scheme]
3859
+ assert_equal 'john', host1[:user]
3860
+ assert_equal 'doe', host1[:password]
3861
+ assert_equal nil, host1[:path]
3862
+
3863
+ assert_equal '[2404:7a80:d440:3000:192a:a292:bd7f:ca19]', host2[:host]
3864
+ assert_equal 9200, host2[:port]
3865
+ assert_equal 'http', host2[:scheme]
3866
+ assert_equal 'john', host2[:user]
3867
+ assert_equal 'doe', host2[:password]
3868
+ assert_equal nil, host2[:path]
3869
+ end
3870
+
3765
3871
  def test_single_host_params_and_defaults_with_escape_placeholders
3766
3872
  config = %{
3767
3873
  host 2404:7a80:d440:3000:192a:a292:bd7f:ca19
@@ -3794,13 +3900,15 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
3794
3900
 
3795
3901
  def test_content_type_header
3796
3902
  stub_request(:head, "http://localhost:9200/").
3797
- to_return(:status => 200, :body => "", :headers => {})
3903
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
3798
3904
  if Elasticsearch::VERSION >= "6.0.2"
3799
3905
  elastic_request = stub_request(:post, "http://localhost:9200/_bulk").
3800
- with(headers: { "Content-Type" => "application/x-ndjson" })
3906
+ with(headers: { "Content-Type" => "application/x-ndjson" }).
3907
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
3801
3908
  else
3802
3909
  elastic_request = stub_request(:post, "http://localhost:9200/_bulk").
3803
- with(headers: { "Content-Type" => "application/json" })
3910
+ with(headers: { "Content-Type" => "application/json" }).
3911
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
3804
3912
  end
3805
3913
  stub_elastic_info
3806
3914
  driver.run(default_tag: 'test') do
@@ -3811,9 +3919,10 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
3811
3919
 
3812
3920
  def test_custom_headers
3813
3921
  stub_request(:head, "http://localhost:9200/").
3814
- to_return(:status => 200, :body => "", :headers => {})
3922
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
3815
3923
  elastic_request = stub_request(:post, "http://localhost:9200/_bulk").
3816
- with(headers: {'custom' => 'header1','and_others' => 'header2' })
3924
+ with(headers: {'custom' => 'header1','and_others' => 'header2' }).
3925
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
3817
3926
  stub_elastic_info
3818
3927
  driver.configure(%[custom_headers {"custom":"header1", "and_others":"header2"}])
3819
3928
  driver.run(default_tag: 'test') do
@@ -3824,9 +3933,10 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
3824
3933
 
3825
3934
  def test_api_key_header
3826
3935
  stub_request(:head, "http://localhost:9200/").
3827
- to_return(:status => 200, :body => "", :headers => {})
3936
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
3828
3937
  elastic_request = stub_request(:post, "http://localhost:9200/_bulk").
3829
- with(headers: {'Authorization'=>'ApiKey dGVzdGF1dGhoZWFkZXI='})
3938
+ with(headers: {'Authorization'=>'ApiKey dGVzdGF1dGhoZWFkZXI='}).
3939
+ to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
3830
3940
  stub_elastic_info
3831
3941
  driver.configure(%[api_key testauthheader])
3832
3942
  driver.run(default_tag: 'test') do
@@ -3895,7 +4005,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
3895
4005
  compressed_body = gzip(bodystr, Zlib::DEFAULT_COMPRESSION)
3896
4006
 
3897
4007
  elastic_request = stub_request(:post, "http://localhost:9200/_bulk").
3898
- to_return(:status => 200, :headers => {'Content-Type' => 'Application/json'}, :body => compressed_body)
4008
+ to_return(:status => 200, :headers => {'Content-Type' => 'Application/json', 'x-elastic-product' => 'Elasticsearch'}, :body => compressed_body)
3899
4009
  stub_elastic_info("http://localhost:9200/")
3900
4010
 
3901
4011
  driver(config)
@@ -3975,7 +4085,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
3975
4085
  with(
3976
4086
  body: /#{index_part}\n{"age":26,"request_id":"42","parent_id":"parent","routing_id":"routing","#{chunk_id_key}":".*"}\n/) do |req|
3977
4087
  @index_cmds = req.body.split("\n").map {|r| JSON.parse(r) }
3978
- end
4088
+ end.to_return({:status => 200, :body => "", :headers => { 'Content-Type' => 'json', 'x-elastic-product' => 'Elasticsearch' } })
3979
4089
  stub_elastic_info
3980
4090
  driver.run(default_tag: 'test', shutdown: false) do
3981
4091
  driver.feed(sample_record)
@@ -4137,7 +4247,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
4137
4247
  )
4138
4248
  .to_return(lambda do |req|
4139
4249
  { :status => 200,
4140
- :headers => { 'Content-Type' => 'json' },
4250
+ :headers => { 'Content-Type' => 'json', 'x-elastic-product' => 'Elasticsearch'},
4141
4251
  :body => return_body_str
4142
4252
  }
4143
4253
  end)
@@ -5493,7 +5603,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
5493
5603
  stub_request(:post, "http://localhost:9200/_bulk").with do |req|
5494
5604
  connection_resets += 1
5495
5605
  raise Faraday::ConnectionFailed, "Test message"
5496
- end
5606
+ end.to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
5497
5607
  stub_elastic_info
5498
5608
 
5499
5609
  assert_raise(Fluent::Plugin::ElasticsearchOutput::RecoverableRequestFailure) {
@@ -5510,7 +5620,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
5510
5620
  stub_request(:post, "http://localhost:9200/_bulk").with do |req|
5511
5621
  connection_resets += 1
5512
5622
  raise ZeroDivisionError, "any not host_unreachable_exceptions exception"
5513
- end
5623
+ end.to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
5514
5624
  stub_elastic_info
5515
5625
 
5516
5626
  driver.configure("reconnect_on_error true\n")
@@ -5537,7 +5647,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
5537
5647
  stub_request(:post, "http://localhost:9200/_bulk").with do |req|
5538
5648
  connection_resets += 1
5539
5649
  raise ZeroDivisionError, "any not host_unreachable_exceptions exception"
5540
- end
5650
+ end.to_return(:status => 200, :body => "", :headers => {'x-elastic-product' => 'Elasticsearch'})
5541
5651
  stub_elastic_info
5542
5652
 
5543
5653
  driver.configure("reconnect_on_error false\n")
@@ -5561,7 +5671,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
5561
5671
  stub_request(:post, 'http://localhost:9200/_bulk')
5562
5672
  .to_return(lambda do |req|
5563
5673
  { :status => 200,
5564
- :headers => { 'Content-Type' => 'json' },
5674
+ :headers => { 'Content-Type' => 'json', 'x-elastic-product' => 'Elasticsearch'},
5565
5675
  :body => %({
5566
5676
  "took" : 1,
5567
5677
  "errors" : true,
@@ -5621,7 +5731,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
5621
5731
  stub_request(:post, 'http://localhost:9200/_bulk')
5622
5732
  .to_return(lambda do |req|
5623
5733
  { :status => 200,
5624
- :headers => { 'Content-Type' => 'json' },
5734
+ :headers => { 'Content-Type' => 'json', 'x-elastic-product' => 'Elasticsearch'},
5625
5735
  :body => %({
5626
5736
  "took" : 1,
5627
5737
  "errors" : true,
@@ -5673,7 +5783,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
5673
5783
  stub_request(:post, 'http://localhost:9200/_bulk')
5674
5784
  .to_return(lambda do |req|
5675
5785
  { :status => 200,
5676
- :headers => { 'Content-Type' => 'json' },
5786
+ :headers => { 'Content-Type' => 'json', 'x-elastic-product' => 'Elasticsearch' },
5677
5787
  :body => %({
5678
5788
  "took" : 1,
5679
5789
  "errors" : true,
@@ -5724,7 +5834,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
5724
5834
  stub_request(:post, 'http://localhost:9200/_bulk')
5725
5835
  .to_return(lambda do |req|
5726
5836
  { :status => 200,
5727
- :headers => { 'Content-Type' => 'json' },
5837
+ :headers => { 'Content-Type' => 'json', 'x-elastic-product' => 'Elasticsearch' },
5728
5838
  :body => %({
5729
5839
  "took" : 1,
5730
5840
  "errors" : true,
@@ -5774,7 +5884,7 @@ class ElasticsearchOutputTest < Test::Unit::TestCase
5774
5884
  stub_request(:post, 'http://localhost:9200/_bulk')
5775
5885
  .to_return(lambda do |req|
5776
5886
  { :status => 200,
5777
- :headers => { 'Content-Type' => 'json' },
5887
+ :headers => { 'Content-Type' => 'json', 'x-elastic-product' => 'Elasticsearch'},
5778
5888
  :body => %({
5779
5889
  "took" : 1,
5780
5890
  "errors" : true,