Skip to content
This repository was archived by the owner on Mar 21, 2023. It is now read-only.

parse_date throws exception on errorΒ #243

@jalogisch

Description

@jalogisch

When using the parse_date function the rule will exit with an exception if the parse_date does not work.

Backround

parse_date could be used in the when part of the rules to check what date format is used and then act on that.

rule "correct time"
when
   parse_date(value:$message.log_date, pattern:"MMM dd HH:mm:ss.SSS", timezone:"CET");
then
    let date = now("CET");
    let new_date = concat(to_string(date.year), to_string($message.log_date));
    let time = parse_date(value:new_date, pattern:"yyyyMMM dd HH:mm:ss.SSS", timezone:"CET");
    set_field("timestamp",time);
end

Additional it is not possible to have multiple parse_date rules in the same rule to catch all possible timestamps with multiple callings of parse_date.

let new_date = to_string($message.log_date);
let time = parse_date(value:new_date, pattern:"MMM dd HH:mm:ss.SSS", timezone:"CET");
let time = parse_date(value:new_date, pattern:"MMM dd HH:mm:ss ZZZ", timezone:"CET");
let time = parse_date(value:new_date, pattern:"MMM dd HH:mm:ss.SSS ZZZ", timezone:"CET");
set_field("processed_time", time);

The above is possible with other functions (like grok).

Environment

  • Graylog Version: 2.4.3

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions