返回介绍

场景示例 - windows系统日志

发布于 2020-06-28 10:03:42 字数 11440 浏览 1249 评论 0 收藏 0

前面说过如何在 windows 上利用 nxlog 传输日志数据。事实上,对于 windows 本身,也有类似 syslog 的设计,叫 eventlog。本节介绍如何处理 windows eventlog。

采集端配置

logstash 配置

  1. input {
  2. eventlog {
  3. #logfile => ["Application", "Security", "System"]
  4. logfile => ["Security"]
  5. type => "winevent"
  6. tags => [ "caen" ]
  7. }
  8. }

nxlog 配置

  1. ## This is a sample configuration file. See the nxlog reference manual about the
  2. ## configuration options. It should be installed locally and is also available
  3. ## online at http://nxlog.org/nxlog-docs/en/nxlog-reference-manual.html
  4. ## Please set the ROOT to the folder your nxlog was installed into,
  5. ## otherwise it will not start.
  6. #define ROOT C:Program Filesnxlog
  7. define ROOT C:Program Files (x86)nxlog
  8. Moduledir %ROOT%modules
  9. CacheDir %ROOT%data
  10. Pidfile %ROOT%datanxlog.pid
  11. SpoolDir %ROOT%data
  12. LogFile %ROOT%datanxlog.log
  13. <Extension json>
  14. Module xm_json
  15. </Extension>
  16. <Input in>
  17. Module im_msvistalog
  18. # For windows 2003 and earlier use the following:
  19. # Module im_mseventlog
  20. Exec to_json();
  21. </Input>
  22. <Output out>
  23. Module om_tcp
  24. Host 10.66.66.66
  25. Port 5140
  26. </Output>
  27. <Route 1>
  28. Path in => out
  29. </Route>

Logstash 解析配置

  1. input {
  2. tcp {
  3. codec => "json"
  4. port => 5140
  5. tags => ["windows","nxlog"]
  6. type => "nxlog-json"
  7. }
  8. } # end input
  9. filter {
  10. if [type] == "nxlog-json" {
  11. date {
  12. match => ["[EventTime]", "YYYY-MM-dd HH:mm:ss"]
  13. timezone => "Europe/London"
  14. }
  15. mutate {
  16. rename => [ "AccountName", "user" ]
  17. rename => [ "AccountType", "[eventlog][account_type]" ]
  18. rename => [ "ActivityId", "[eventlog][activity_id]" ]
  19. rename => [ "Address", "ip6" ]
  20. rename => [ "ApplicationPath", "[eventlog][application_path]" ]
  21. rename => [ "AuthenticationPackageName", "[eventlog][authentication_package_name]" ]
  22. rename => [ "Category", "[eventlog][category]" ]
  23. rename => [ "Channel", "[eventlog][channel]" ]
  24. rename => [ "Domain", "domain" ]
  25. rename => [ "EventID", "[eventlog][event_id]" ]
  26. rename => [ "EventType", "[eventlog][event_type]" ]
  27. rename => [ "File", "[eventlog][file_path]" ]
  28. rename => [ "Guid", "[eventlog][guid]" ]
  29. rename => [ "Hostname", "hostname" ]
  30. rename => [ "Interface", "[eventlog][interface]" ]
  31. rename => [ "InterfaceGuid", "[eventlog][interface_guid]" ]
  32. rename => [ "InterfaceName", "[eventlog][interface_name]" ]
  33. rename => [ "IpAddress", "ip" ]
  34. rename => [ "IpPort", "port" ]
  35. rename => [ "Key", "[eventlog][key]" ]
  36. rename => [ "LogonGuid", "[eventlog][logon_guid]" ]
  37. rename => [ "Message", "message" ]
  38. rename => [ "ModifyingUser", "[eventlog][modifying_user]" ]
  39. rename => [ "NewProfile", "[eventlog][new_profile]" ]
  40. rename => [ "OldProfile", "[eventlog][old_profile]" ]
  41. rename => [ "Port", "port" ]
  42. rename => [ "PrivilegeList", "[eventlog][privilege_list]" ]
  43. rename => [ "ProcessID", "pid" ]
  44. rename => [ "ProcessName", "[eventlog][process_name]" ]
  45. rename => [ "ProviderGuid", "[eventlog][provider_guid]" ]
  46. rename => [ "ReasonCode", "[eventlog][reason_code]" ]
  47. rename => [ "RecordNumber", "[eventlog][record_number]" ]
  48. rename => [ "ScenarioId", "[eventlog][scenario_id]" ]
  49. rename => [ "Severity", "level" ]
  50. rename => [ "SeverityValue", "[eventlog][severity_code]" ]
  51. rename => [ "SourceModuleName", "nxlog_input" ]
  52. rename => [ "SourceName", "[eventlog][program]" ]
  53. rename => [ "SubjectDomainName", "[eventlog][subject_domain_name]" ]
  54. rename => [ "SubjectLogonId", "[eventlog][subject_logonid]" ]
  55. rename => [ "SubjectUserName", "[eventlog][subject_user_name]" ]
  56. rename => [ "SubjectUserSid", "[eventlog][subject_user_sid]" ]
  57. rename => [ "System", "[eventlog][system]" ]
  58. rename => [ "TargetDomainName", "[eventlog][target_domain_name]" ]
  59. rename => [ "TargetLogonId", "[eventlog][target_logonid]" ]
  60. rename => [ "TargetUserName", "[eventlog][target_user_name]" ]
  61. rename => [ "TargetUserSid", "[eventlog][target_user_sid]" ]
  62. rename => [ "ThreadID", "thread" ]
  63. }
  64. mutate {
  65. remove_field => [
  66. "CurrentOrNextState",
  67. "Description",
  68. "EventReceivedTime",
  69. "EventTime",
  70. "EventTimeWritten",
  71. "IPVersion",
  72. "KeyLength",
  73. "Keywords",
  74. "LmPackageName",
  75. "LogonProcessName",
  76. "LogonType",
  77. "Name",
  78. "Opcode",
  79. "OpcodeValue",
  80. "PolicyProcessingMode",
  81. "Protocol",
  82. "ProtocolType",
  83. "SourceModuleType",
  84. "State",
  85. "Task",
  86. "TransmittedServices",
  87. "Type",
  88. "UserID",
  89. "Version"
  90. ]
  91. }
  92. }
  93. }

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文