fluent-plugin-rds-pgsql-log 0.3.2 → 0.4.0
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 +4 -0
- data/fluent-plugin-rds-pgsql-log.gemspec +1 -1
- data/lib/fluent/plugin/in_rds_pgsql_log.rb +9 -9
- data/test/plugin/test_in_rds_pgsql.rb +36 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8ef1de71b76cd256ade578928b9799c8a728ba8c
|
4
|
+
data.tar.gz: b32866f201c50d4e94a0c608db3762516500e5f1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 48d95204d022492d2a38a7070e2dfe1bb8bb9a960a90f5d7cab78efbddd147c0707ee391d863430cbf24a00f41cd67028646f9b119246989da14d050c4cb0117
|
7
|
+
data.tar.gz: 0f234c127f0ff778cc5914a837be2e77bbed9fbe661e4848ce585c30fa2146dd2acb65f8172e8e5fa7f0c0b61687a23ae971a9e803cd81e3ee46034d760bb541
|
data/README.md
CHANGED
@@ -3,7 +3,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |spec|
|
5
5
|
spec.name = "fluent-plugin-rds-pgsql-log"
|
6
|
-
spec.version = "0.
|
6
|
+
spec.version = "0.4.0"
|
7
7
|
spec.authors = ["shinsaka"]
|
8
8
|
spec.email = ["shinx1265@gmail.com"]
|
9
9
|
spec.summary = "Amazon RDS for PostgreSQL log input plugin"
|
@@ -28,13 +28,6 @@ class Fluent::Plugin::RdsPgsqlLogInput < Fluent::Plugin::Input
|
|
28
28
|
raise Fluent::ConfigError.new("pos_file is required") unless @pos_file
|
29
29
|
raise Fluent::ConfigError.new("refresh_interval is required") unless @refresh_interval
|
30
30
|
raise Fluent::ConfigError.new("tag is required") unless @tag
|
31
|
-
end
|
32
|
-
|
33
|
-
def start
|
34
|
-
super
|
35
|
-
|
36
|
-
# pos file touch
|
37
|
-
File.open(@pos_file, File::RDWR|File::CREAT).close
|
38
31
|
|
39
32
|
begin
|
40
33
|
options = {
|
@@ -48,6 +41,13 @@ class Fluent::Plugin::RdsPgsqlLogInput < Fluent::Plugin::Input
|
|
48
41
|
rescue => e
|
49
42
|
log.warn "RDS Client error occurred: #{e.message}"
|
50
43
|
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def start
|
47
|
+
super
|
48
|
+
|
49
|
+
# pos file touch
|
50
|
+
File.open(@pos_file, File::RDWR|File::CREAT).close
|
51
51
|
|
52
52
|
timer_execute(:poll_logs, @refresh_interval, repeat: true, &method(:input))
|
53
53
|
end
|
@@ -190,7 +190,7 @@ class Fluent::Plugin::RdsPgsqlLogInput < Fluent::Plugin::Input
|
|
190
190
|
record["message"] << "\n" + raw_record unless record.nil?
|
191
191
|
else
|
192
192
|
# emit before record
|
193
|
-
router.emit(@tag,
|
193
|
+
router.emit(@tag, Time.parse(record["time"]), record) unless record.nil?
|
194
194
|
|
195
195
|
# set a record
|
196
196
|
record = {
|
@@ -206,7 +206,7 @@ class Fluent::Plugin::RdsPgsqlLogInput < Fluent::Plugin::Input
|
|
206
206
|
end
|
207
207
|
end
|
208
208
|
# emit last record
|
209
|
-
router.emit(@tag,
|
209
|
+
router.emit(@tag, Time.parse(record["time"]), record) unless record.nil?
|
210
210
|
rescue => e
|
211
211
|
log.warn e.message
|
212
212
|
end
|
@@ -10,7 +10,7 @@ class RdsPgsqlLogInputTest < Test::Unit::TestCase
|
|
10
10
|
secret_access_key: 'dummy_secret_access_key',
|
11
11
|
region: 'ap-northeast-1',
|
12
12
|
db_instance_identifier: 'test-postgres-id',
|
13
|
-
refresh_interval:
|
13
|
+
refresh_interval: 2,
|
14
14
|
pos_file: 'pgsql-log-pos.dat',
|
15
15
|
}
|
16
16
|
|
@@ -46,6 +46,40 @@ class RdsPgsqlLogInputTest < Test::Unit::TestCase
|
|
46
46
|
assert_equal 'ap-northeast-1', d.instance.region
|
47
47
|
assert_equal 'test-postgres-id', d.instance.db_instance_identifier
|
48
48
|
assert_equal 'pgsql-log-pos.dat', d.instance.pos_file
|
49
|
-
assert_equal
|
49
|
+
assert_equal 2, d.instance.refresh_interval
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_get_log_files
|
53
|
+
use_iam_role
|
54
|
+
d = create_driver
|
55
|
+
|
56
|
+
aws_client_stub = Aws::RDS::Client.new(stub_responses: {
|
57
|
+
describe_db_log_files: {
|
58
|
+
describe_db_log_files: [
|
59
|
+
{
|
60
|
+
log_file_name: 'db.log',
|
61
|
+
last_written: 123,
|
62
|
+
size: 123
|
63
|
+
}
|
64
|
+
],
|
65
|
+
marker: 'marker'
|
66
|
+
},
|
67
|
+
download_db_log_file_portion: {
|
68
|
+
log_file_data: "2019-01-26 22:10:20 UTC::@:[129155]:LOG:some db log",
|
69
|
+
marker: 'marker',
|
70
|
+
additional_data_pending: false
|
71
|
+
}
|
72
|
+
})
|
73
|
+
|
74
|
+
d.instance.instance_variable_set(:@rds, aws_client_stub)
|
75
|
+
|
76
|
+
d.run(timeout: 3, expect_emits: 1)
|
77
|
+
|
78
|
+
events = d.events
|
79
|
+
assert_equal(events[0][1].iso8601, "2019-01-26T22:10:20Z")
|
80
|
+
assert_equal(events[0][2]["pid"], '129155')
|
81
|
+
assert_equal(events[0][2]["message_level"], 'LOG')
|
82
|
+
assert_equal(events[0][2]["message"], 'some db log')
|
83
|
+
assert_equal(events[0][2]["log_file_name"], 'db.log')
|
50
84
|
end
|
51
85
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-rds-pgsql-log
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- shinsaka
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-01-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fluentd
|