Last active
October 28, 2022 13:37
-
-
Save stuart-warren/6726081 to your computer and use it in GitHub Desktop.
Windows Event log via nxlog (json) -> logstash 1.2 config
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Exception in filterworker {"exception"=>#<NoMethodError: undefined method `[]=' for nil:NilClass>, "backtrace"=>["file:/opt/logstash/logstash.jar!/logstash/event.rb:135:in `[]='", "org/jruby/RubyProc.java:255:in `call'", "(eval):9:in `exec'", "org/jruby/RubyProc.java:255:in `call'", "file:/opt/logstash/logstash.jar!/logstash/util/fieldreference.rb:44:in `exec'", "file:/opt/logstash/logstash.jar!/logstash/event.rb:134:in `[]='", "file:/opt/logstash/logstash.jar!/logstash/filters/mutate.rb:234:in `rename'", "org/jruby/RubyHash.java:1332:in `each'", "file:/opt/logstash/logstash.jar!/logstash/filters/mutate.rb:232:in `rename'", "file:/opt/logstash/logstash.jar!/logstash/filters/mutate.rb:205:in `filter'", "(eval):127:in `initialize'", "org/jruby/RubyProc.java:255:in `call'", "file:/opt/logstash/logstash.jar!/logstash/pipeline.rb:243:in `filter'", "file:/opt/logstash/logstash.jar!/logstash/pipeline.rb:191:in `filterworker'", "file:/opt/logstash/logstash.jar!/logstash/pipeline.rb:134:in `start_filters'"], :level=>:error} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
input { | |
tcp { | |
codec => "json" | |
port => 5140 | |
tags => ["windows","nxlog"] | |
type => "nxlog-json" | |
} | |
} # end input | |
filter { | |
if [type] == "nxlog-json" { | |
date { | |
match => ["[EventTime]", "YYYY-MM-dd HH:mm:ss"] | |
timezone => "Europe/London" | |
} | |
mutate { | |
rename => [ "AccountName", "user" ] | |
rename => [ "AccountType", "[eventlog][account_type]" ] | |
rename => [ "ActivityId", "[eventlog][activity_id]" ] | |
rename => [ "Address", "ip6" ] | |
rename => [ "ApplicationPath", "[eventlog][application_path]" ] | |
rename => [ "AuthenticationPackageName", "[eventlog][authentication_package_name]" ] | |
rename => [ "Category", "[eventlog][category]" ] | |
rename => [ "Channel", "[eventlog][channel]" ] | |
rename => [ "Domain", "domain" ] | |
rename => [ "EventID", "[eventlog][event_id]" ] | |
rename => [ "EventType", "[eventlog][event_type]" ] | |
rename => [ "File", "[eventlog][file_path]" ] | |
rename => [ "Guid", "[eventlog][guid]" ] | |
rename => [ "Hostname", "hostname" ] | |
rename => [ "Interface", "[eventlog][interface]" ] | |
rename => [ "InterfaceGuid", "[eventlog][interface_guid]" ] | |
rename => [ "InterfaceName", "[eventlog][interface_name]" ] | |
rename => [ "IpAddress", "ip" ] | |
rename => [ "IpPort", "port" ] | |
rename => [ "Key", "[eventlog][key]" ] | |
rename => [ "LogonGuid", "[eventlog][logon_guid]" ] | |
rename => [ "Message", "message" ] | |
rename => [ "ModifyingUser", "[eventlog][modifying_user]" ] | |
rename => [ "NewProfile", "[eventlog][new_profile]" ] | |
rename => [ "OldProfile", "[eventlog][old_profile]" ] | |
rename => [ "Port", "port" ] | |
rename => [ "PrivilegeList", "[eventlog][privilege_list]" ] | |
rename => [ "ProcessID", "pid" ] | |
rename => [ "ProcessName", "[eventlog][process_name]" ] | |
rename => [ "ProviderGuid", "[eventlog][provider_guid]" ] | |
rename => [ "ReasonCode", "[eventlog][reason_code]" ] | |
rename => [ "RecordNumber", "[eventlog][record_number]" ] | |
rename => [ "ScenarioId", "[eventlog][scenario_id]" ] | |
rename => [ "Severity", "level" ] | |
rename => [ "SeverityValue", "[eventlog][severity_code]" ] | |
rename => [ "SourceModuleName", "nxlog_input" ] | |
rename => [ "SourceName", "[eventlog][program]" ] | |
rename => [ "SubjectDomainName", "[eventlog][subject_domain_name]" ] | |
rename => [ "SubjectLogonId", "[eventlog][subject_logonid]" ] | |
rename => [ "SubjectUserName", "[eventlog][subject_user_name]" ] | |
rename => [ "SubjectUserSid", "[eventlog][subject_user_sid]" ] | |
rename => [ "System", "[eventlog][system]" ] | |
rename => [ "TargetDomainName", "[eventlog][target_domain_name]" ] | |
rename => [ "TargetLogonId", "[eventlog][target_logonid]" ] | |
rename => [ "TargetUserName", "[eventlog][target_user_name]" ] | |
rename => [ "TargetUserSid", "[eventlog][target_user_sid]" ] | |
rename => [ "ThreadID", "thread" ] | |
} | |
mutate { | |
remove_field => [ | |
"CurrentOrNextState", | |
"Description", | |
"EventReceivedTime", | |
"EventTime", | |
"EventTimeWritten", | |
"IPVersion", | |
"KeyLength", | |
"Keywords", | |
"LmPackageName", | |
"LogonProcessName", | |
"LogonType", | |
"Name", | |
"Opcode", | |
"OpcodeValue", | |
"PolicyProcessingMode", | |
"Protocol", | |
"ProtocolType", | |
"SourceModuleType", | |
"State", | |
"Task", | |
"TransmittedServices", | |
"Type", | |
"UserID", | |
"Version" | |
] | |
} | |
} | |
} | |
output { | |
# For debugging purposes! | |
stdout { | |
debug => true | |
codec => "plain" | |
} | |
} # end output |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## This is a sample configuration file. See the nxlog reference manual about the | |
## configuration options. It should be installed locally and is also available | |
## online at http://nxlog.org/nxlog-docs/en/nxlog-reference-manual.html | |
## Please set the ROOT to the folder your nxlog was installed into, | |
## otherwise it will not start. | |
#define ROOT C:\Program Files\nxlog | |
define ROOT C:\Program Files (x86)\nxlog | |
Moduledir %ROOT%\modules | |
CacheDir %ROOT%\data | |
Pidfile %ROOT%\data\nxlog.pid | |
SpoolDir %ROOT%\data | |
LogFile %ROOT%\data\nxlog.log | |
<Extension json> | |
Module xm_json | |
</Extension> | |
<Input in> | |
Module im_msvistalog | |
# For windows 2003 and earlier use the following: | |
# Module im_mseventlog | |
Exec to_json(); | |
</Input> | |
<Output out> | |
Module om_tcp | |
Host 10.66.66.66 | |
Port 5140 | |
</Output> | |
<Route 1> | |
Path in => out | |
</Route> |
awesome!
Hi,
Do I need logstash.conf too? What's exception.rb
Nx-log not generating the event log with Event id........ It's possible ?
Perfect
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for this. Spent ages trying to get it working and this worked perfectly!