Hi everybody,
how can i see all logs outside business hours?
Thanks.
Hi everybody,
how can i see all logs outside business hours?
Thanks.
Time frame selector
and choose Absolute
and setup specific time frame.rule "out_of_hours"
when
to_long(now("Europe/London").hourOfDay) >= 0 AND
to_long(now("Europe/London").hourOfDay) < 7
then
set_field("out_of_hours", true);
//debug("out_of_hours");
end
rule âoff work hoursâ
when
( to_long(to_date($message.timestamp, âEurope/Berlinâ).hourOfDay) >= 0 AND to_long(to_date($message.timestamp, âEurope/Berlinâ).hourOfDay) <= 6 ) OR
( to_long(to_date($message.timestamp, âEurope/Berlinâ).hourOfDay) >= 18 AND to_long(to_date($message.timestamp, âEurope/Berlinâ).hourOfDay) <= 0 )
then
set_field(âout_of_hoursâ, true);
end
rule âoff work weekendâ
when
// from Monday (1) to Sunday (7)
to_long(to_date($message.timestamp, âEurope/Berlinâ).dayOfWeek) == 7 OR
to_long(to_date($message.timestamp, âEurope/Berlinâ).dayOfWeek) == 6
then
set_field(âout_of_hoursâ, true);
end
No you donât use it same way. Youâve used to_date
instead of now
pipeline function. There is a bug in graylogâs function to_date
which doesnât support timezone parameter, or ignore it, and always use UTC.
Also your condition will not match, replace it to 23
instead of 0
to_long(to_date($message.timestamp, âEurope/Berlinâ).hourOfDay) <= 0
Please post, whatâs wrong with your pipeline rule and your conditions.
You canât paste 2 rules into pipeline body of rule, please separate it into two pipeline rules. One with rule âoff work hoursâ and one for âoff work weekendâ.
otherwise everything is correct?
As I post, you used function to_date
with timezone parameter which is ignored. Either use UTC times in condition >=, <=, == or use function now
as i suggested with timezone.
Best way to debug functions is to use simple condition when true
or similar, and use debug:
rule "debug_hourOfDay"
when
true
then
debug(concat("hourOfDay: ", to_string(now("Europe/Berlin").hourOfDay));
debug(concat("dayOfWeek: ", to_string(now("Europe/Berlin").dayOfWeek));
end
Then check graylog logs file and search for line hourOfDay and dayOfWeek:
sudo tail -f /var/log/graylog-server/server.log
Thank you, this is now working properly.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.