logstash-input-elasticache 0.2.10 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a7b5c422e124c1074ca7d4c24b0ad7c7f639bdc2ff21a5e97f98d895e86b8f08
4
- data.tar.gz: 4f9b9dd48c6d2f2c31d21eb2cefca706f637785648accd9a5f9ea8fcf303768f
3
+ metadata.gz: b293f0027b99f3844f2183bd30efbe1ee9c197a0e099ce4407fc0d41ac4ebcc8
4
+ data.tar.gz: 182293b263ff5027fc7ae99eac52533aa8beef28f89566150e710d7ace6f5507
5
5
  SHA512:
6
- metadata.gz: a6e3555c977c4fdc759e3895098714856c7a7591c393e2bf7467d68ed8e31e2ab96599c05bc29a2708234e4494e7b8572bc76b735fc6ac502036790a18e11bcb
7
- data.tar.gz: 5a756c510129835b2c6271b612364c7d4d6a2618a4e9241b2d777abfcb3bf8bafcc5ac318f479b9cfa81591026e2f3631c31c8d21f9d7feae568e80958dfdf71
6
+ metadata.gz: 65e11c26d01eaa764a778edc0141151a7c69406328d591f0676dbf9847705211e976ed8bf62418e5e8329c68b4a5399bcda249eb8930145d1f673e31fec677f4
7
+ data.tar.gz: a7bbe5641232af2c34fbc631052c398c2f526cac31318caa445d3135072cadcd6f4a83f88cd0608ca86e3fa2d2404ec67f40336582911f4b39e03526bec4cf64
@@ -18,12 +18,15 @@ class LogStash::Inputs::ElastiCache < LogStash::Inputs::Base
18
18
  config :source_type, :validate => :string, :required => true
19
19
  config :source_name, :validate => :string, :required => true
20
20
  config :polling_frequency, :validate => :number, :default => 600
21
+ config :sincedb_path, :validate => :string, :default => nil
21
22
 
22
23
  def register
23
24
  require "aws-sdk"
24
25
  @logger.info "Registering ElastiCache input", :region => @region, :source_type => @source_type, :source_name => @source_name
25
26
  @elasticache = Aws::ElastiCache::Client.new aws_options_hash
26
- @since = DateTime.now - 13 # FIXME sincedb
27
+
28
+ path = @sincedb_path || File.join(ENV["HOME"], ".sincedb_" + Digest::MD5.hexdigest("#{@source_type}+#{@source_name}"))
29
+ @sincedb = SinceDB::File.new path
27
30
  end
28
31
 
29
32
  def run(queue)
@@ -38,7 +41,7 @@ class LogStash::Inputs::ElastiCache < LogStash::Inputs::Base
38
41
  response = @elasticache.describe_events({
39
42
  source_identifier: @source_name,
40
43
  source_type: @source_type,
41
- start_time: @since,
44
+ start_time: @sincedb.read,
42
45
  end_time: checkpoint,
43
46
  marker: marker,
44
47
  })
@@ -47,7 +50,7 @@ class LogStash::Inputs::ElastiCache < LogStash::Inputs::Base
47
50
  more = response[:marker]
48
51
  marker = response[:marker]
49
52
  end
50
- @since = checkpoint
53
+ @sincedb.write checkpoint
51
54
  end
52
55
  end
53
56
  end
@@ -82,4 +85,26 @@ class LogStash::Inputs::ElastiCache < LogStash::Inputs::Base
82
85
  @logger.debug "shipping #{event} to #{queue}"
83
86
  queue << event
84
87
  end
88
+
89
+ private
90
+ module SinceDB
91
+ class File
92
+ def initialize(file)
93
+ @db = file
94
+ end
95
+
96
+ def read
97
+ if ::File.exists?(@db)
98
+ content = ::File.read(@db).chomp.strip
99
+ return content.empty? ? Time.new : Time.parse(content)
100
+ else
101
+ return DateTime.now - 13
102
+ end
103
+ end
104
+
105
+ def write(time)
106
+ ::File.open(@db, 'w') { |file| file.write time.to_s }
107
+ end
108
+ end
109
+ end
85
110
  end
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'logstash-input-elasticache'
3
- s.version = '0.2.10'
3
+ s.version = '0.3.1'
4
4
  s.summary = 'Import events from ElastiCache to Logstash'
5
5
 
6
6
  s.authors = ['Andrew Schleifer']
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-input-elasticache
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.10
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Schleifer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-12-22 00:00:00.000000000 Z
11
+ date: 2018-01-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement