fluent-plugin-rds-mysql-log 0.1.1 → 0.1.3
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/fluent-plugin-rds-mysql-log.gemspec +2 -2
- data/lib/fluent/plugin/in_rds_mysql_log.rb +21 -11
- data/test/plugin/test_in_rds_mysql_log.rb +0 -10
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a3228cf8c54c9c3bc5a79742976dc646e549cee3a47fdbe2b0b403f3c326badd
|
4
|
+
data.tar.gz: 97e43edd9c455691f4fc7ec881d6d76fdceaf3187587f8df059360c7eef65587
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1c96f62c54275181ba8fc95f79f18e8b0106d73f87ef7100d01d95f0abf1d919fd76b79f7be4875056e97bd86460099d0d9d3b334b58448f0a062f0fe278d595
|
7
|
+
data.tar.gz: 179a3823ec2ac89c1b9781a7db5caa99acdf19d1fb9e568b3388ed4e151149238cde851901645003f36be6749e405ca8a7e701c3de0d90c6342016ab2d184292
|
@@ -5,7 +5,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = 'fluent-plugin-rds-mysql-log'
|
8
|
-
spec.version = '0.1.
|
8
|
+
spec.version = '0.1.3'
|
9
9
|
spec.authors = ['Junaid Ali']
|
10
10
|
spec.email = ['jonnie36@yahoo.com']
|
11
11
|
spec.summary = 'Amazon RDS Mysql logs input plugin'
|
@@ -13,7 +13,7 @@ Gem::Specification.new do |spec|
|
|
13
13
|
spec.homepage = 'https://github.com/iamjunaidali/fluent-plugin-rds-mysql-log.git'
|
14
14
|
spec.license = 'MIT'
|
15
15
|
spec.required_ruby_version = '>= 2.7.0'
|
16
|
-
|
16
|
+
|
17
17
|
spec.files = `git ls-files -z`.split("\x0")
|
18
18
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
19
19
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
@@ -75,6 +75,10 @@ class Fluent::Plugin::RdsMysqlLogInput < Fluent::Plugin::Input
|
|
75
75
|
log.warn "EC2 Client error occurred: #{e.message}"
|
76
76
|
end
|
77
77
|
end
|
78
|
+
|
79
|
+
def is_audit_logs?
|
80
|
+
@pos_info.keys.any? { |log_file_name| log_file_name =~ AUDIT_LOG_PATTERN }
|
81
|
+
end
|
78
82
|
|
79
83
|
def get_and_parse_posfile
|
80
84
|
begin
|
@@ -83,21 +87,28 @@ class Fluent::Plugin::RdsMysqlLogInput < Fluent::Plugin::Input
|
|
83
87
|
|
84
88
|
pos_last_written_timestamp = 0
|
85
89
|
pos_info = {}
|
90
|
+
|
86
91
|
File.open(@pos_file, File::RDONLY) do |file|
|
87
92
|
file.each_line do |line|
|
93
|
+
|
88
94
|
pos_match = /^(\d+)$/.match(line)
|
89
95
|
if pos_match
|
90
|
-
pos_last_written_timestamp = pos_match[1].to_i
|
96
|
+
pos_last_written_timestamp = pos_match[1].to_i
|
91
97
|
log.debug "pos_last_written_timestamp: #{pos_last_written_timestamp}"
|
92
98
|
end
|
93
99
|
|
94
100
|
pos_match = /^(.+)\t(.+)$/.match(line)
|
95
101
|
if pos_match
|
96
|
-
|
97
|
-
|
102
|
+
if pos_match[1] =~ AUDIT_LOG_PATTERN
|
103
|
+
pos_info[pos_match[1]] = 0
|
104
|
+
else
|
105
|
+
pos_info[pos_match[1]] = pos_match[2]
|
106
|
+
end
|
107
|
+
|
98
108
|
log.debug "log_file: #{pos_match[1]}, marker: #{pos_match[2]}"
|
99
109
|
end
|
100
110
|
end
|
111
|
+
|
101
112
|
@pos_last_written_timestamp = pos_last_written_timestamp
|
102
113
|
@pos_info = pos_info
|
103
114
|
end
|
@@ -126,11 +137,7 @@ class Fluent::Plugin::RdsMysqlLogInput < Fluent::Plugin::Input
|
|
126
137
|
begin
|
127
138
|
log.debug "get logfile-list from rds: db_instance_identifier=#{@db_instance_identifier}, pos_last_written_timestamp=#{@pos_last_written_timestamp}"
|
128
139
|
|
129
|
-
|
130
|
-
|
131
|
-
audit_logs_exist = @pos_info.keys.any? { |log_file_name| log_file_name =~ AUDIT_LOG_PATTERN }
|
132
|
-
|
133
|
-
file_last_written = if audit_logs_exist
|
140
|
+
file_last_written = if is_audit_logs?
|
134
141
|
# Use custom interval for audit logs
|
135
142
|
(Time.now.to_i - @refresh_interval) * 1000
|
136
143
|
else
|
@@ -155,9 +162,12 @@ class Fluent::Plugin::RdsMysqlLogInput < Fluent::Plugin::Input
|
|
155
162
|
# save maximum written timestamp value
|
156
163
|
@pos_last_written_timestamp = item[:last_written] if @pos_last_written_timestamp < item[:last_written]
|
157
164
|
|
158
|
-
|
159
|
-
|
160
|
-
|
165
|
+
log_file_name = item[:log_file_name]
|
166
|
+
marker = if is_audit_logs?
|
167
|
+
"0"
|
168
|
+
else
|
169
|
+
@pos_info[log_file_name] || "0"
|
170
|
+
end
|
161
171
|
|
162
172
|
log.debug "download log from rds: log_file_name=#{log_file_name}, marker=#{marker}"
|
163
173
|
logs = @rds.download_db_log_file_portion(
|
@@ -75,8 +75,6 @@ class RdsMysqlLogInputTest < Test::Unit::TestCase
|
|
75
75
|
|
76
76
|
assert_equal(events[0][2]["log_file_name"], 'server_audit.log')
|
77
77
|
assert_equal(events[0][2]["message"], "UPDATE table SET id=123, updated_at=\'2025-04-03 19:38:08.681797\', is_weight_saved=1 WHERE table.id = 1234")
|
78
|
-
|
79
|
-
# assert_equal(d.instance.instance_variable_get(:@pos_info)['server_audit.log'], 'new_marker')
|
80
78
|
end
|
81
79
|
|
82
80
|
def test_get_non_audit_log_files
|
@@ -140,18 +138,10 @@ class RdsMysqlLogInputTest < Test::Unit::TestCase
|
|
140
138
|
})
|
141
139
|
|
142
140
|
d.instance.instance_variable_set(:@rds, aws_client_stub)
|
143
|
-
|
144
|
-
d.instance.instance_variable_set(:@pos_last_written_timestamp, (Time.now.to_i - (2*2000)))
|
145
|
-
|
146
|
-
test_start_time = Time.now.to_i
|
147
|
-
buffer_time = 5 * d.instance.refresh_interval * 20000
|
148
|
-
|
149
141
|
d.run(timeout: 3, expect_emits: 1)
|
150
142
|
|
151
143
|
events = d.events
|
152
144
|
assert_equal(events[0][2]["log_file_name"], 'server_audit.log')
|
153
145
|
assert_equal(events[0][2]["message"], "UPDATE table SET id=123, updated_at=\'2025-04-03 19:38:08.681797\', is_weight_saved=1 WHERE table.id = 1234")
|
154
|
-
|
155
|
-
assert_operator events[0][1].to_i, :>=, (test_start_time - (buffer_time))
|
156
146
|
end
|
157
147
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-rds-mysql-log
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Junaid Ali
|
8
8
|
bindir: bin
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-04-
|
10
|
+
date: 2025-04-07 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: aws-sdk-ec2
|