Fluentd - Server name not found in configuration files - TinyIds
harsh288 opened this issue · 14 comments
I'm using fluentd and the plugin that I'm using is fluent-plugin-sql & activerecord-sqlserver-adapter when I have the host as "HOSTNAME/SQLSERVERINSTANCE" it gives an error "TinyTDS: Server name not found in configuration files", however when I just keep the HOSTNAME without "/" it works, this actually an issue in ruby on rails, there is the workaround I have seen like to use dataserver instead of the host but it is not working in fluentd using the plugin fluent-plugin-sql
<source>
@type sql
host HOSTNAME/SQLSERVERINSTANCE
database db_name
adapter sqlserver
username user
password pwd
<table>
table tbl_name
update_column insert_timestamp
</table>
</source>
<match **>
@type stdout
</match>
Hmm, if dataserver HOSTNAME/SQLSERVERINSTANCE
is supported as configuration parameter, does it solve this situation?
@kenhys It solves in activerecord-sqlserver-adapter however not in fluent-plugin-sql as it does not understand the keyword dataserver, which may be because that is not the accepted parameter.
Hmm, what "not in fluent-plugin-sql" mean?
Even though dataserver
parameter is supported, will it not resolved at all?
diff --git a/lib/fluent/plugin/in_sql.rb b/lib/fluent/plugin/in_sql.rb
index babec57..36ac9b9 100644
--- a/lib/fluent/plugin/in_sql.rb
+++ b/lib/fluent/plugin/in_sql.rb
@@ -41,6 +41,8 @@ module Fluent::Plugin
config_param :socket, :string, default: nil
desc 'PostgreSQL schema search path'
config_param :schema_search_path, :string, default: nil
+ desc 'SQLServer dataserver (HOST\INSTANCENAME)'
+ config_param :dataserver, :string, default: nil
desc 'path to a file to store last rows'
config_param :state_file, :string, default: nil
@@ -192,6 +194,7 @@ module Fluent::Plugin
socket: @socket,
schema_search_path: @schema_search_path,
}
+ config[:dataserver] = @dataserver if @dataserver
# creates subclass of ActiveRecord::Base so that it can have different
# database configuration from ActiveRecord::Base.
I don't see the same code in location https://github.com/fluent/fluent-plugin-sql/blob/master/lib/fluent/plugin/in_sql.rb
Yes, as the above code is PoC code.
If it works, it may have a value to make it as a PR.
Could you please help me with how to test that ?? I will test and let you know, so then we can make a PR.
Also, the hostname is mandatory so if dataserver is passed as a parameter then hostname should not be mandatory.
Apply patch and modify your configuration.
Something like this:
<source>
@type sql
host HOSTNAME
database db_name
adapter sqlserver
dataserver HOSTNAME/SQLSERVERINSTANCE
...
</source>
You mentioned patch, so I believe this is the location "C:\opt\td-agent\lib\ruby\gems\2.7.0\gems\fluent-plugin-sql-2.2.0\lib\fluent\plugin\in_sql.rb", I have just edited and made changes as per your suggestion, that is the only thing I need to do, no compilation or creating package ?? I tried with the below configuration where the "host" is mandatory and if I remove the "host" it gives the below error, and if I keep host then it takes host value and it tries to connect over there ignoring dataserver
<source>
@type sql
host HOSTNAME
database db_name
adapter sqlserver
dataserver HOSTNAME/SQLSERVERINSTANCE
...
</source>
If I exclude "host"
In case if I keep blank "host" then
Thanks for testing!
I have just edited and made changes as per your suggestion, that is the only thing I need to do, no compilation or creating package ??
Yes. It is what I mean. modifying it is enough.
if I keep host then it takes host value and it tries to connect over there ignoring dataserver
Hmm, I guess specifying both of host and dataserver parameters are harmless. but it might not be true for this case.