Fix missing contrail logs patterns
Change-Id: I7ba38f47ce768ad435d2fe9ce110c24ea0d58313
diff --git a/heka/files/lua/common/contrail_patterns.lua b/heka/files/lua/common/contrail_patterns.lua
index 9499875..153f28f 100644
--- a/heka/files/lua/common/contrail_patterns.lua
+++ b/heka/files/lua/common/contrail_patterns.lua
@@ -46,7 +46,10 @@
-- Timestamp patterns
-- 10/31/2016 03:40:47 AM [contrail-alarm-gen]: blabla
-local log_timestamp = l.Cg(dt.build_strftime_grammar("%m/%d/%Y %r") / dt.time_to_ns, "Timestamp")
+local log_num_month_timestamp = l.Cg(dt.build_strftime_grammar("%m/%d/%Y %r") / dt.time_to_ns, "Timestamp")
+local log_short_str_month_timestamp = l.Cg(dt.build_strftime_grammar("%b/%d/%Y %r") / dt.time_to_ns, "Timestamp")
+local log_full_str_month_timestamp = l.Cg(dt.build_strftime_grammar("%B/%d/%Y %r") / dt.time_to_ns, "Timestamp")
+local log_timestamp = l.Ct(log_num_month_timestamp + log_short_str_month_timestamp + log_full_str_month_timestamp)
-- 172.16.10.101 - - [2016-10-31 12:50:36] "POST /subscribe HTTP/1.1" 200 715 0.058196
local api_timestamp = l.Cg(patt.Timestamp, "Timestamp")
@@ -64,6 +67,11 @@
-- Complete grammars
-- 10/31/2016 03:40:47 AM [contrail-alarm-gen]: blabla
LogGrammar = l.Ct(log_timestamp * patt.sp * "[" * modulename * "]:" * patt.sp * message)
+-- wokeup and found a line
+-- NoSuchProcess: process name:cassandra pid:22192
+-- Exception AssertionError: AssertionError() in <module 'threading' from '/usr/lib/python2.7/threading.pyc'> ignored
+-- ...
+GenericGrammar = l.Ct(message)
-- 172.16.10.101 - - [2016-10-31 12:50:36] "POST /subscribe HTTP/1.1" 200 715 0.058196
ApiGrammar = l.Ct(ip_address * delim * "["* api_timestamp * "]" * sp * message)
diff --git a/heka/files/lua/decoders/contrail_log.lua b/heka/files/lua/decoders/contrail_log.lua
index b2c48ce..d306dee 100644
--- a/heka/files/lua/decoders/contrail_log.lua
+++ b/heka/files/lua/decoders/contrail_log.lua
@@ -31,13 +31,19 @@
local log = read_message("Payload")
local logger = read_message("Logger")
local m = contrail.LogGrammar:match(log)
- if not m then
- return -1, string.format("Failed to parse %s log: %s", logger, string.sub(log, 1, 64))
- end
- msg.Timestamp = m.Timestamp
- msg.Payload = m.Message
msg.Fields = {}
- msg.Fields.severity_label = 'INFO'
+ if not m then
+ m = contrail.GenericGrammar:match(log)
+ if not m then
+ return -1, string.format("Failed to parse %s log: %s", logger, string.sub(log, 1, 64))
+ end
+ msg.Fields.severity_label = 'ERROR'
+ else
+ msg.Fields.severity_label = 'INFO'
+ end
+ msg.Payload = m.Message
+ msg.Severity = utils.label_to_severity_map[msg.Fields.severity_label]
+ msg.Timestamp = m.Timestamp
msg.Fields.programname = m.Module
utils.inject_tags(msg)
return utils.safe_inject_message(msg)