Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
47fdf7d442 | ||
|
|
ffb2f700be | ||
|
|
f52c14b79a | ||
|
|
f46fd58048 |
@@ -1,6 +1,13 @@
|
|||||||
# Change Log
|
# Change Log
|
||||||
All notable changes to this project will be documented in this file, from 0.2.0.
|
All notable changes to this project will be documented in this file, from 0.2.0.
|
||||||
|
|
||||||
|
## [0.3.2] - 2016-09-15
|
||||||
|
- Adds long/bigint support to address https://github.com/theangryangel/logstash-output-jdbc/issues/61
|
||||||
|
|
||||||
|
## [0.3.1] - 2016-08-28
|
||||||
|
- Adds connection_test configuration option, to prevent the connection test from occuring, allowing the error to be suppressed.
|
||||||
|
Useful for cockroachdb deployments. https://github.com/theangryangel/logstash-output-jdbc/issues/53
|
||||||
|
|
||||||
## [0.3.0] - 2016-07-24
|
## [0.3.0] - 2016-07-24
|
||||||
- Brings tests from v5 branch, providing greater coverage
|
- Brings tests from v5 branch, providing greater coverage
|
||||||
- Removes bulk update support, due to inconsistent behaviour
|
- Removes bulk update support, due to inconsistent behaviour
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# logstash-output-jdbc
|
# logstash-output-jdbc
|
||||||
|
|
||||||
[](https://travis-ci.org/theangryangel/logstash-output-jdbc)
|
[](https://travis-ci.org/theangryangel/logstash-output-jdbc)
|
||||||
|
|
||||||
This plugin is provided as an external plugin and is not part of the Logstash project.
|
This plugin is provided as an external plugin and is not part of the Logstash project.
|
||||||
|
|
||||||
@@ -43,6 +43,7 @@ For development:
|
|||||||
| driver_auto_commit | Boolean | If the driver does not support auto commit, you should set this to false | No | True |
|
| driver_auto_commit | Boolean | If the driver does not support auto commit, you should set this to false | No | True |
|
||||||
| driver_jar_path | String | File path to jar file containing your JDBC driver. This is optional, and all JDBC jars may be placed in $LOGSTASH_HOME/vendor/jar/jdbc instead. | No | |
|
| driver_jar_path | String | File path to jar file containing your JDBC driver. This is optional, and all JDBC jars may be placed in $LOGSTASH_HOME/vendor/jar/jdbc instead. | No | |
|
||||||
| connection_string | String | JDBC connection URL | Yes | |
|
| connection_string | String | JDBC connection URL | Yes | |
|
||||||
|
| connection_test | Boolean | Run a JDBC connection test. Some drivers do not function correctly, and you may need to disable the connection test to supress an error. Cockroach with the postgres JDBC driver is such an example. | No | Yes |
|
||||||
| username | String | JDBC username - this is optional as it may be included in the connection string, for many drivers | No | |
|
| username | String | JDBC username - this is optional as it may be included in the connection string, for many drivers | No | |
|
||||||
| password | String | JDBC password - this is optional as it may be included in the connection string, for many drivers | No | |
|
| password | String | JDBC password - this is optional as it may be included in the connection string, for many drivers | No | |
|
||||||
| statement | Array | An array of strings representing the SQL statement to run. Index 0 is the SQL statement that is prepared, all other array entries are passed in as parameters (in order). A parameter may either be a property of the event (i.e. "@timestamp", or "host") or a formatted string (i.e. "%{host} - %{message}" or "%{message}"). If a key is passed then it will be automatically converted as required for insertion into SQL. If it's a formatted string then it will be passed in verbatim. | Yes | |
|
| statement | Array | An array of strings representing the SQL statement to run. Index 0 is the SQL statement that is prepared, all other array entries are passed in as parameters (in order). A parameter may either be a property of the event (i.e. "@timestamp", or "host") or a formatted string (i.e. "%{host} - %{message}" or "%{message}"). If a key is passed then it will be automatically converted as required for insertion into SQL. If it's a formatted string then it will be passed in verbatim. | Yes | |
|
||||||
|
|||||||
@@ -83,6 +83,9 @@ class LogStash::Outputs::Jdbc < LogStash::Outputs::Base
|
|||||||
# Suitable for configuring retryable custom JDBC SQL state codes.
|
# Suitable for configuring retryable custom JDBC SQL state codes.
|
||||||
config :retry_sql_states, validate: :array, default: []
|
config :retry_sql_states, validate: :array, default: []
|
||||||
|
|
||||||
|
# Run a connection test on start.
|
||||||
|
config :connection_test, validate: :boolean, default: true
|
||||||
|
|
||||||
# Maximum number of sequential failed attempts, before we stop retrying.
|
# Maximum number of sequential failed attempts, before we stop retrying.
|
||||||
# If set to < 1, then it will infinitely retry.
|
# If set to < 1, then it will infinitely retry.
|
||||||
# At the default values this is a little over 10 minutes
|
# At the default values this is a little over 10 minutes
|
||||||
@@ -148,10 +151,12 @@ class LogStash::Outputs::Jdbc < LogStash::Outputs::Base
|
|||||||
|
|
||||||
validate_connection_timeout = (@connection_timeout / 1000) / 2
|
validate_connection_timeout = (@connection_timeout / 1000) / 2
|
||||||
|
|
||||||
|
return unless @connection_test
|
||||||
|
|
||||||
# Test connection
|
# Test connection
|
||||||
test_connection = @pool.getConnection
|
test_connection = @pool.getConnection
|
||||||
unless test_connection.isValid(validate_connection_timeout)
|
unless test_connection.isValid(validate_connection_timeout)
|
||||||
@logger.error('JDBC - Connection is not valid. Please check connection string or that your JDBC endpoint is available.')
|
@logger.error('JDBC - Connection is not reporting as validate. Either connection is invalid, or driver is not getting the appropriate response.')
|
||||||
end
|
end
|
||||||
test_connection.close
|
test_connection.close
|
||||||
end
|
end
|
||||||
@@ -275,7 +280,13 @@ class LogStash::Outputs::Jdbc < LogStash::Outputs::Base
|
|||||||
# strftime appears to be the most reliable across drivers.
|
# strftime appears to be the most reliable across drivers.
|
||||||
statement.setString(idx + 1, value.time.strftime(STRFTIME_FMT))
|
statement.setString(idx + 1, value.time.strftime(STRFTIME_FMT))
|
||||||
when Fixnum, Integer
|
when Fixnum, Integer
|
||||||
|
# bit_length doesn't exist in the current version of ruby/jruby logstash targets
|
||||||
|
# and this seems quicker than doing some Math.log2(value < 0 ? -value : value+1).ceil shit
|
||||||
|
if value > 2147483647 or value < -2147483648
|
||||||
|
statement.setLong(idx + 1, value)
|
||||||
|
else
|
||||||
statement.setInt(idx + 1, value)
|
statement.setInt(idx + 1, value)
|
||||||
|
end
|
||||||
when Float
|
when Float
|
||||||
statement.setFloat(idx + 1, value)
|
statement.setFloat(idx + 1, value)
|
||||||
when String
|
when String
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
Gem::Specification.new do |s|
|
Gem::Specification.new do |s|
|
||||||
s.name = 'logstash-output-jdbc'
|
s.name = 'logstash-output-jdbc'
|
||||||
s.version = "0.3.0"
|
s.version = "0.3.2"
|
||||||
s.licenses = [ "Apache License (2.0)" ]
|
s.licenses = [ "Apache License (2.0)" ]
|
||||||
s.summary = "This plugin allows you to output to SQL, via JDBC"
|
s.summary = "This plugin allows you to output to SQL, via JDBC"
|
||||||
s.description = "This gem is a logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/plugin install gemname. This gem is not a stand-alone program"
|
s.description = "This gem is a logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/plugin install gemname. This gem is not a stand-alone program"
|
||||||
@@ -34,5 +34,5 @@ Gem::Specification.new do |s|
|
|||||||
|
|
||||||
s.add_development_dependency 'logstash-devutils'
|
s.add_development_dependency 'logstash-devutils'
|
||||||
|
|
||||||
s.add_development_dependency 'rubocop'
|
s.add_development_dependency 'rubocop', '0.41.2'
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -31,11 +31,11 @@ RSpec.shared_context 'when outputting messages' do
|
|||||||
end
|
end
|
||||||
|
|
||||||
let(:jdbc_create_table) do
|
let(:jdbc_create_table) do
|
||||||
"CREATE table #{jdbc_test_table} (created_at datetime not null, message varchar(512) not null, message_sprintf varchar(512) not null, static_int int not null, static_bit bit not null)"
|
"CREATE table #{jdbc_test_table} (created_at datetime not null, message varchar(512) not null, message_sprintf varchar(512) not null, static_int int not null, static_bit bit not null, static_bigint bigint not null)"
|
||||||
end
|
end
|
||||||
|
|
||||||
let(:jdbc_statement) do
|
let(:jdbc_statement) do
|
||||||
["insert into #{jdbc_test_table} (created_at, message, message_sprintf, static_int, static_bit) values(?, ?, ?, ?, ?)", '@timestamp', 'message', 'sprintf-%{message}', 1, true]
|
["insert into #{jdbc_test_table} (created_at, message, message_sprintf, static_int, static_bit, static_bigint) values(?, ?, ?, ?, ?, ?)", '@timestamp', 'message', 'sprintf-%{message}', 1, true, 4000881632477184]
|
||||||
end
|
end
|
||||||
|
|
||||||
let(:systemd_database_service) do
|
let(:systemd_database_service) do
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ describe 'logstash-output-jdbc: derby', if: ENV['JDBC_DERBY_JAR'] do
|
|||||||
end
|
end
|
||||||
|
|
||||||
let(:jdbc_create_table) do
|
let(:jdbc_create_table) do
|
||||||
"CREATE table #{jdbc_test_table} (created_at timestamp not null, message varchar(512) not null, message_sprintf varchar(512) not null, static_int int not null, static_bit boolean not null)"
|
"CREATE table #{jdbc_test_table} (created_at timestamp not null, message varchar(512) not null, message_sprintf varchar(512) not null, static_int int not null, static_bit boolean not null, static_bigint bigint not null)"
|
||||||
end
|
end
|
||||||
|
|
||||||
let(:jdbc_settings) do
|
let(:jdbc_settings) do
|
||||||
|
|||||||
Reference in New Issue
Block a user