fluent-plugin-rds-mysql-log 0.1.8 → 0.1.10

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fcba57c8d4b6fc8d25f74197fc6cf800941e55f65c31d1afafa923fdcea142aa
4
- data.tar.gz: 7f8ce5fc38eacee479de6cd14052219cda2315263d59fde155252485327a9155
3
+ metadata.gz: 8c8518eb0a1d3f6518709c2c0c26215dd9ed673a6a58272b434cc0b22e7de513
4
+ data.tar.gz: 830699a65d0274d7174bc5e5a8fc5cf123c48324cdaefc79ef77966c2996c7ab
5
5
  SHA512:
6
- metadata.gz: f7cfe921848ccb44ac09611759137f55eb64211c915d75b5257120a3ad7c5f267264c3fd92cf208e238bac0d474872cb57a1c402a7ad9640b8d9643bfb335b06
7
- data.tar.gz: 30c7707b42d0cff2d0643ab49c1838b9359a218d34d60e3709f56d5a08e3be1f45bf5635ac3db03d8f2a6d1ce50977b3ec673a028e12ff68251d87ad296ad248
6
+ metadata.gz: '059a1d93f38aa05262e7c93155ff104d02245b7074780e3455a0effd94557c12913ef9591d9236018501c8355cf0f152bbe533749fddc41373b59584400b38e3'
7
+ data.tar.gz: a1ab70de3e8746816063793c4ce6934452d6be0e5e278f207b7ee6ed99bfd0b0c896de3cb4ca3711a74174b8d34591d9a92c7e40be6b4dc1070776967af019f0
data/README.md CHANGED
@@ -1,9 +1,43 @@
1
1
  # fluent-plugin-rds-mysql-log
2
2
 
3
3
  ## Overview
4
- - Amazon Web Services RDS log input plugin for fluentd
4
+ ### AWS RDS log input plugin of Mysql for fluentd
5
5
 
6
- This plugin has been created to deal with audit and error logs of mysql.
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,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'
8
+ spec.version = '0.1.10'
9
9
  spec.authors = ['Junaid Ali']
10
10
  spec.email = ['jonnie36@yahoo.com']
11
11
  spec.summary = 'Amazon RDS Mysql logs input plugin'
@@ -82,8 +82,6 @@ class Fluent::Plugin::RdsMysqlLogInput < Fluent::Plugin::Input
82
82
 
83
83
  def should_track_marker?(log_file_name)
84
84
  return false if log_file_name == "audit/server_audit.log"
85
- return false if log_file_name == "general/mysql-general.log"
86
- return false if log_file_name == "error/mysql-error-running.log"
87
85
 
88
86
  true
89
87
  end
@@ -221,6 +219,7 @@ class Fluent::Plugin::RdsMysqlLogInput < Fluent::Plugin::Input
221
219
  "message" => line_match[:query],
222
220
  "return_code" => line_match[:retcode],
223
221
  "log_file_name" => log_file_name,
222
+ "detected_level" => "info"
224
223
  }
225
224
  else
226
225
  record = {
@@ -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.8
4
+ version: 0.1.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Junaid Ali
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-04-09 00:00:00.000000000 Z
10
+ date: 2025-05-05 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: aws-sdk-ec2