Skip to content

Files

Latest commit

 

History

History
33 lines (30 loc) · 854 Bytes

postgres.md

File metadata and controls

33 lines (30 loc) · 854 Bytes

Example 1: Postgres

With thanks to @roflmao

input
{
	stdin { }
}
output {
	jdbc {
		connection_string => 'jdbc:postgresql://hostname:5432/database?user=username&password=password'
		statement => [ "INSERT INTO log (host, timestamp, message) VALUES(?, CAST (? AS timestamp), ?)", "host", "@timestamp", "message" ]
	}
}

Example 2: If the previous example doesn't work (i.e. connection errors)

Tested with https://jdbc.postgresql.org/download/postgresql-42.1.4.jre7.jar saved to /opt/logstash/vendor/jar/jdbc/

input
{
	stdin { }
}
output {
	jdbc {
		connection_string => 'jdbc:postgresql://hostname:5432/database'
		username => 'username'
		password => 'password'
		statement => [ "INSERT INTO log (host, timestamp, message) VALUES(?, CAST (? AS timestamp), ?)", "host", "@timestamp", "message" ]
	}
}