Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MSSQL - database name taken from parameter adds N'' making query invalid #333

Open
PiotrBB opened this issue Apr 15, 2019 · 1 comment
Open

Comments

@PiotrBB
Copy link

PiotrBB commented Apr 15, 2019

Hello,

Here's my logstash config file:

input {
jdbc {
parameters => {
database => ABC
}
jdbc_driver_library => "/usr/share/logstash/lib/drivers/sqljdbc42.jar"
jdbc_driver_class => "com.microsoft.sqlserver.jdbc.SQLServerDriver"
jdbc_connection_string => "server:1433"
jdbc_user => "login"
jdbc_password => "pwd"
schedule => "*/1 * * * *"
statement_filepath => "/etc/logstash/conf.d/query.sql"
use_column_value => true
tracking_column_type => "numeric"
tracking_column => "id"
last_run_metadata_path => "/usr/share/logstash/last_run_metadata/.query"
record_last_run => true
}
}

The query looks like this:
select * from :database.dbo.table

Logstash is unable to retrieve any result, due to an error with the query. In the log i can see that's it's trying to execute the following:

select * from N'ABC'.dbo.table

Is there a way to get rid of N'' when parameter is used for database name?

@guyboertje
Copy link
Contributor

Sequel is trying to provide an appropriate datatype for the substitution because it expects that substitutions are done in WHERE clauses, i.e. dynamic values.

A solution for your dynamic needs might be to use ENV variables in the statement_filepath => "/etc/logstash/conf.d/query.sql" setting.

statement_filepath => "/etc/logstash/conf.d/$DB-query.sql" and $DB -> "ABC"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants