Hello guys!
Please, I need your advise.
From one client server to logstash comming 2 different logs with different time template:
-
[2021-02-24 00:00:06,335] [[ACTIVE] ExecuteThread: '121' for queue: 'weblogic.kernel.Default (self-tuning)'] ERROR EntityDataSourceRepository:readEntities:130
-
2021-01-27 10:22:04 0.488 GET 200 /api/1.0/info/prepaidAddBalance?ctn=7768741498&hash
Because elastic can't take different timestamps at the same time, I cut milliceconds in first timepattern, but it doesn't work, nothing goes to elastic.
My current filter is:
filter {
if "/uss/servlet/ivrRequest" in [message] {
grok { match => {"message" => "(?%{YEAR}-%{MONTHNUM}-%{MONTHDAY})\t[\t]%{WORD:method}[\t]%{URIPATH:request_type}[?]BNumber=%{NUMBER:bnumber}&ANumber=%{NUMBER:msisdn}[\t]%{NUMBER:response_code}[\t]%{NUMBER:response_time}"}}
mutate {
add_field => {"log_time" => "%{date} %{hms}"}
}
date { match => [ "log_time", "YYYY-MM-dd HH:mm:ss" ]
timezone => "Asia/Almaty"
target => "@timestamp"
}
mutate {strip => ["log_time"]
remove_field => ["date", "hms"]
}
}
else if "/uss/servlet/ussdHttpServlet.ru" in [message] or "/uss/servlet/ussdHttpServlet.kz" in [message] {
grok { match => {"message" => "(?%{YEAR}-%{MONTHNUM}-%{MONTHDAY})\t[\t]%{WORD:method}[\t]%{URIPATH:request_type}[?]msisdn=%{NUMBER:msisdn}&ussd=%{NUMBER:ussd}[\t]%{NUMBER:response_code}[\t]%{NUMBER:response_time}"}}
mutate {
add_field => {"log_time" => "%{date} %{hms}"}
}
date { match => [ "log_time", "YYYY-MM-dd HH:mm:ss" ]
timezone => "Asia/Almaty"
target => "@timestamp"
}
mutate {strip => ["log_time"]
remove_field => ["date", "hms"]
}
}
if "ER000" in [message] or "ER001" in [message] or "ER002" in [message] or "ER003" in [message] or "ER004" in [message] or "ER004" in [message] or "TUX" in [message] or "ER034" in [message] {
grok { match => {"message" => "[%{TIMESTAMP_ISO8601:error_log_time}]%{GREEDYDATA} %{LOGLEVEL:log-level}%{GREEDYDATA} \NAPIERROR %{WORD:action}%{GREEDYDATA} [%{WORD:response_code}%{GREEDYDATA}\BAN=[%{NUMBER:ban}%{GREEDYDATA}\SUBSCRIBER_NO=[%{NUMBER:subscriber_no}%{GREEDYDATA}\SOC=[%{WORD:soc}%{GREEDYDATA}"}}
mutate { gsub => ["error_log_time", ",\d{3}$", ""]}
date { match => [ "error_log_time", "YYYY-MM-dd HH:mm:ss" ]
timezone => "Asia/Almaty"
target => "@timestamp"
}
}
else if "! service is too slow" in [message] {
grok { match => {"message" => "[%{TIMESTAMP_ISO8601:error_log_time}]%{GREEDYDATA} %{LOGLEVEL:log-level}%{GREEDYDATA}- %{GREEDYDATA:response_code}"}}
mutate { gsub => ["error_log_time", ",\d{3}$", ""]}
date { match => [ "error_log_time", "YYYY-MM-dd HH:mm:ss" ]
timezone => "Asia/Almaty"
target => "@timestamp"
}
}
else if "! Tuxedo service is too slow" in [message] {
grok { match => {"message" => "[%{TIMESTAMP_ISO8601:error_log_time}]%{GREEDYDATA} %{LOGLEVEL:log-level}%{GREEDYDATA}- %{GREEDYDATA:response_code}: com%{GREEDYDATA}"}}
mutate { gsub => ["error_log_time", ",\d{3}$", ""]}
date { match => [ "error_log_time", "YYYY-MM-dd HH:mm:ss" ]
timezone => "Asia/Almaty"
target => "@timestamp"
}
}
else {
grok { match => {"message" => "(?%{YEAR}-%{MONTHNUM}-%{MONTHDAY})\t[\t]%{NUMBER:response_time}[\t]%{WORD:method}[\t]%{NUMBER:response_code}[\t]%{URIPATH:request_type}[?]ctn=%{NUMBER:msisdn}"}}
mutate {
add_field => {"log_time" => "%{date} %{hms}"}
}
date { match => [ "log_time", "YYYY-MM-dd HH:mm:ss" ]
timezone => "Asia/Almaty"
target => "@timestamp"
}
mutate {strip => ["log_time"]
remove_field => ["date", "hms"]
}
}
if "_grokparsefailure" in [tags] {
drop {}
}
}