fluent-plugin-elasticsearch 1.9.4 → 1.9.5
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.
- checksums.yaml +4 -4
- data/History.md +6 -0
- data/README.md +8 -1
- data/fluent-plugin-elasticsearch.gemspec +1 -1
- data/lib/fluent/plugin/out_elasticsearch.rb +2 -1
- data/test/plugin/test_out_elasticsearch.rb +40 -9
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8af381642b4168628152b2baf959f30d85ecb3aa
|
4
|
+
data.tar.gz: 64f4f74cf949f999db949489a59ea264d524b41e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3b1da6085fb920f79bf1fd1951da9aa00fea43ad78cf1dc48febb51973cc075e6d6339b050254cd5f8eb5e08c5ec77db2ced1140abd0c3e918aeced9f560a7fb
|
7
|
+
data.tar.gz: e8701fbad7986ddb9be19659a6d27d79b180b5ec25ca95384bd888af0edef5e3b9ea112ad82fd905f7dab6da2992006dda3234caf3875bacea6f5eab3ef81bee
|
data/History.md
CHANGED
@@ -4,6 +4,12 @@
|
|
4
4
|
- Log ES response errors (#230)
|
5
5
|
- Use latest elasticsearch-ruby (#240)
|
6
6
|
|
7
|
+
### 1.9.5
|
8
|
+
- sub-second time precision [(#249)](https://github.com/uken/fluent-plugin-elasticsearch/pull/249)
|
9
|
+
|
10
|
+
### 1.9.4
|
11
|
+
- Include 'Content-Type' header in `transport_options`
|
12
|
+
|
7
13
|
### 1.9.2
|
8
14
|
- Fix elasticsearch_dynamic for v0.14 (#224)
|
9
15
|
|
data/README.md
CHANGED
@@ -21,6 +21,7 @@ Note: For Amazon Elasticsearch Service please consider using [fluent-plugin-aws-
|
|
21
21
|
+ [logstash_prefix](#logstash_prefix)
|
22
22
|
+ [logstash_dateformat](#logstash_dateformat)
|
23
23
|
+ [time_key_format](#time_key_format)
|
24
|
+
+ [time_precision](#time_precision)
|
24
25
|
+ [time_key](#time_key)
|
25
26
|
+ [time_key_exclude_timestamp](#time_key_exclude_timestamp)
|
26
27
|
+ [utc_index](#utc_index)
|
@@ -140,6 +141,12 @@ For example to parse ISO8601 times with sub-second precision:
|
|
140
141
|
time_key_format %Y-%m-%dT%H:%M:%S.%N%z
|
141
142
|
```
|
142
143
|
|
144
|
+
### time_precision
|
145
|
+
|
146
|
+
Should the record not include a `time_key`, define the degree of sub-second time precision to preserve from the `time` portion of the routed event.
|
147
|
+
|
148
|
+
For example, should your input plugin not include a `time_key` in the record but it able to pass a `time` to the router when emitting the event (AWS CloudWatch events are an example of this), then this setting will allow you to preserve the sub-second time resolution of those events. This is the case for: [fluent-plugin-cloudwatch-ingest](https://github.com/sampointer/fluent-plugin-cloudwatch-ingest).
|
149
|
+
|
143
150
|
### time_key
|
144
151
|
|
145
152
|
By default, when inserting records in [Logstash](https://www.elastic.co/products/logstash) format, `@timestamp` is dynamically created with the time at log ingestion. If you'd like to use a custom time, include an `@timestamp` with your record.
|
@@ -360,7 +367,7 @@ remove_keys a_parent, a_routing # a_parent and a_routing fields won't be sent to
|
|
360
367
|
|
361
368
|
### remove_keys_on_update
|
362
369
|
|
363
|
-
Remove keys on update will not update the configured keys in elasticsearch when a record is being updated.
|
370
|
+
Remove keys on update will not update the configured keys in elasticsearch when a record is being updated.
|
364
371
|
This setting only has any effect if the write operation is update or upsert.
|
365
372
|
|
366
373
|
If the write setting is upsert then these keys are only removed if the record is being
|
@@ -3,7 +3,7 @@ $:.push File.expand_path('../lib', __FILE__)
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = 'fluent-plugin-elasticsearch'
|
6
|
-
s.version = '1.9.
|
6
|
+
s.version = '1.9.5'
|
7
7
|
s.authors = ['diogo', 'pitr']
|
8
8
|
s.email = ['pitr.vern@gmail.com', 'me@diogoterror.com']
|
9
9
|
s.description = %q{ElasticSearch output plugin for Fluent event collector}
|
@@ -27,6 +27,7 @@ class Fluent::ElasticsearchOutput < Fluent::ObjectBufferedOutput
|
|
27
27
|
config_param :target_index_key, :string, :default => nil
|
28
28
|
config_param :target_type_key, :string, :default => nil
|
29
29
|
config_param :time_key_format, :string, :default => nil
|
30
|
+
config_param :time_precision, :integer, :default => 0
|
30
31
|
config_param :logstash_format, :bool, :default => false
|
31
32
|
config_param :logstash_prefix, :string, :default => "logstash"
|
32
33
|
config_param :logstash_dateformat, :string, :default => "%Y.%m.%d"
|
@@ -300,7 +301,7 @@ class Fluent::ElasticsearchOutput < Fluent::ObjectBufferedOutput
|
|
300
301
|
record[TIMESTAMP_FIELD] = rts unless @time_key_exclude_timestamp
|
301
302
|
else
|
302
303
|
dt = Time.at(time).to_datetime
|
303
|
-
record[TIMESTAMP_FIELD] = dt.
|
304
|
+
record[TIMESTAMP_FIELD] = dt.iso8601(@time_precision)
|
304
305
|
end
|
305
306
|
dt = dt.new_offset(0) if @utc_index
|
306
307
|
target_index = "#{@logstash_prefix}-#{dt.strftime(@logstash_dateformat)}"
|
@@ -120,8 +120,8 @@ class ElasticsearchOutput < Test::Unit::TestCase
|
|
120
120
|
to_return(:status => 200, :body => "", :headers => {})
|
121
121
|
|
122
122
|
driver('test', config)
|
123
|
-
end
|
124
|
-
|
123
|
+
end
|
124
|
+
|
125
125
|
|
126
126
|
def test_template_create_invalid_filename
|
127
127
|
config = %{
|
@@ -177,14 +177,14 @@ class ElasticsearchOutput < Test::Unit::TestCase
|
|
177
177
|
to_return(:status => 200, :body => "", :headers => {})
|
178
178
|
stub_request(:put, "https://john:doe@logs.google.com:777/es//_template/logstash3").
|
179
179
|
to_return(:status => 200, :body => "", :headers => {})
|
180
|
-
|
180
|
+
|
181
181
|
driver('test', config)
|
182
|
-
|
182
|
+
|
183
183
|
assert_requested( :put, "https://john:doe@logs.google.com:777/es//_template/logstash1", times: 1)
|
184
184
|
assert_requested( :put, "https://john:doe@logs.google.com:777/es//_template/logstash2", times: 1)
|
185
185
|
assert_not_requested(:put, "https://john:doe@logs.google.com:777/es//_template/logstash3") #exists
|
186
186
|
end
|
187
|
-
|
187
|
+
|
188
188
|
def test_templates_not_used
|
189
189
|
cwd = File.dirname(__FILE__)
|
190
190
|
template_file = File.join(cwd, 'test_template.json')
|
@@ -199,7 +199,7 @@ class ElasticsearchOutput < Test::Unit::TestCase
|
|
199
199
|
template_name logstash
|
200
200
|
template_file #{template_file}
|
201
201
|
templates {"logstash1":"#{template_file}", "logstash2":"#{template_file}" }
|
202
|
-
}
|
202
|
+
}
|
203
203
|
# connection start
|
204
204
|
stub_request(:head, "https://john:doe@logs.google.com:777/es//").
|
205
205
|
to_return(:status => 200, :body => "", :headers => {})
|
@@ -254,7 +254,7 @@ class ElasticsearchOutput < Test::Unit::TestCase
|
|
254
254
|
assert_raise(RuntimeError) {
|
255
255
|
driver('test', config)
|
256
256
|
}
|
257
|
-
|
257
|
+
|
258
258
|
assert_requested(:put, "https://john:doe@logs.google.com:777/es//_template/logstash1", times: 1)
|
259
259
|
assert_not_requested(:put, "https://john:doe@logs.google.com:777/es//_template/logstash2")
|
260
260
|
end
|
@@ -780,6 +780,37 @@ class ElasticsearchOutput < Test::Unit::TestCase
|
|
780
780
|
assert_equal(index_cmds[1]['@timestamp'], ts)
|
781
781
|
end
|
782
782
|
|
783
|
+
def test_uses_no_subsecond_precision_by_default
|
784
|
+
driver.configure("logstash_format true\n")
|
785
|
+
stub_elastic_ping
|
786
|
+
stub_elastic
|
787
|
+
begin
|
788
|
+
time = Fluent::EventTime.new(Time.now.to_i, 000000000)
|
789
|
+
rescue
|
790
|
+
time = Fluent::Engine.now
|
791
|
+
end
|
792
|
+
driver.emit(sample_record, time)
|
793
|
+
driver.run
|
794
|
+
assert(index_cmds[1].has_key? '@timestamp')
|
795
|
+
assert_equal(index_cmds[1]['@timestamp'], Time.at(time).iso8601)
|
796
|
+
end
|
797
|
+
|
798
|
+
def test_uses_subsecond_precision_when_configured
|
799
|
+
driver.configure("logstash_format true
|
800
|
+
time_precision 3\n")
|
801
|
+
stub_elastic_ping
|
802
|
+
stub_elastic
|
803
|
+
begin
|
804
|
+
time = Fluent::EventTime.new(Time.now.to_i, 000000000)
|
805
|
+
rescue
|
806
|
+
time = Fluent::Engine.now
|
807
|
+
end
|
808
|
+
driver.emit(sample_record, time)
|
809
|
+
driver.run
|
810
|
+
assert(index_cmds[1].has_key? '@timestamp')
|
811
|
+
assert_equal(index_cmds[1]['@timestamp'], Time.at(time).iso8601(3))
|
812
|
+
end
|
813
|
+
|
783
814
|
def test_doesnt_add_tag_key_by_default
|
784
815
|
stub_elastic_ping
|
785
816
|
stub_elastic
|
@@ -941,7 +972,7 @@ class ElasticsearchOutput < Test::Unit::TestCase
|
|
941
972
|
stub_request(:post, "http://localhost:9200/_bulk").with do |req|
|
942
973
|
raise ZeroDivisionError, "any not host_unreachable_exceptions exception"
|
943
974
|
end
|
944
|
-
|
975
|
+
|
945
976
|
driver.configure("reconnect_on_error true\n")
|
946
977
|
driver.emit(sample_record)
|
947
978
|
|
@@ -965,7 +996,7 @@ class ElasticsearchOutput < Test::Unit::TestCase
|
|
965
996
|
stub_request(:post, "http://localhost:9200/_bulk").with do |req|
|
966
997
|
raise ZeroDivisionError, "any not host_unreachable_exceptions exception"
|
967
998
|
end
|
968
|
-
|
999
|
+
|
969
1000
|
driver.configure("reconnect_on_error false\n")
|
970
1001
|
driver.emit(sample_record)
|
971
1002
|
|