Thanks for all your great and valuable feedback. I’m then continuing down the pipeline path, but have run into some other issues here. I’m having a little hard time to understand exactly what the pipeline does when the “Then” code has been executed. Does it just modify the original message so this modifications are visible when searching and showing the message in “search”?.
What happens is that my rule seems to be able to parse the Json in message field in the simulator, but when receiving messages from the real stream, it fails ALL messages. I took the message directly from a recent event, and tried it it the simulator. It was parsed fine.
Here’s an example of the data:
{ “time”: “2018-12-14 12:02:11.9210”, “level”: “INFO”, “message”: “DODP operation-entry: getBookmarks”, “CorrelationID”: “c472e04b-6ee2-47f1-9684-d354feb15d82”, “SessionID”: “UFbMbnX8i0a8BxqH6A_s-g”, “Component”: “DodpMobile”, “ComponentVersion”: “1.0.1.0”, “Action”: “DODP-GETBOOKMARKS”, “MethodNameOrURL”: “/getBookmarks”, “MemberID”: “”, “BookNo”: null, “TimeSpentInMs”: “0”, “Hostname”: “BETADLWEB02”, “InitiatorIPAddress”: “192.168.0.7”, “UserAgent”: “DodpReader;1.0.40.25070”, “ResultCode”: null, “DataAsJson”: null }
Here’s the Rule:
rule “parse the json log entries”
when
true
then
let json_tree = parse_json(to_string(message.message));
let json_fields = select_jsonpath(json_tree, { time: ".time", level: “.level", message: ".message”, CorrelationID: “.CorrelationID", SessionID: ".SessionID”, Component: “.Component", ComponentVersion: ".ComponentVersion”, Action: “.Action", ResultCode: ".ResultCode”, DataAsJson: “.DataAsJson" , InitiatorIPAddress: ".InitiatorIPAddress” , MethodNameOrURL: “.MethodNameOrURL", MemberID: ".MemberID”, UserAgent: “.UserAgent", TimeSpentInMs: ".TimeSpentInMs”, BookNo: “.BookNo", SourceLine: "._source_line”, SourceMethod: “._source_method", EventDateAtOrigin: ".EventDateAtOrigin” });
set_field(“EventDateAtOrigin”, to_date(json_fields.EventDateAtOrigin));
set_field(“Level”, to_string(json_fields.Level));
set_field(“CorrelationID”, to_string(json_fields.CorrelationID));
set_field(“SessionID”, to_string(json_fields.SessionID));
set_field(“BookNo”, to_string(json_fields.BookNo));
set_field(“Hostname”, to_string(json_fields.Hostname));
set_field(“UserAgent”, to_string(json_fields.UserAgent));
set_field(“ResultCode”, to_long(json_fields.ResultCode));
set_field(“ComponentVersion”, to_string(json_fields.ComponentVersion));
set_field(“Component”, to_string(json_fields.Component));
set_field(“Action”, to_string(json_fields.Action));
set_field(“MemberID”, to_string(json_fields.MemberID));
set_field(“TimeSpentInMs”, to_long(json_fields.TimeSpentInMs));
set_field(“DataAsJson”, to_string(json_fields.DataAsJson));
set_field(“MethodNameOrURL”, to_string(json_fields.MethodNameOrURL));
set_field(“InitiatorIPAddress”, to_string(json_fields.InitiatorIPAddress));
set_field(“time”, to_string(json_fields.time));
set_field(“SourceLine”, to_string(json_fields.SourceLine));
set_field(“SourceMethod”, to_string(json_fields.SourceMethod));
set_field(“timestamp”, parse_date(substring(to_string(json_fields.time), 0, 23), “yyyy-MM-dd HH:mm:ss.SSS”));
remove_field(“time”);
end
Simulator shows:
Here’s where I see errors:
Or at least think it means errors evem 0 error/s(1145) could be understood in many ways, anyway, theres no changes to the messages when I search. No new or modified fields. (Do I need to cycle index?)
I dont know how to troubleshoot this. Do I need to look into Graylog server logs?
Sorry that I have to ask for more help…
//Peter