Steps to Install & Configure SQL Server with Logstash
Steps:
- Download the Logstash and extract the ZIP. ( i.e https://artifacts.elastic.co/downloads/logstash/logstash-7.4.1.zip (or ) https://www.elastic.co/downloads/logstash ). Right now i’m using 7.4.1v.
2. Download the JAVA 8 and above version. we need JDK version not JAVA run time. Download the JDK >=8 from following link:
3. Install the JAVA And Set the Environment variable like below: Go to -> Control Panel -> System -> Advanced system settings ->Then click on Advanced Tab like below -> Environment Variables like below:
Set the java JRE address path in path variable like below.
JAVA installation JRE path: C:\Program Files\Java\jdk1.8.0_231\jre\bin
Check the Java version like below:
4. Download Microsoft JDBC Driver for SQL Server from following link :
https://www.microsoft.com/en-us/download/details.aspx?id=58505
I’m using Microsoft JDBC Driver 7.4 for SQL Server.
5. Extract Zip of Microsoft JDBC Driver and navigate to below path:
....\Downloads\Microsoft JDBC Driver 7.4 for SQL Server\sqljdbc_7.4\enu\
Based on your java JDK installation version select mssql-jdbc-7.4.1.jre8 JRE file. (i.e I installed JAVA 8)
6. Copy mssql-jdbc-7.4.1.jre8 JRE file and paste in below path :
....\logstash-7.4.1\logstash-7.4.1\logstash-core\lib\jars\
7. Prepare the logstash config file and Execute the config file by using below command using CMD.
we need to navigate the logstash bin folder path(i.e. Instead of navigating every time we can set the bin path as Environment Variable also) like below steps:
- open CMD type (i.e. Logstash bin location)
cd C:\Users\Ramanareddy.v\Desktop\logstash-7.4.1\logstash-7.4.1\bin
- Then After type logstash -f “ your config file location “
logstash -f C:\Users\Ramanareddy\Desktop\logstashconfig\test.config
FOR EXAMPLE:
Simple SQL database connection with logstash .config file.
input {
jdbc {
# jdbc_driver_library => If you place ur mssql-jdbc-7.4.1.jre8 JRE file in logstash ..\logstash-core\lib\jars\ no need to give mssql JRE file path..
jdbc_driver_class => "com.microsoft.sqlserver.jdbc.SQLServerDriver"
jdbc_connection_string => "jdbc:mysql://localhost:3306/mydb" # your sql conncetionstring with database name
jdbc_user => "SQL USER NAME"
jdbc_password => "Password"
statement => " SELECT * FROM dbo.Employee " # Simple Query or Stored procedure
}
}
output
{
stdout { codec => json_lines }
}
for more information please refer below link :
NOTE:
I did above setup in my windows 10 PC only 😃.
========== Happy Coding ==========