logstash-input-rds 0.10.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: f5d470b025d41bd47c4d16db6e024a57a7c22a85f0047b27037f79bc4fed9175
4
+ data.tar.gz: 33bdc3b8fa47f832755aa73881d1c2c04e198a0b66774590d4203cd21afc273f
5
+ SHA512:
6
+ metadata.gz: 3db6fc440d15ad18d0f7bb34ca49cb6acc729da5559231b927870312decc4007e3bbe8ab70c99148c642b643b6f47a503a0073e2d72642d38259e74c9dc89ef8
7
+ data.tar.gz: 7f1bf5c19c52cbc47c890bc0a53ae4297e99a07491ed06950de91d6920fc31ddc0df162bb5a70ea73c7f8b84971eb97b10b03b06da4f6811dfa359a3c8679ede
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
3
+
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,4 @@
1
+ # Logstash Input RDS
2
+
3
+ Ingest RDS log files to Logstash.
4
+
@@ -0,0 +1,62 @@
1
+ # encoding: utf-8
2
+ require "logstash/inputs/base"
3
+ require "logstash/namespace"
4
+ require "stud/interval"
5
+ require "logstash/inputs/rds/patch"
6
+ require "time"
7
+
8
+ Aws.eager_autoload!
9
+
10
+ class LogStash::Inputs::Rds < LogStash::Inputs::Base
11
+ include LogStash::PluginMixins::AwsConfig::V2
12
+
13
+ config_name "rds"
14
+ milestone 1
15
+ default :codec, "plain"
16
+
17
+ config :instance_identifier, :validate => :string, :required => true
18
+ config :log_file_name, :validate => :string, :required => true
19
+ config :polling_frequency, :validate => :number, :default => 600
20
+
21
+ def register
22
+ require "aws-sdk"
23
+ @logger.info "Registering RDS input", :instance_identifier => @instance_identifier
24
+ @database = Aws::RDS::DBInstance.new @instance_identifier, aws_options_hash
25
+ @sincedate = filename2datetime "1999-01-01-01" # FIXME
26
+ end
27
+
28
+ def run(queue)
29
+ Stud.interval(@polling_frequency) do
30
+ @logger.info "finding files starting #{@sincedate} (#{@sincedate.to_i * 1000})"
31
+
32
+ logfiles = @database.log_files({
33
+ filename_contains: @log_file_name,
34
+ file_last_written: @sincedate.to_i * 1000,
35
+ })
36
+ logfiles.each do |logfile|
37
+ @sincedate = filename2datetime logfile.name
38
+
39
+ more = true
40
+ marker = "0"
41
+ while more do
42
+ response = logfile.download({marker: marker})
43
+ response[:log_file_data].lines.each do |line|
44
+ @codec.decode(line) do |event|
45
+ event.set "rds-instance", @instance_identifier
46
+ event.set "log-file", @log_file_name
47
+ queue << event
48
+ end
49
+ end
50
+ more = response[:additional_data_pending]
51
+ marker = response[:marker]
52
+ end
53
+ end
54
+ end
55
+ end
56
+
57
+ def filename2datetime(name)
58
+ fragments = name.match /(\d{4})-(\d{2})-(\d{2})-(\d{2})$/
59
+ Time.parse "#{fragments[1]}-#{fragments[2]}-#{fragments[3]} #{fragments[4]}"
60
+ end
61
+ end
62
+
@@ -0,0 +1,12 @@
1
+ require 'aws-sdk'
2
+
3
+ begin
4
+ old_stderr = $stderr
5
+ $stderr = StringIO.new
6
+
7
+ module Aws
8
+ const_set(:RDS, Aws::RDS)
9
+ end
10
+ ensure
11
+ $stderr = old_stderr
12
+ end
@@ -0,0 +1,21 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = 'logstash-input-rds'
3
+ s.version = '0.10.1'
4
+ s.summary = 'Stream events from RDS to Logstash'
5
+
6
+ s.authors = ['Andrew Schleifer']
7
+ s.email = 'me@andrewschleifer.name'
8
+
9
+ s.require_paths = ['lib']
10
+ s.files = Dir['lib/**/*','spec/**/*','vendor/**/*','*.gemspec','*.md','CONTRIBUTORS','Gemfile','LICENSE','NOTICE.TXT']
11
+ s.test_files = s.files.grep(%r{^(test|spec|features)/})
12
+
13
+ # Special flag to let us know this is actually a logstash plugin
14
+ s.metadata = { "logstash_plugin" => "true", "logstash_group" => "input" }
15
+
16
+ # Gem dependencies
17
+ s.add_runtime_dependency "logstash-core-plugin-api", "~> 2.0"
18
+ s.add_runtime_dependency 'logstash-codec-plain'
19
+ s.add_runtime_dependency 'stud', '>= 0.0.22'
20
+ s.add_development_dependency 'logstash-devutils', '>= 0.0.16'
21
+ end
@@ -0,0 +1,11 @@
1
+ # encoding: utf-8
2
+ require "logstash/devutils/rspec/spec_helper"
3
+ require "logstash/inputs/rds"
4
+
5
+ describe LogStash::Inputs::Rds do
6
+
7
+ it_behaves_like "an interruptible input plugin" do
8
+ let(:config) { { "interval" => 100 } }
9
+ end
10
+
11
+ end
metadata ADDED
@@ -0,0 +1,108 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: logstash-input-rds
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.10.1
5
+ platform: ruby
6
+ authors:
7
+ - Andrew Schleifer
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-12-05 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.0.22
47
+ name: stud
48
+ prerelease: false
49
+ type: :runtime
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: 0.0.22
55
+ - !ruby/object:Gem::Dependency
56
+ requirement: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: 0.0.16
61
+ name: logstash-devutils
62
+ prerelease: false
63
+ type: :development
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: 0.0.16
69
+ description:
70
+ email: me@andrewschleifer.name
71
+ executables: []
72
+ extensions: []
73
+ extra_rdoc_files: []
74
+ files:
75
+ - Gemfile
76
+ - LICENSE
77
+ - README.md
78
+ - lib/logstash/inputs/rds.rb
79
+ - lib/logstash/inputs/rds/patch.rb
80
+ - logstash-input-rds.gemspec
81
+ - spec/inputs/rds_spec.rb
82
+ homepage:
83
+ licenses: []
84
+ metadata:
85
+ logstash_plugin: 'true'
86
+ logstash_group: input
87
+ post_install_message:
88
+ rdoc_options: []
89
+ require_paths:
90
+ - lib
91
+ required_ruby_version: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ required_rubygems_version: !ruby/object:Gem::Requirement
97
+ requirements:
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ version: '0'
101
+ requirements: []
102
+ rubyforge_project:
103
+ rubygems_version: 2.6.13
104
+ signing_key:
105
+ specification_version: 4
106
+ summary: Stream events from RDS to Logstash
107
+ test_files:
108
+ - spec/inputs/rds_spec.rb