fluent-plugin-postgresql-csvlog 0.5.0 → 0.6.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/example-fluentd.conf +16 -0
- data/fluent-plugin-postgresql-csvlog.gemspec +1 -1
- data/lib/fluent/plugin/in_pg_stat_statements.rb +2 -2
- data/test/plugin/itest_in_pg_stat_statements.rb +3 -3
- data/test/plugin/test_in_pg_stat_statements.rb +3 -3
- data/test/verify-docker-compose.sh +8 -2
- 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: e36a1382a11ed800637467180b1af1a28b16f1125ecd5bf2c5b7dd0b4c708223
|
4
|
+
data.tar.gz: 36f9ea068ffd9674c7a0450feffd3ff7344774a88e63fb8934e3871155ca40a6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e5fe1bd18ada66464c1c6fa57d3cf31f389aa6831e248095d63e2c6d30b737dd363ce72dcf7b80baf771e93921bada05c7d26267969ab161f862d0dc35cc0e57
|
7
|
+
data.tar.gz: bff45c6bf1911f8106b4dd36248df2b14bd8c8d08f1d3214b95d5930c85c385ccfd1ecd23d2d712df8e044c49f5bad4e543f1b18f4de7ab81ecdd0d9001f831c
|
data/example-fluentd.conf
CHANGED
@@ -13,6 +13,10 @@
|
|
13
13
|
time_slice_format %Y%m%d%H%M%S
|
14
14
|
flush_interval 1s
|
15
15
|
utc
|
16
|
+
|
17
|
+
<format>
|
18
|
+
@type json
|
19
|
+
</format>
|
16
20
|
</match>
|
17
21
|
|
18
22
|
<source>
|
@@ -23,3 +27,15 @@
|
|
23
27
|
password testpass
|
24
28
|
interval 1
|
25
29
|
</source>
|
30
|
+
|
31
|
+
<match postgres.pg_stat_activity>
|
32
|
+
@type file
|
33
|
+
path /var/log/pg/pg_stat_activity
|
34
|
+
time_slice_format %Y%m%d%H%M%S
|
35
|
+
flush_interval 1s
|
36
|
+
utc
|
37
|
+
<format>
|
38
|
+
@type json
|
39
|
+
</format>
|
40
|
+
</match>
|
41
|
+
|
@@ -2,7 +2,7 @@ $:.push File.expand_path('lib', __dir__)
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = 'fluent-plugin-postgresql-csvlog'
|
5
|
-
s.version = '0.
|
5
|
+
s.version = '0.6.0'
|
6
6
|
s.authors = ['stanhu']
|
7
7
|
s.email = ['stanhu@gmail.com']
|
8
8
|
s.homepage = 'https://gitlab.com/gitlab-org/fluent-plugins/fluent-plugin-postgresql-csvlog'
|
@@ -11,7 +11,7 @@ module Fluent::Plugin
|
|
11
11
|
# 'fingerprint' => '8a6e9896bd9048a2',
|
12
12
|
# 'query' => 'SELECT * FROM table ORDER BY queryid LIMIT $1',
|
13
13
|
# 'query_length' => 58,
|
14
|
-
# 'queryid' => 3239318621761098074
|
14
|
+
# 'queryid' => '3239318621761098074'
|
15
15
|
# }
|
16
16
|
class PgStatStatementsInput < PollingPostgresInputPlugin
|
17
17
|
Fluent::Plugin.register_input('pg_stat_statements', self)
|
@@ -35,7 +35,7 @@ module Fluent::Plugin
|
|
35
35
|
|
36
36
|
# We record the query_length as it will help in understanding whether unparseable
|
37
37
|
# queries are truncated.
|
38
|
-
record = { 'queryid' => row['queryid'], 'query_length' => query&.length }
|
38
|
+
record = { 'queryid' => row['queryid'].to_s, 'query_length' => query&.length }
|
39
39
|
|
40
40
|
return record unless query
|
41
41
|
|
@@ -98,8 +98,7 @@ class PgStatStatementsInputIntegrationTest < Test::Unit::TestCase
|
|
98
98
|
expected_record = {
|
99
99
|
'fingerprint' => '8a6e9896bd9048a2',
|
100
100
|
'query' => 'SELECT * FROM pg_stat_statements ORDER BY queryid LIMIT $1',
|
101
|
-
'query_length' => 58
|
102
|
-
'queryid' => 3_239_318_621_761_098_074
|
101
|
+
'query_length' => 58
|
103
102
|
}
|
104
103
|
known_statement_event = emits.find do |event|
|
105
104
|
record = event[2]
|
@@ -114,7 +113,8 @@ class PgStatStatementsInputIntegrationTest < Test::Unit::TestCase
|
|
114
113
|
assert_equal 'postgres.pg_stat_statements', tag
|
115
114
|
assert_equal expected_record['fingerprint'], record['fingerprint']
|
116
115
|
assert_equal expected_record['query_length'], record['query_length']
|
117
|
-
assert_true
|
116
|
+
assert_true record.include? 'queryid'
|
117
|
+
assert_true record['queryid'].is_a? String
|
118
118
|
end
|
119
119
|
end
|
120
120
|
end
|
@@ -75,7 +75,7 @@ class PgStatStatementsInputTest < Test::Unit::TestCase
|
|
75
75
|
)
|
76
76
|
SQL
|
77
77
|
|
78
|
-
record = d.instance.record_for_row({ 'queryid' =>
|
78
|
+
record = d.instance.record_for_row({ 'queryid' => 1234, 'query' => ddl_sql })
|
79
79
|
|
80
80
|
expected = {
|
81
81
|
'fingerprint' => 'fa9c9d26757c4f9b',
|
@@ -88,7 +88,7 @@ class PgStatStatementsInputTest < Test::Unit::TestCase
|
|
88
88
|
|
89
89
|
test 'set command' do
|
90
90
|
d = create_driver
|
91
|
-
record = d.instance.record_for_row({ 'queryid' =>
|
91
|
+
record = d.instance.record_for_row({ 'queryid' => 1234, 'query' => "SET TIME ZONE 'PST8PDT'" })
|
92
92
|
|
93
93
|
expected = {
|
94
94
|
'fingerprint' => '23f8d6eb1d3125c3',
|
@@ -102,7 +102,7 @@ class PgStatStatementsInputTest < Test::Unit::TestCase
|
|
102
102
|
|
103
103
|
test 'unparseable sql' do
|
104
104
|
d = create_driver
|
105
|
-
record = d.instance.record_for_row({ 'queryid' =>
|
105
|
+
record = d.instance.record_for_row({ 'queryid' => 1234, 'query' => 'SELECT * FROM' })
|
106
106
|
|
107
107
|
expected = { 'query_length' => 13, 'query_unparseable' => true, 'queryid' => '1234' }
|
108
108
|
assert_equal expected, record
|
@@ -5,7 +5,8 @@
|
|
5
5
|
|
6
6
|
cleanup() {
|
7
7
|
echo "# removing all logs"
|
8
|
-
rm -rf /var/log/pg
|
8
|
+
rm -rf /var/log/pg/pg_stat_statements.*.log
|
9
|
+
rm -rf /var/log/pg/pg_stat_activity.*.log
|
9
10
|
}
|
10
11
|
|
11
12
|
die() {
|
@@ -17,6 +18,11 @@ die() {
|
|
17
18
|
cleanup
|
18
19
|
echo "# sleeping 10, awaiting logs"
|
19
20
|
sleep 10;
|
20
|
-
|
21
|
+
|
22
|
+
(find /var/log/pg/ -name "pg_stat_statements.*.log" | grep .) || die "No pg_stat_statements files created"
|
23
|
+
cat /var/log/pg/pg_stat_statements.*.log | tail -1
|
24
|
+
|
25
|
+
(find /var/log/pg/ -name "pg_stat_activity.*.log" | grep .) || die "No pg_stat_activity files created"
|
26
|
+
cat /var/log/pg/pg_stat_activity.*.log | tail -1
|
21
27
|
|
22
28
|
cleanup
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-postgresql-csvlog
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- stanhu
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-07-
|
11
|
+
date: 2021-07-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fluentd
|