Handle and fix timezones and timestamps
AxoSyslog FilterX has a few functions set or fix the timestamp and timezone of the messages.
fix_timezone
Available in AxoSyslog 4.24 and later. Similar to the fix-time-zone() rewrite operation.
Corrects the timezone of a message if it was parsed incorrectly for some reason, or if the client didn’t include any timezone information in the message. For example:
datetime = strptime("2000-01-01T00:00:00 +0200", "%Y-%m-%dT%H:%M:%S %z");
timezone = "CET";
fixed_datetime = fix_timezone(datetime, timezone);
${MSG} = strftime("%Y-%m-%dT%H:%M:%S %z", fixed_datetime);
get_timezone_source
Available in AxoSyslog 4.24 and later.
Shows where the timezone information of the message originates from.
For example:
if (get_timezone_source(timestamp) === "assumed") {
timestamp = fix_timezone(timestamp, "CET");
};
Possible values:
assumed: The timestamp didn’t contain timezone info, so AxoSyslog used the default (local) timezonefixed: The timezone was set using thefix_timezoneorset_timezonefunctionsguessed: The timezone info was set usingguess_timezonefunctionparsed: The timezone was parsed from the timestamp
guess_timezone
Available in AxoSyslog 4.24 and later. Similar to the guess-time-zone() rewrite operation.
Attempts to set the timezone of the message automatically, using heuristics on the timestamps. Normally AxoSyslog performs this operation automatically when it parses the incoming message. Use this function if you can’t parse the incoming message for some reason, but you want to set the timezone automatically, for example, after you have preprocessed the message. Using this function is identical to using the flags(guess-timezone) flag in the source.
For example:
datetime = strptime("2000-01-01T00:00:00 +0200", "%Y-%m-%dT%H:%M:%S %z");
guessed_datetime = guess_timezone(datetime);
set_timezone
Available in AxoSyslog 4.24 and later. Similar to the set-time-zone() rewrite operation.
Sets the timezone of the message to a specific value, or converts an existing timezone to a different one. This operation is identical to setting the time-zone() option in the destination or as a global option, but can be applied selectively to the messages using conditions.
For example:
datetime = strptime("2000-01-01T00:00:00 +0200", "%Y-%m-%dT%H:%M:%S %z");
timezone = "CET";
set_datetime = set_timezone(datetime, timezone);
${MSG} = strftime("%Y-%m-%dT%H:%M:%S %z", set_datetime);