I'm trying to write GROK filter in logstash conf file to decode above entry and get the timestamp, latency and URI. I'll calculate response time from latency (response time =subtracting 12 position field from 6th position field)
my logstash conf entry looks like
input {
tcp {
port => 5514
type => syslog
}
}
filter {
syslog_pri {
add_field => { "[@metadata][type]" => "syslog" }
add_field => { "[@metadata][beat]" => "syslog" }
}
if [type] == "syslog" {
grok {
match => { "message" => "%{SYSLOGLINE}" }
}
date {
match => [ "timestamp", "MMM d HH:mm:ss", "MMM dd HH:mm:ss" ]
}
}
}
output {
if [type] == "syslog" {
elasticsearch {
hosts => ["localhost:9200"]
sniffing => true
manage_template => false
user => elastic
password => defaultpassword
index => "datapower-%{+YYYY.MM.dd}"
}
}
}
I tried to use Grok debugger but I'm stuck with timestamp entry itself. I tried few options like
%{DATESTAMP:timestamp}
%{SYSLOGTIMESTAMP:timestamp}
%{TIMESTAMP_ISO8601:timestamp}
I was wonder how the <%{level}> and %{unnamed} related to the below log event
20180308T211418.088Z [0x80e00073][mpgw][debug] mpgw(MyServices_MPGW): tid(12380973)[102.29.16.10] gtid(5ae25f9f5a986d770257aec3): Latency: 0 138 0 56 56 56 0 138 138 138 138 138 138 138 56 138 [http://10.40.59.102:8070/rephierarchy/savedlist/2798]
As log as the filter works I'm good. I made the changes you have recommend and I would not be able to test them until I restart ELK Stack. I'm not sure if the is expected behavior of the ELK stask to restart all (Logstash, Elasticsearch and Kibana). I have dependence with other team who is testing other functionality. I'll reboot once the other team have done testing their changes. After installing XPack, I have noticed that rebooting ELK stack doesnt reflect logstash config changes.
Now I understood what you mean by <%{level}> and %{unnamed}.
Question: You still want me to GROK along dissect? or Can we skip GROK in this scenario?
Below output I got is using GROK:
--- GROK OUTPUT--
"<14>Mar 08 11:03:11 DVI_MyServices [0x80e00073][latency][info] mpgw(MyServices_MPGW): trans(12362109)[102.29.16.10] gtid(5ae25f9f5aa15f0704322723): Latency: 0 138 0 56 56 56 0 138 138 138 138 138 138 138 56 138 [http://10.40.59.102:8070/rephierarchy/savedlist/2798]"
Without using GROK, the input from TCP to Logstash would look like the following
---- TCP input ----
20180308T211418.088Z [0x80e00073][mpgw][debug] mpgw(MyServices_MPGW): tid(12380973)[102.29.16.10] gtid(5ae25f9f5a986d770257aec3): Latency: 0 138 0 56 56 56 0 138 138 138 138 138 138 138 56 138 [http://10.40.59.102:8070/rephierarchy/savedlist/2798]
Based our your latest response, may be you wanted me to use filter config as following:
I'll test above changes once a request comes from TCP (I cannot manually trigger the TCP request).
Also is it possible to get URI from URL request without query parameters using dissect ?
For example
dissect {
mapping => {
message => "<%{}>%{ts} %{+ts} %{+ts} %{} [%{}][%{}] %{}: %{} %{} Latency: %{latency} [%{url}]"
"url" => "http://%{}:%{}/%{uri}?%{}"
}
}
Yes, but the pattern you gave only works if there is a query string. So you would have to test for the presence of ? to decide whether to include ?%{} in the mapping.
After Adding the query parameter URL line along with URL line without query parameter in logstash config, logstash is not even listening on port 5514 after restarting. Removing query parameter URL from config is working as expected.
Is there a way to check in some log files where the problem is?
"logstash-plain.log" file size is empty.
/var/log/logstash/logstash-plain.log
-rw-r--r--. 1 logstash logstash 0 Mar 13 09:36 logstash-plain.log
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.