I am using logstash to read some logs. I have a log file which the Timestamp only consist of time field, i.e. 08:28:20,500, but no date field. I would like to map it with the datetime of today. How should I do that with date filter.
A line of my log file is like this.
08:28:20,500 INFO [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 27) JBAS010403: Deploying JDBC-compliant driver class org.h2.Driver (version 1.3)>>"C:\CIGNA\jboss\jboss.log"
Is there anyone who can help with this issue?Great thanks in advance.
EDIT After using ruby as filter, I have managed to solve the issue. However, there is occasionally a ruby exception. As seen from below, the first message has come across with ruby exception while the 2nd one runs fine. I would wonder how this happen and if anyone can provide me some advice. Thanks.
{
"message" => "10:30:39 FATAL [org.jboss.as.server] (default task-1) JBAS015957: Server boot has failed in an unre
coverable manner; exiting. See previous messages for details.\r",
"@version" => "1",
"@timestamp" => "2016-07-26T02:43:17.379Z",
"path" => "C:/CIGNA/jboss/jboss.log",
"host" => "SIMSPad",
"type" => "txt",
"Time" => "10:30:39",
"Level" => "FATAL",
"JavaClass" => "org.jboss.as.server",
"Message" => "(default task-1) JBAS015957: Server boot has failed in an unrecoverable manner; exiting. See previo
us messages for details.\r",
"tags" => [
[0] "_rubyexception"
]
}
{
"message" => "10:30:39 DEBUG [org.jboss.as.quickstarts.logging.LoggingExample] (default task-1) Settings reconfig
ured: JBOSS EAP Resettlement\r",
"@version" => "1",
"@timestamp" => "2016-07-26T02:30:39.000Z",
"path" => "C:/CIGNA/jboss/jboss.log",
"host" => "SIMSPad",
"type" => "txt",
"Time" => "10:30:39",
"Level" => "DEBUG",
"JavaClass" => "org.jboss.as.quickstarts.logging.LoggingExample",
"Message" => "(default task-1) Settings reconfigured: JBOSS EAP Resettlement\r"
}
And my updated filter part in my logstash .conf file is as shown.
filter {
grok {
match => { "message" => '\A%{TIME:Time}%{SPACE}%{WORD:Level}%{SPACE}\[%{PROG:JavaClass}]%{SPACE}%{JAVALOGMESSAGE:Message}'}
}
ruby {
code => "
p = Time.parse(event['message']);
event['@timestamp'] = LogStash::Timestamp.new(p);
"
}
}
Timefield, not Timestamp, which does not exist in your example. Also the time pattern is missing,SSSfor the milliseconds - baudsp