Hello friends!
I need some help with my logstash config.
I want to get event field "winlog.event_data.ObjectName" and take it to a bash script.
Then I want to get the result back and put it in the "winlog.event_data.ObjectName".
Is it possible with rub filter or smth like that?
Here is the config:
input {
beats {
port => 5140
}
}
filter {
if [winlog.event_data.ObjectType] {
ruby {
code => 'require "open3"
winlog = event.get("winlog.event_data.ObjectName")
cmd = "/etc/logstash/script/ldap_search.sh #{winlog}"
stdin, stdout, stderr = Open3.popen3(cmd)
event.set("winlog.event_data.ObjectType", stdout.read)
err = stderr.read
if err.to_s.empty?
filter_matched(event)
else
event.set("winlog.event_data.ObjectType", err)
end'
remove_field => ["tags"]
}
}
}
PS:
"ldap_search.sh" script does:
Turns the value like this "%{1ee131bd-72b1-47ae-8d79-ba4bd881a86b}"
Into the value like that "DC=AgentSmith,DC=example.ru,DC=ru"
It can be used to get the "DistingushedName" of an Active Directory object that was last changed.
Example:
/etc/logstash/script/ldap_search.sh %{1ee131bd-72b1-47ae-8d79-ba4bd881a86b}
stdout:
"DC=AgentSmith,DC=example.ru,DC=ru