logstash-output-jdbc/examples/sql-server.md
Karl 6affac0a0c Update sql-server.md
Add a with thanks.
2017-04-12 12:35:56 +01:00

1.1 KiB

Example: SQL Server

input
{
	stdin { }
}
output {
	jdbc {
		driver_jar_path => '/opt/sqljdbc42.jar'
		connection_string => "jdbc:sqlserver://server:1433;databaseName=databasename;user=username;password=password"
		statement => [ "INSERT INTO log (host, timestamp, message) VALUES(?, ?, ?)", "host", "@timestamp", "message" ]
	}
	
}

Another example, with mixed static strings and parameters, with thanks to @MassimoSporchia

input
{
	stdin { }
}
output {
jdbc {
		driver_jar_path => '/opt/sqljdbc42.jar'
		connection_string => "jdbc:sqlserver://server:1433;databaseName=databasename;user=username;password=password"
		statement => [ "INSERT INTO log (host, timestamp, message, comment) VALUES(?, ?, ?, 'static string')", "host", "@timestamp", "message" ]
	}
}