I am using the below pipeline rule to convert the timestamp to normal timestamp.
rule "XXX"
when
has_field("message")
then
let json = parse_json(to_string($message.message));
let fields = select_jsonpath(json, {time:"$.timestamp"});
set_fields(fields);
let new_time = to_long($message.time);
set_field("new_time1", new_time / 1000);
let epoch = parse_date("1970-01-01T00:00:00", "yyyy-MM-dd'T'HH:mm:ss");
let ts_seconds = seconds(to_long($message.new_time1));
set_field("timestamp", epoch + ts_seconds);
end
When i simulate the json with the above pipeline, the timestamp is parsing accurately.
But when i send the json through postman on gelf, i am getting the below error in graylog logs.
2018-04-19 10:43:23,635 WARN : org.graylog.plugins.pipelineprocessor.functions.json.JsonParse - Unable to parse json
com.fasterxml.jackson.core.JsonParseException: Unrecognized token 'test': was expecting ('true', 'false' or 'null')
at [Source: iot; line: 1, column: 7]
The json is getting indexed now. I am using the below rule.
rule “XXX”
when
has_field(“message”)
then
let json = parse_json(to_string(message.message));
let fields = select_jsonpath(json, {time:".timestamp"});
set_fields(fields);
let new_time = to_long($message.time);
set_field(“new_time1”, new_time / 1000);
let epoch = parse_date(“1970-01-01T00:00:00”, “yyyy-MM-dd’T’HH:mm:ss”);
let ts_seconds = seconds(to_long($message.new_time1));
set_field(“timestamp”, epoch + ts_seconds);
end
The problem is :
Simulator is giving the exact time,
but the indexed data has timestamp as 1970-01-01T00:00:00 (which is not correct)