實施例時:grok正則表達式解析不匹配日誌。指定一個基團作爲任選的,但不是最後一個組
info: 2014-10-28T22:39:46.593Z - info: an error occurred while trying to handle command: PlaceMarketOrderCommand, xkkdAAGRIl. Error: Insufficient Cash #userId=5 #orderId=Y5545
圖案:使用
> %{LOGLEVEL:stream_level}: %{TIMESTAMP_ISO8601:timestamp} -
> %{LOGLEVEL:log_level}: %{MESSAGE:message}
> (#userId=%{USER_ID:user_id})? (#orderId=%{ORDER_ID:order_id})?
額外圖案:
USER_ID (\d+|None)
ORDER_ID .*
ORDER_ID_HASH \s*(#orderId=%{ORDER_ID:order_id})?
USER_ID_HASH \s*(#userId=%{USER_ID:user_id})?
MESSAGE (.*?)
正常工作: 去除可選last orderId also works
info: 2014-10-28T22:39:46.593Z - info: an error occurred while trying to handle command: PlaceMarketOrderCommand, xkkdAAGRIl. Error: Insufficient Cash #userId=5
,但如果我繼續OrderID和要刪除用戶名,然後我得到一個「不匹配」
info: 2014-10-28T22:39:46.593Z - info: an error occurred while trying to handle command: PlaceMarketOrderCommand, xkkdAAGRIl. Error: Insufficient Cash #orderId=Y5545
另外,USER_ID組與結尾?作爲一個可選的組..
這是一個錯誤? (logstash 1.4.2)在正則表達式中丟失了什麼? (更可能..但什麼?)
我看着regex lib grok is using,看起來這種語法應該工作。它確實適用於最後一組(orderId),但不適用於前一組。
感謝您的幫助!