Externalize the absolute path names in log-stash configuration and using relative path in patterns_dir

373 Views Asked by At

Hi logstash experts please help me
While doing logstash configuration in the input section

input 
{
    file 
    {
         path => "/TISUATWEB53/home/tisuat54/solstis/solstair-uat/solstis-persist-1/logs/solstispersist.log" #file to parse
         sincedb_path =>"/TISUATWEB53/home/tisuat54/solstis/solstair-uat/solstis-persist-1/logs/solstispersist.db" #file to save position (used after restart)
         start_position => "beginning" #start on the beginning of the file when no sincedb path created
    }
}  

filter {
    grok {
#    patterns_dir => ["../.././patterns/"]
     patterns_dir => ["/TISUATWEB53/home/tisuat54/Tmon_LogStash/tmon-agent-3.2.3/patterns/"]
     match => { "message" => "%{BEFORE_THREAD_NAME}(%{THREAD_NAME:thread_name})%{BEFORE_ANALYSISPROCESS_ID}(%{ONLY_DIGITS:analysisprocessId})%{BEFORE_INSERTIONMONITORING_ID}%{ONLY_DIGITS:insertionmonitorId}%{BEFORE_BIN_FILE}%{BINFILE:binfileName}"}
    }
}

Can we define file path in properties file and refer properties in path=> and sincedb_path=> .
And also in filter section how to define relative path in patterns_dir .I have tried patterns_dir => ["../../patterns/"] but not working

1

There are 1 best solutions below

7
On

You can use environment variables in logstash, so you could do ${VAR_FROM_ENVIRONMENT} in you file and then set that variable before starting logstash. For example:

export VAR_FROM_ENVIRONMENT="/TISUATWEB53/home/tisuat54"
bin/logstash -f logstash.conf

If you are running a version of logstash before logstash-5, you'll need to add a --allow-env flag to your logstash command line.