fluent-plugin-elasticsearch 0.6.1 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f8996e6467b32911e04aee292d62260af99fbb0c
4
- data.tar.gz: e9a20b223483d5ec1662b191dc85f2153f63da09
3
+ metadata.gz: db7ae2774a9228b9590ed370a165dce4b02cffb9
4
+ data.tar.gz: 0a3fdd28683a0c7a63169b2ed9b9188876d205f2
5
5
  SHA512:
6
- metadata.gz: 3d4e373bf3a028d3756ac00390231a292af88e58742eb5b3686152a47ca50908abc118421a2318f4ba4d800b4d6995894a42081f1b2737afc5b0c56650b1b725
7
- data.tar.gz: 1ffdf80eb1094f23883a69bf1688450d921e0c1c777e10eb73870df52146979e85b6c7c2ab5f5ab27b16fe02c900a8f7f4c711a8a89d3a27f5bde336d67b470c
6
+ metadata.gz: 97264a9bd9817e7cd4b43e413f6ac492d61dfac495256008209f08453db1f889a188c2f46d15c674c9c619fc488deeec343169312f01daabd6654b7d31d06586
7
+ data.tar.gz: 42f10a91ad47b1927411cef10ddd33d093b7e56608940feb3e032c06110945b74c7d1484bcc6d1a5a136d4c59ceb85912f4ebfcc1d85cc83f2586b6e6b706041
data/History.md CHANGED
@@ -2,6 +2,9 @@
2
2
 
3
3
  ### Future
4
4
 
5
+ ### 0.7.0
6
+ - Add new option `time_key` (#85)
7
+
5
8
  ### 0.6.1
6
9
  - 0.10.43 is minimum version required of fluentd (#79)
7
10
 
data/README.md CHANGED
@@ -79,6 +79,32 @@ By default, when inserting records in logstash format, @timestamp is dynamically
79
79
  {"@timestamp":"2014-04-07T000:00:00-00:00"}
80
80
  ```
81
81
 
82
+ You can specify an option `time_key` (like the option described in [tail Input Plugin](http://docs.fluentd.org/articles/in_tail)) if you don't like `@timestamp`.
83
+
84
+ Suppose you have settings
85
+
86
+ ```
87
+ logstash_format true
88
+ time_key vtm
89
+ ```
90
+
91
+ Your input is:
92
+ ```
93
+ {
94
+ "title": "developer",
95
+ "vtm": "2014-12-19T08:01:03Z"
96
+ }
97
+ ```
98
+
99
+ The output will be
100
+ ```
101
+ {
102
+ "title": "developer",
103
+ "@timstamp": "2014-12-19T08:01:03Z",
104
+ "vtm": "2014-12-19T08:01:03Z"
105
+ }
106
+ ```
107
+
82
108
  By default, the records inserted into index `logstash-YYMMDD`. This option allows to insert into specified index like `logstash-YYYYMM` for a monthly index.
83
109
 
84
110
  ```
@@ -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 = '0.6.1'
6
+ s.version = '0.7.0'
7
7
  s.authors = ['diogo', 'pitr']
8
8
  s.email = ['pitr@uken.com', 'diogo@uken.com']
9
9
  s.description = %q{ElasticSearch output plugin for Fluent event collector}
@@ -27,6 +27,7 @@ class Fluent::ElasticsearchOutput < Fluent::BufferedOutput
27
27
  config_param :request_timeout, :time, :default => 5
28
28
  config_param :reload_connections, :bool, :default => true
29
29
  config_param :reload_on_failure, :bool, :default => false
30
+ config_param :time_key, :string, :default => nil
30
31
 
31
32
  include Fluent::SetTagKeyMixin
32
33
  config_set_default :include_tag_key, false
@@ -125,6 +126,9 @@ class Fluent::ElasticsearchOutput < Fluent::BufferedOutput
125
126
  if @logstash_format
126
127
  if record.has_key?("@timestamp")
127
128
  time = Time.parse record["@timestamp"]
129
+ elsif record.has_key?(@time_key)
130
+ time = Time.parse record[@time_key]
131
+ record['@timestamp'] = record[@time_key]
128
132
  else
129
133
  record.merge!({"@timestamp" => Time.at(time).to_datetime.to_s})
130
134
  end
@@ -30,7 +30,7 @@ class ElasticsearchOutput < Test::Unit::TestCase
30
30
  end
31
31
 
32
32
  def stub_elastic_ping(url="http://localhost:9200")
33
- stub_request(:head, url).with.to_return(:status => 200, :body => "", :headers => {})
33
+ stub_request(:head, url).to_return(:status => 200, :body => "", :headers => {})
34
34
  end
35
35
 
36
36
  def stub_elastic(url="http://localhost:9200/_bulk")
@@ -333,6 +333,18 @@ class ElasticsearchOutput < Test::Unit::TestCase
333
333
  assert_equal(index_cmds[1]['@timestamp'], ts)
334
334
  end
335
335
 
336
+ def test_uses_custom_time_key
337
+ driver.configure("logstash_format true
338
+ time_key vtm\n")
339
+ stub_elastic_ping
340
+ stub_elastic
341
+ ts = DateTime.new(2001,2,3).to_s
342
+ driver.emit(sample_record.merge!('vtm' => ts))
343
+ driver.run
344
+ assert(index_cmds[1].has_key? '@timestamp')
345
+ assert_equal(index_cmds[1]['@timestamp'], ts)
346
+ end
347
+
336
348
  def test_doesnt_add_tag_key_by_default
337
349
  stub_elastic_ping
338
350
  stub_elastic
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-elasticsearch
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - diogo
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-11-03 00:00:00.000000000 Z
12
+ date: 2014-12-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: fluentd