fluent-plugin-postgresql-csvlog 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bb322f50f848a7b196962dae916a75f30a77f1461167bb314494ae203f8ef9d6
4
- data.tar.gz: 077266e6c7f3589813d0c4db8ddccfde76f7d6ecd0b6d6388b67a4e6328ad858
3
+ metadata.gz: 81cfb53854390b0aae43fd6f8cfaf05e11c4251a4442bf40ccdee016db11b3f6
4
+ data.tar.gz: 0e705c2af91af84e400e96d41b5275f0d01f4d6dc4ec0a37b3bfed0974e8a424
5
5
  SHA512:
6
- metadata.gz: 9b130aa84b1285a62466b3bf68ff6d02acc7e95cd53cc91ee7e34ec81ee4440e06358738790f86f8d436cb8a72ad232f12ac2c0f9d8aca16fd5c6ba19bbdfe49
7
- data.tar.gz: e9480110be0cadfad86c5fcc554eb5d1d7264559714e4fd88ea396ae9bb913027b15782c70cd2f4c06e1f4cc5a5bbafe55632ca8eba02ce57e610d98f8440c09
6
+ metadata.gz: 24bb505d30f06847e16b2f631e1e2ce011559edcc11724556d62abc0089ee99b00e5b911c1f23d87740720fd4d57235af1ee104991cbff72ac8ba790c700280a
7
+ data.tar.gz: d42ae8976276b4392c1963d6c83e7691732f7eec8dbf87eaf270e3b4547ceba8f9f2b76056006163d6b594e0791b4a9b49183c6ae1793610e7f6555a92b9d190
data/Dockerfile ADDED
@@ -0,0 +1,18 @@
1
+ # Dockerfile useful for manual testing purposes
2
+ FROM fluent/fluentd:v1.13-1
3
+ USER root
4
+ RUN apk add bash alpine-sdk postgresql-dev postgresql-client ruby-dev
5
+
6
+ WORKDIR /src/
7
+
8
+ ADD Gemfile /src/
9
+ ADD fluent-plugin-postgresql-csvlog.gemspec /src/
10
+
11
+ ADD . /src/
12
+
13
+ RUN bundle install
14
+ RUN rake build
15
+
16
+ RUN fluent-gem install pkg/*.gem
17
+
18
+ ENTRYPOINT [ "/bin/bash"]
@@ -0,0 +1,19 @@
1
+ # Docker Compose setup useful for testing and development purposes
2
+ version: "3.9"
3
+ services:
4
+ fluentd:
5
+ build: .
6
+ links:
7
+ - postgres
8
+ entrypoint: /usr/bin/fluentd -vvv -c /src/example-fluentd.conf
9
+ postgres:
10
+ image: postgres
11
+ restart: always
12
+ environment:
13
+ - POSTGRES_USER=testuser
14
+ - POSTGRES_PASSWORD=testpass
15
+ ports:
16
+ - '5438:5432'
17
+ command: postgres -c shared_preload_libraries=pg_stat_statements -c pg_stat_statements.track=all
18
+ volumes:
19
+ - ./sql/create_extension.sql:/docker-entrypoint-initdb.d/create_extension.sql
@@ -0,0 +1,12 @@
1
+ <source>
2
+ @type pg_stat_statements
3
+ tag postgres.pg_stat_statements
4
+ host postgres
5
+ username testuser
6
+ password testpass
7
+ interval 1
8
+ </source>
9
+
10
+ <match postgres.pg_stat_statements>
11
+ @type stdout
12
+ </match>
@@ -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.3.0'
5
+ s.version = '0.3.1'
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'
@@ -1,10 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'fluent/input'
3
+ require 'fluent/plugin/input'
4
4
  require 'pg'
5
5
  require 'pg_query'
6
6
 
7
- module Fluent
7
+ module Fluent::Plugin
8
8
  # PgStatStatementsInput will periodically poll postgres, querying pg_stat_statements
9
9
  # for queryid to query mappings. These are then normalized for security purposes
10
10
  # fingerprinted and emitted as records with the following format:
@@ -101,9 +101,9 @@ module Fluent
101
101
 
102
102
  # Query the database and emit statements to fluentd router
103
103
  def emit_statements_to_stream(conn)
104
- me = MultiEventStream.new
104
+ me = Fluent::MultiEventStream.new
105
105
 
106
- now = Engine.now
106
+ now = Fluent::Engine.now
107
107
  conn.exec('SELECT queryid, query FROM pg_stat_statements').each do |row|
108
108
  record = record_for_row(row)
109
109
  me.add(now, record)
@@ -0,0 +1 @@
1
+ CREATE EXTENSION pg_stat_statements;
data/test/helper.rb CHANGED
@@ -16,4 +16,4 @@ Test::Unit::TestCase.extend(Fluent::Test::Helpers)
16
16
  require 'fluent/plugin/filter_postgresql_slowlog'
17
17
  require 'fluent/plugin/filter_postgresql_redactor'
18
18
  require 'fluent/plugin/filter_marginalia'
19
- require 'fluent/plugin/input_pg_stat_statements'
19
+ require 'fluent/plugin/in_pg_stat_statements'
@@ -3,10 +3,11 @@
3
3
  require_relative '../helper'
4
4
 
5
5
  class PgStatStatementsInputIntegrationTest < Test::Unit::TestCase
6
- # These items are configured in .gitlab-ci.yml on the postgres service
7
- HOST = 'postgres'
8
- USERNAME = 'testuser'
9
- PASSWORD = 'testpass'
6
+ # The defaults values work with the configuration in .gitlab-ci.yml on the postgres service
7
+ # Override with env vars for local development
8
+ HOST = ENV.fetch('PG_TEST_HOST', 'postgres')
9
+ USERNAME = ENV.fetch('PG_TEST_USER', 'testuser')
10
+ PASSWORD = ENV.fetch('PG_TEST_PASSWORD', 'testpass')
10
11
 
11
12
  def setup
12
13
  Fluent::Test.setup
@@ -53,7 +54,7 @@ class PgStatStatementsInputIntegrationTest < Test::Unit::TestCase
53
54
  )
54
55
 
55
56
  def create_driver(config)
56
- Fluent::Test::InputTestDriver.new(Fluent::PgStatStatementsInput).configure(config)
57
+ Fluent::Test::InputTestDriver.new(Fluent::Plugin::PgStatStatementsInput).configure(config)
57
58
  end
58
59
 
59
60
  sub_test_case 'configuration' do
@@ -20,7 +20,7 @@ class PgStatStatementsInputTest < Test::Unit::TestCase
20
20
  )
21
21
 
22
22
  def create_driver
23
- Fluent::Test::InputTestDriver.new(Fluent::PgStatStatementsInput).configure(CONFIG)
23
+ Fluent::Test::InputTestDriver.new(Fluent::Plugin::PgStatStatementsInput).configure(CONFIG)
24
24
  end
25
25
 
26
26
  sub_test_case 'configuration' do
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.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - stanhu
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-06-24 00:00:00.000000000 Z
11
+ date: 2021-06-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fluentd
@@ -94,22 +94,26 @@ extensions: []
94
94
  extra_rdoc_files: []
95
95
  files:
96
96
  - ".gitlab-ci.yml"
97
+ - Dockerfile
97
98
  - Gemfile
98
99
  - LICENSE
99
100
  - README.md
100
101
  - Rakefile
102
+ - docker-compose.yml
103
+ - example-fluentd.conf
101
104
  - fluent-plugin-postgresql-csvlog.gemspec
102
105
  - lib/fluent/plugin/filter_marginalia.rb
103
106
  - lib/fluent/plugin/filter_postgresql_redactor.rb
104
107
  - lib/fluent/plugin/filter_postgresql_slowlog.rb
105
- - lib/fluent/plugin/input_pg_stat_statements.rb
108
+ - lib/fluent/plugin/in_pg_stat_statements.rb
106
109
  - lib/fluent/plugin/parser_multiline_csv.rb
110
+ - sql/create_extension.sql
107
111
  - test/helper.rb
108
- - test/plugin/itest_input_pg_stat_statements.rb
112
+ - test/plugin/itest_in_pg_stat_statements.rb
109
113
  - test/plugin/test_filter_marginalia.rb
110
114
  - test/plugin/test_filter_postgresql_redactor.rb
111
115
  - test/plugin/test_filter_postgresql_slowlog.rb
112
- - test/plugin/test_input_pg_stat_statements.rb
116
+ - test/plugin/test_in_pg_stat_statements.rb
113
117
  homepage: https://gitlab.com/gitlab-org/fluent-plugins/fluent-plugin-postgresql-csvlog
114
118
  licenses: []
115
119
  metadata: {}
@@ -134,8 +138,8 @@ specification_version: 4
134
138
  summary: fluentd plugins to work with PostgreSQL CSV logs
135
139
  test_files:
136
140
  - test/helper.rb
137
- - test/plugin/itest_input_pg_stat_statements.rb
141
+ - test/plugin/itest_in_pg_stat_statements.rb
138
142
  - test/plugin/test_filter_marginalia.rb
139
143
  - test/plugin/test_filter_postgresql_redactor.rb
140
144
  - test/plugin/test_filter_postgresql_slowlog.rb
141
- - test/plugin/test_input_pg_stat_statements.rb
145
+ - test/plugin/test_in_pg_stat_statements.rb