我的ELK搭建笔记(Windows日志收集)

我的ELK搭建笔记

(Windows 日志收集)

M目录预览

        1、需求说明

        2、Winlogbeat工具介绍

        3、安装部署 

            3.1 下载

            3.2 配置

            3.3 安装

            3.4 启动

        4、验证

        5、性能

        6、维护

        7、Troubleshooting

1

需求说明

收集和存储Windows AD服务器关键系统日志,应对安全审计要求。

基于Windows账户登录日志进行安全事件分析。

2

Winlogbeat工具介绍

Elasticsearch官方提供的轻量级Windows事件日志转发代理。

日志数据流:Winlogbeat ---> Logstash ---> Elasticsearch

采取这样的部署方式是基于如下考虑:

Windows 服务器部署后就不需要再做任何变更了(毕竟是线上AD服务器,隔三差五去动配置要掉脑袋的!)

如果对默认 Window 日志映射不满意,可以在 logstash 上重新调整

3

安装部署

3.1 下载

官方地址:

下载Winlogbeat压缩包,解压后部署在Windows Server 2008 R2服务器的目录。程序主目录【C:\Program Files\winlogbeat\】,效果如下:

3.2 配置

编辑文件【winlogbeat.conf】,设置日志收集参数、转发服务器参数等。

C:\Program Files\winlogbeat\winlogbeat.yml 

# The supported keys are name (required), tags, fields, fields_under_root,

# forwarded, ignore_older, level, event_id, provider, and include_xml. Please

# visit the documentation for the complete details of each option.

#

#  收集三类日志:Application/Security/System,72小时前的日志忽略。以下默认,无需修改

winlogbeat.event_logs:

  - name: Application

    ignore_older: 72h

  - name: Security

  - name: System

 

# 注释所有Elasticsearch相关的配置参数

#-------------------------- Elasticsearch output ------------------------------

#output.elasticsearch:

  # Array of hosts to connect to.

  #hosts: ["localhost:9200"]

  # Optional protocol and basic auth credentials.

  #protocol: "https"

  #username: "elastic"

  #password: "changeme"

 

# 配置Logstash相关参数,默认只需要配置hosts

#----------------------------- Logstash output --------------------------------

output.logstash:

  # The Logstash hosts

  hosts: ["1.1.1.1:5044"]

其中1.1.1.1时远程logstash服务器的IP地址,实际部署时请设置为正确的IP参数。

请确保防火墙策略允许Windows AD服务器能够访问到logstash服务器IP的TCP5044端口。

3.3 安装

启动powershell工作台:

切换到【C:\Program Files\winlogbeat\】

执行命令【.\install-service-winlogbeat.ps1】安装服务。

3.4 启动

命令行执行【net start winlogbeat】;

启动日志收集代理服务。

4

验证

本地确认winlogbeat服务工作正常

程序自身日志正常

远程logstash工作正常

Kibana能搜索到Windows日志

5

性能

在没有日志产生的情况下,winlogbeat进程工作内存9M,有日志产生的情况下,小于100M内存。

6

维护

Windows Service维护 

;启动服务

net start winlogbeat

;停止服务

net stop winlogbeat

;卸载服务

powershell "C:\Program Files\winlogbeat\uninstall-service-winlogbeat.ps1"

7

Troubleshooting

某些Windows Server服务器默认是禁止启用powershell的,因此安装过程可能会遇到如下问题。

无法加载文件 C:\Program Files\winlogbeat\install-service-winlogbeat.ps1,因为在此系统中禁止执行脚本。有关详细信息,请参阅 "get-help about_signing"。

所在位置 行:1 字符: 33

+ .\install-service-winlogbeat.ps1 <<<<

+ CategoryInfo          : NotSpecified: (:) [], PSSecurityException

+ FullyQualifiedErrorId : RuntimeException

针对该异常情况,建议:

临时降低powershell执行检查要求,允许执行非签名的shell文件

安装部署winlogbeat

还原powershell执行安全配置

在powershell中全流程操作如下:

PS C:\Users\Administrator> cd "C:\Program Files\winlogbeat"

PS C:\Program Files\winlogbeat> set-executionpolicy remotesigned

PS C:\Program Files\winlogbeat> .\install-service-winlogbeat.ps1

PS C:\Program Files\winlogbeat> net start winlogbeat

PS C:\Program Files\winlogbeat> set-executionpolicy restricted

__ !!! 重 要 声 明 !!! __

唯品会安全应急响应中心VSRC(官网:)是唯一接收唯品会安全漏洞的平台,唯品会从未授予任何第三方机构或个人接收唯品会相关安全漏洞,任何个人或机构若在第三方平台提交唯品会相关安全漏洞,一切后果自负。

且在必要情况下,我们将会以相关法律手段予以处理,若有任何问题,请随时联系我们。

点击阅读上篇精彩分享《我的ELK搭建笔记(阿里云上部署)》