Hi all,
I am using following configuration in logstash:
input {
jdbc {
jdbc_driver_library => "F:\driver\sqljdbc_6.0\enu\jre8\sqljdbc42.jar"
jdbc_driver_class => "com.microsoft.sqlserver.jdbc.SQLServerDriver"
jdbc_connection_string => "jdbc:sqlserver://local:3333;databaseName=Total"
jdbc_user => "***"
jdbc_password => "***"
schedule => "0 10-23/1 * * *"
statement => "
DECLARE @DDate1 CHAR(10)
select @DDate1=REPLACE(MAX(Date),'/','') from Total.dbo.Total_Control
select [BaseDate_Accept_Setel]
,[Financial_Date]
from dbo.vw_Total where (BaseDate_Accept_Setel=@DDate1) AND (BaseDate_Accept_Setel> :sql_last_value)
"
use_column_value => "true"
tracking_column => "basedate_accept_setel"
}
}
filter {
jdbc_streaming {
jdbc_driver_library => "F:\driver\sqljdbc_6.0\enu\jre8\sqljdbc42.jar"
jdbc_driver_class => "com.microsoft.sqlserver.jdbc.SQLServerDriver"
jdbc_connection_string => "jdbc:sqlserver://local:3333;databaseName=Total"
jdbc_user => "***"
jdbc_password => "***"
parameters => {"mine" => "BaseDate_Accept_Setel"}
statement => "
DECLARE @ddate2 CHAR(10)
set @ddate2=:mine
SELECT Total_OnLine.dbo.d2md(@ddate2) as gdate"
target => "gdate"
}
mutate { replace => { "gdate" => "%{[gdate][0][gdate]}" } }
mutate { gsub => [ "gdate", "/", "-" ] }
}
output {
elasticsearch {
hosts => ["http://192.168.170.153:9200"]
index => "a2_%{gdate}"
user => "logstash_internal25"
password => "x-pack-test-password"
}
stdout { codec => rubydebug }
}
now, I want to load an index as "disp_%{gdate}" , how can i add this? i found that we can load elasticsearch indices in input part as following:
input {
elasticsearch {
hosts => "http://192.168.170.153:9200"
index => "disp-*"
}
}
but I want to load the index of date %{gdate}, how can i do it? the problem is that "gdate" is defined in filter part and i want to use it in input part, is it possible? many thanks.