Hi,
I’m following a private project and I’m quite stuck on one of the requirements:
We are receiving Windows NXlog from a management workstation and other Windows clients and we are trying to set a couple of alerts every time a login or a logout is performed through RDP
For every logout, 1 log is received from the source, but for every login, we receive 7 logs within 2/3 seconds:
- 4 x “Successful Login”
- 3 x “A user disconnected”
in no particular order (it changes every time) and I think it’s the authentication method’s fault, but I can’t be sure, since I haven’t permissions to log on appliances other than the graylog one.
The rules we wanted to enforce were:
-
keep the first login in the chain and ignore the others
which we solved by setting 1 backlog and 5 seconds of grace period in the notifications rules -
keep 1 logout, but only if there aren’t any logins within a 5 seconds period
which would be easy enough per se, the correlation engine could work this out in no time, but the email should contain some of the fields of the message that triggered the rule.
Overview
Graylog 4.0.5+d95b909 (Debian 11.0.9.1 on Linux 4.19.0-14-amd64)
Event Definition (Windows - Account Logout (RDP))
- Event condition
- Condition tipe: Filter & Aggregation
- Filter
- search query: “
source:<name> AND EventID:4634 AND NOT TargetUserName:SYSTEM
” - stream: “MGMT Workstation”
- search in the last “10 seconds”
- execute search every “10 seconds”
- Create Events for Definition if… “Filter has results”
- search query: “
- No Notifications
Event Definition (Windows - Account Logout (correlation)
- Event condition
- Condition tipe: Event Correlation
- Event Correlation Rules
- search in the last “10 seconds”
- execute search every “10 seconds”
- event #1
- event from “Windows - Account Logout (RDP)”
- should occur at least “1 time”
- followed by:
- event #2
- event from “Windows - Account Login (RDP)”
- should not occur in the next “5 seconds”
- Notification
- [Email] Windows - logout event
- message backlog (1)
Notification ([Email] Windows - logout event)
- Notification Type “Email Notification”
- Sender “
graylog@server.local
” - Subject “Graylog event notification: ${event_definition_title}”
- Body Template:
<b>${event.message}</b>${if backlog}${foreach backlog message}
Message ID: https://graylog.server.local/messages/${message.index}/${message.id}
Timestamp: ${message.fields.DateTime}
Sistema: ${message.source}
Utente: ${message.fields.TargetUserName}
${end}
${else}<i>- no backlog -</i>
${end}
DateTime
is a custom field created by an extractor.
Question
we need: Message ID
({message.index}/{message.id}), Timestamp
({message.fields.DateTime}**), `Sistema` (**{message.source}) and Utente
(${message.fields.TargetUserName}) from messages that trigger the “Windows - Account Logout (RDP)” rule.
I didn’t quite understand the full potential of the “Custom Fileds” section and I found myself reading errors like:
2021-04-11T19:16:57.334+02:00 ERROR [TemplateFieldValueProvider] No value found for variable "message.source" in template "${message.source}"
2021-04-11T19:17:02.785+02:00 WARN [CorrelationEventProcessor] Event <###> has no value for field <Sistema>
in the “server.log
” without knowing where to watch to start troubleshooting.
Is it possible to use the “Custom Fields” section in the event definition to solve this problem? If yes, should I create custom fields on the base rule or in the correlation rule? Should I mark them as keys?
Is there any other way to retrieve the messages of the events triggering the correlation in the notification?
Thanks,