logstash-input-elasticache 0.2.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +3 -0
- data/LICENSE +11 -0
- data/README.md +10 -0
- data/lib/logstash/inputs/elasticache.rb +85 -0
- data/logstash-input-elasticache.gemspec +23 -0
- metadata +120 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: a7b5c422e124c1074ca7d4c24b0ad7c7f639bdc2ff21a5e97f98d895e86b8f08
|
4
|
+
data.tar.gz: 4f9b9dd48c6d2f2c31d21eb2cefca706f637785648accd9a5f9ea8fcf303768f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a6e3555c977c4fdc759e3895098714856c7a7591c393e2bf7467d68ed8e31e2ab96599c05bc29a2708234e4494e7b8572bc76b735fc6ac502036790a18e11bcb
|
7
|
+
data.tar.gz: 5a756c510129835b2c6271b612364c7d4d6a2618a4e9241b2d777abfcb3bf8bafcc5ac318f479b9cfa81591026e2f3631c31c8d21f9d7feae568e80958dfdf71
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
2
|
+
you may not use this file except in compliance with the License.
|
3
|
+
You may obtain a copy of the License at
|
4
|
+
|
5
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
6
|
+
|
7
|
+
Unless required by applicable law or agreed to in writing, software
|
8
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
9
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
10
|
+
See the License for the specific language governing permissions and
|
11
|
+
limitations under the License.
|
data/README.md
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require "logstash/inputs/base"
|
3
|
+
require "logstash/namespace"
|
4
|
+
require "logstash/plugin_mixins/aws_config"
|
5
|
+
require "stud/interval"
|
6
|
+
require "aws-sdk"
|
7
|
+
require "date"
|
8
|
+
|
9
|
+
Aws.eager_autoload!
|
10
|
+
|
11
|
+
class LogStash::Inputs::ElastiCache < LogStash::Inputs::Base
|
12
|
+
include LogStash::PluginMixins::AwsConfig::V2
|
13
|
+
|
14
|
+
config_name "elasticache"
|
15
|
+
milestone 1
|
16
|
+
default :codec, "plain"
|
17
|
+
|
18
|
+
config :source_type, :validate => :string, :required => true
|
19
|
+
config :source_name, :validate => :string, :required => true
|
20
|
+
config :polling_frequency, :validate => :number, :default => 600
|
21
|
+
|
22
|
+
def register
|
23
|
+
require "aws-sdk"
|
24
|
+
@logger.info "Registering ElastiCache input", :region => @region, :source_type => @source_type, :source_name => @source_name
|
25
|
+
@elasticache = Aws::ElastiCache::Client.new aws_options_hash
|
26
|
+
@since = DateTime.now - 13 # FIXME sincedb
|
27
|
+
end
|
28
|
+
|
29
|
+
def run(queue)
|
30
|
+
@thread = Thread.current
|
31
|
+
Stud.interval(@polling_frequency) do
|
32
|
+
with_rescue_and_retry do
|
33
|
+
checkpoint = Time.now
|
34
|
+
|
35
|
+
more = true
|
36
|
+
marker = nil
|
37
|
+
while more do
|
38
|
+
response = @elasticache.describe_events({
|
39
|
+
source_identifier: @source_name,
|
40
|
+
source_type: @source_type,
|
41
|
+
start_time: @since,
|
42
|
+
end_time: checkpoint,
|
43
|
+
marker: marker,
|
44
|
+
})
|
45
|
+
|
46
|
+
response[:events].each { |item| enqueue item, queue }
|
47
|
+
more = response[:marker]
|
48
|
+
marker = response[:marker]
|
49
|
+
end
|
50
|
+
@since = checkpoint
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def stop
|
56
|
+
Stud.stop! @thread
|
57
|
+
end
|
58
|
+
|
59
|
+
def with_rescue_and_retry
|
60
|
+
begin
|
61
|
+
failures ||= 0
|
62
|
+
yield
|
63
|
+
rescue Aws::ElastiCache::Errors::ServiceError
|
64
|
+
failures += 1
|
65
|
+
if failures <= 4
|
66
|
+
@logger.warn "service error for #{@source_type} #{@source_name}, delaying attempt ##{failures + 1}"
|
67
|
+
sleep (2 ** failures)
|
68
|
+
retry
|
69
|
+
else
|
70
|
+
@logger.error "pausing #{@source_type} #{@source_name} after five failures, will resume in #{@polling_frequency}s"
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def enqueue(item, queue)
|
76
|
+
event = LogStash::Event.new({
|
77
|
+
"@timestamp" => item.date,
|
78
|
+
"message" => item.message,
|
79
|
+
})
|
80
|
+
decorate event
|
81
|
+
event.set @source_type.gsub(/-/, "_"), @source_name
|
82
|
+
@logger.debug "shipping #{event} to #{queue}"
|
83
|
+
queue << event
|
84
|
+
end
|
85
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = 'logstash-input-elasticache'
|
3
|
+
s.version = '0.2.10'
|
4
|
+
s.summary = 'Import events from ElastiCache to Logstash'
|
5
|
+
|
6
|
+
s.authors = ['Andrew Schleifer']
|
7
|
+
s.email = ['me@andrewschleifer.name']
|
8
|
+
s.homepage = 'https://github.com/discourse/logstash-input-elasticache'
|
9
|
+
|
10
|
+
s.require_paths = ['lib']
|
11
|
+
s.files = Dir['lib/**/*','spec/**/*','vendor/**/*','*.gemspec','*.md','CONTRIBUTORS','Gemfile','LICENSE','NOTICE.TXT']
|
12
|
+
s.test_files = s.files.grep(%r{^(test|spec|features)/})
|
13
|
+
|
14
|
+
# Special flag to let us know this is actually a logstash plugin
|
15
|
+
s.metadata = { 'logstash_plugin' => 'true', 'logstash_group' => 'input' }
|
16
|
+
|
17
|
+
# Gem dependencies
|
18
|
+
s.add_runtime_dependency 'logstash-core-plugin-api', '~> 2.0'
|
19
|
+
s.add_runtime_dependency 'logstash-codec-plain'
|
20
|
+
s.add_runtime_dependency 'logstash-mixin-aws'
|
21
|
+
s.add_runtime_dependency 'stud', '>= 0.0.22'
|
22
|
+
s.add_development_dependency 'logstash-devutils', '>= 0.0.16'
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,120 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: logstash-input-elasticache
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.10
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Andrew Schleifer
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-12-22 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
15
|
+
requirements:
|
16
|
+
- - "~>"
|
17
|
+
- !ruby/object:Gem::Version
|
18
|
+
version: '2.0'
|
19
|
+
name: logstash-core-plugin-api
|
20
|
+
prerelease: false
|
21
|
+
type: :runtime
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
requirement: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
name: logstash-codec-plain
|
34
|
+
prerelease: false
|
35
|
+
type: :runtime
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
requirement: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
47
|
+
name: logstash-mixin-aws
|
48
|
+
prerelease: false
|
49
|
+
type: :runtime
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
requirement: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: 0.0.22
|
61
|
+
name: stud
|
62
|
+
prerelease: false
|
63
|
+
type: :runtime
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 0.0.22
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
requirement: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: 0.0.16
|
75
|
+
name: logstash-devutils
|
76
|
+
prerelease: false
|
77
|
+
type: :development
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 0.0.16
|
83
|
+
description:
|
84
|
+
email:
|
85
|
+
- me@andrewschleifer.name
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- Gemfile
|
91
|
+
- LICENSE
|
92
|
+
- README.md
|
93
|
+
- lib/logstash/inputs/elasticache.rb
|
94
|
+
- logstash-input-elasticache.gemspec
|
95
|
+
homepage: https://github.com/discourse/logstash-input-elasticache
|
96
|
+
licenses: []
|
97
|
+
metadata:
|
98
|
+
logstash_plugin: 'true'
|
99
|
+
logstash_group: input
|
100
|
+
post_install_message:
|
101
|
+
rdoc_options: []
|
102
|
+
require_paths:
|
103
|
+
- lib
|
104
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
105
|
+
requirements:
|
106
|
+
- - ">="
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: '0'
|
109
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
110
|
+
requirements:
|
111
|
+
- - ">="
|
112
|
+
- !ruby/object:Gem::Version
|
113
|
+
version: '0'
|
114
|
+
requirements: []
|
115
|
+
rubyforge_project:
|
116
|
+
rubygems_version: 2.6.13
|
117
|
+
signing_key:
|
118
|
+
specification_version: 4
|
119
|
+
summary: Import events from ElastiCache to Logstash
|
120
|
+
test_files: []
|