fluent-plugin-timescaledb 1.0.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.
@@ -0,0 +1,38 @@
1
+ require 'fluent/plugin/output'
2
+ require 'pg'
3
+
4
+ module Fluent
5
+ module Plugin
6
+ class TimescaleDB < Output
7
+ Fluent::Plugin.register_output('timescaledb', self)
8
+
9
+ config_param :db_conn_string, :string, secret: true
10
+ config_param :db_table_name, :string, default: 'log_records'
11
+
12
+ def start
13
+ super
14
+
15
+ @conn = PG.connect(@db_conn_string)
16
+ @conn.prepare('insert_record', "INSERT INTO \"#{@db_table_name}\" (time, tag, record) VALUES ($1, $2, $3::jsonb)")
17
+ end
18
+
19
+ def close
20
+ @conn.close if @conn
21
+ end
22
+
23
+ def write(chunk)
24
+ chunk.msgpack_each do | tag, time, record |
25
+ @conn.exec_prepared('insert_record', [Time.at(time.to_f), tag, record.to_json])
26
+ end
27
+ end
28
+
29
+ def format(tag, time, record)
30
+ [tag, time, record].to_msgpack
31
+ end
32
+
33
+ def formatted_to_msgpack_binary
34
+ true
35
+ end
36
+ end
37
+ end
38
+ end
metadata ADDED
@@ -0,0 +1,62 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fluent-plugin-timescaledb
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Chris Northwood
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2019-04-14 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: pg
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '1.1'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '1.1'
30
+ description: Write Fluent logs to TimescaleDB
31
+ email: chris.northwood@1500cloud.com
32
+ executables: []
33
+ extensions: []
34
+ extra_rdoc_files: []
35
+ files:
36
+ - lib/fluent/plugin/out_timescaledb.rb
37
+ homepage: https://github.com/1500cloud/fluent-plugin-timescaledb
38
+ licenses:
39
+ - Apache-2.0
40
+ post_install_message:
41
+ rdoc_options: []
42
+ require_paths:
43
+ - lib
44
+ required_ruby_version: !ruby/object:Gem::Requirement
45
+ none: false
46
+ requirements:
47
+ - - ! '>='
48
+ - !ruby/object:Gem::Version
49
+ version: '0'
50
+ required_rubygems_version: !ruby/object:Gem::Requirement
51
+ none: false
52
+ requirements:
53
+ - - ! '>='
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ requirements: []
57
+ rubyforge_project:
58
+ rubygems_version: 1.8.24
59
+ signing_key:
60
+ specification_version: 3
61
+ summary: Write Fluent logs to TimescaleDB
62
+ test_files: []