How to print the logs of logstash execution?


(Gaurav Varma) #1

Is there a way we can print logstash execution output to a log file? For
example, I am using a jdbc plugin to read data as per sql_last_start. I
want to know at what time the query was executed, how many records in
response and what time was the next execution.

Assuming a table test has columns [id,name,updated_on]
Code below :

input {
    jdbc {      
        jdbc_connection_string => "jdbc:oracle:oci:MyDB"       
        jdbc_user => "testUser"
        jdbc_password => "testPassword"        
        jdbc_driver_library => "C:\app\Administrator\product\11.2.0\client_1\ojdbc6.jar"     
        jdbc_driver_class => "Java::oracle.jdbc.driver.OracleDriver"    
        statement => "SELECT * from test where updated_on >= :sql_last_start"
        schedule => "* * * * *"
        jdbc_fetch_size=>3
    }
}
output {
    stdout { codec => rubydebug }
    file {
             path => "C:\logstashOutput.txt"
             message_format => "%{@timestamp}: %{id} - %{name} at :sql_last_start"
       }
}

#2

If you run Logstash at the debugging level (--debug), the jdbc input plugin will write out each query (SQL statement) that it issues. So you can tell from the Logstash log file to determine the time at which it executes each query. Unfortunately, the plugin does not currently provide any information on the # of records retrieved by each statement.


(system) #3