fluent-plugin-rds-mysql-log 0.1.7 → 0.1.9
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/README.md +36 -2
- data/fluent-plugin-rds-mysql-log.gemspec +4 -5
- data/lib/fluent/plugin/in_rds_mysql_log.rb +1 -0
- data/test/plugin/test_in_rds_mysql_log.rb +2 -0
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 887e7a7add419cb9fb39dfd6afd859404fb9c58b0cbbfe8eabe89a799ee7e79c
|
4
|
+
data.tar.gz: 4be0d709822ee1ae20c9ea536e39d4ee2ec8d612d10cebf0dee9828975893cd6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5e7b69425e6d13d6a4aa7d8cd26338d7fec55e588da45ae2bbf5578ce278e77c215e5af7aaa62c7752c35b14bffd44697921b8e2eba81e72594aa1e5731ff922
|
7
|
+
data.tar.gz: 4e67f019f6e5e3430deff0f079b9b3f2982560eed61dbaaaf97873e6c301a0c89baaa9200ef44faed5168948b3f0f9c4e9adf57563500139532fc6ce7c437097
|
data/README.md
CHANGED
@@ -1,9 +1,43 @@
|
|
1
1
|
# fluent-plugin-rds-mysql-log
|
2
2
|
|
3
3
|
## Overview
|
4
|
-
|
4
|
+
### AWS RDS log input plugin of Mysql for fluentd
|
5
5
|
|
6
|
-
This
|
6
|
+
This gem is customized specifically for **MySQL audit logs**, especially tailored for environments where **log rotation** is enabled. In such setups, audit logs rotate every 60 seconds, producing files with a numbered suffix like:
|
7
|
+
|
8
|
+
```
|
9
|
+
audit/server_audit.log.01
|
10
|
+
audit/server_audit.log.02
|
11
|
+
...
|
12
|
+
```
|
13
|
+
|
14
|
+
In my use case, I am using the [MariaDB Audit Plugin for MySQL](https://github.com/aws/audit-plugin-for-mysql) to generate these logs.
|
15
|
+
|
16
|
+
### Inspiration
|
17
|
+
|
18
|
+
This plugin is inspired by [fluent-plugin-rds-pgsql-log](https://github.com/shinsaka/fluent-plugin-rds-pgsql-log).
|
19
|
+
I reused and adapted some of its ideas to handle MySQL audit logs more effectively.
|
20
|
+
|
21
|
+
### Handling Markers and Log Rotation
|
22
|
+
|
23
|
+
One of the key challenges with audit logs is **marker tracking**, because rotated log file names (like `server_audit.log.01`) are not timestamp-based and can repeat over time. This can cause Fluentd to:
|
24
|
+
- Read logs the first time with marker set to `0`
|
25
|
+
- Mark the file as "read" using the marker
|
26
|
+
- Then skip reading it again, even if new content arrives
|
27
|
+
|
28
|
+
To address this, there were two potential approaches:
|
29
|
+
|
30
|
+
A general behavior of master log file `audit/server_audit.log` is to receive logs continuously and rotated into `.01`, `.02`, etc., after reaching a size limit.
|
31
|
+
|
32
|
+
#### ✅ Approach 1: Track markers for rotated files (e.g., `server_audit.log.01`, `.02`)
|
33
|
+
|
34
|
+
By always reading master file `audit/server_audit.log` from the beginning (`marker = 0`), we avoid duplicates and ensure complete log ingestion. While maintaining marker of rotated files avoid duplication.
|
35
|
+
|
36
|
+
#### ❌ Approach 2: Track markers for master file (`audit/server_audit.log`)
|
37
|
+
|
38
|
+
By always reading rotated files (e.g., `server_audit.log.01`, `.02`) from the beginning (`marker = 0`), we observed **duplicate log ingestion**.
|
39
|
+
|
40
|
+
**Therefore, adopting first approach** — treating the master audit log file as a fresh log source every time, while maintaining markers for rotated files.
|
7
41
|
|
8
42
|
## Installation
|
9
43
|
|
@@ -5,16 +5,15 @@ $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.9'
|
9
9
|
spec.authors = ['Junaid Ali']
|
10
10
|
spec.email = ['jonnie36@yahoo.com']
|
11
11
|
spec.summary = 'Amazon RDS Mysql logs input plugin'
|
12
12
|
spec.description = 'fluentd plugin for Amazon RDS Mysql logs input'
|
13
|
-
spec.homepage = 'https://github.com/iamjunaidali/fluent-plugin-rds-mysql-log
|
13
|
+
spec.homepage = 'https://github.com/iamjunaidali/fluent-plugin-rds-mysql-log'
|
14
14
|
|
15
|
-
spec.metadata =
|
16
|
-
|
17
|
-
}
|
15
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
16
|
+
spec.metadata["source_code_uri"] = 'https://github.com/iamjunaidali/fluent-plugin-rds-mysql-log'
|
18
17
|
|
19
18
|
spec.license = 'MIT'
|
20
19
|
spec.required_ruby_version = '>= 2.7.0'
|
@@ -153,7 +153,9 @@ class RdsMysqlLogInputTest < Test::Unit::TestCase
|
|
153
153
|
assert_equal(2, events.size)
|
154
154
|
assert_equal(events[0][2]["log_file_name"], 'audit/server_audit.log')
|
155
155
|
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")
|
156
|
+
assert_equal(events[0][2]["detected_level"], "info")
|
156
157
|
assert_equal(events[1][2]["log_file_name"], 'audit/server_audit.log')
|
157
158
|
assert_equal(events[1][2]["message"], "UPDATE table SET id=456, updated_at=\'2025-04-03 19:38:08.681797\', is_weight_saved=1 WHERE table.id = 5678")
|
159
|
+
assert_equal(events[1][2]["detected_level"], "info")
|
158
160
|
end
|
159
161
|
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.9
|
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-14 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: aws-sdk-ec2
|
@@ -144,11 +144,12 @@ files:
|
|
144
144
|
- lib/fluent/plugin/in_rds_mysql_log.rb
|
145
145
|
- test/helper.rb
|
146
146
|
- test/plugin/test_in_rds_mysql_log.rb
|
147
|
-
homepage: https://github.com/iamjunaidali/fluent-plugin-rds-mysql-log
|
147
|
+
homepage: https://github.com/iamjunaidali/fluent-plugin-rds-mysql-log
|
148
148
|
licenses:
|
149
149
|
- MIT
|
150
150
|
metadata:
|
151
|
-
|
151
|
+
homepage_uri: https://github.com/iamjunaidali/fluent-plugin-rds-mysql-log
|
152
|
+
source_code_uri: https://github.com/iamjunaidali/fluent-plugin-rds-mysql-log
|
152
153
|
rdoc_options: []
|
153
154
|
require_paths:
|
154
155
|
- lib
|