当前位置 : 主页 > 操作系统 > centos >

ELK监控Windows事件日志+Grafana展示

来源:互联网 收集:自由互联 发布时间:2022-06-20
ELK监控Windows事件日志+Grafana展示 ​ 这里介绍使用Winlogbeat+Logstash+Grafana展示windows安全日志,由于数据量不大,没有采用Redis缓存,数据由Winlogbeat直接传输到Logstash进行数据过滤,再发送

ELK监控Windows事件日志+Grafana展示

image20210708153039747.png

​ 这里介绍使用Winlogbeat+Logstash+Grafana展示windows安全日志,由于数据量不大,没有采用Redis缓存,数据由Winlogbeat直接传输到Logstash进行数据过滤,再发送到Elasticsearch存储,使用Grafana数据展示

组件如下:

  • Winlogbeat:Beats内的轻量化采集组件,可以方便采集Windows的应用程序、安全、系统日志,可参考Winlogbeat官方文档
  • Logstash:数据过滤组件,里面有丰富的插件,主要包括三个模块:Input(数据输入),Filter(数据过滤),Output(数据输出),可参考Logstash官方文档
  • Elasticserch:全文索引搜索+存储引擎,java写的,暂未详细了解,可参考Elasticsearch官方文档
  • Kibana:可视化平台,可展示、检索、管理Elasticsearch中的数据。参考Kibana官方文档
  • Grafana:可视化平台,能接入不同的数据源,进行数据图表展示,由于比较熟悉grafana,这里采用grafana进行展示。参考Grafana官方文档

Grafana效果展示

image20210708164331129.png

一、安装ELK

参考 Elasticsearch+Logstash+Kibana+Head安装

二、安装Winlogbeat

下载Winlogbeat

Winlogbeat官网下载

image20210707160553792.png

修改Winlogbeat.yml
# ======================== Winlogbeat specific options ========================= Winlogbeat.event_logs: # - name: Application # - name: System - name: Security #这里只抓取安全日志 ignore_older: 72h #第一次抓取过去72h内的日志 event_id: 4624,4625,4648,4649,4720,4722,4723,4724,4725,4726,4738,4740,4727,4737,4739,4762 # 只抓取以上事件ID的日志 #fields: # type: "winlog_security" # log_topic: "winlog_security" #fields_under_root: true processors: - script: lang: javascript id: security file: ${path.home}/module/security/config/Winlogbeat-security.js # ====================== Elasticsearch template settings ======================= setup.template.settings: index.number_of_shards: 1 # ================================= Dashboards ================================= #setup.dashboards.enabled: false #setup.dashboards.url: # =================================== Kibana =================================== setup.kibana: setup.dashboards.enabled: true setup.dashboards.index: "winlog_security-*" host: "SERVER IP:5601" username: "USERNAME" password: "PASSWORD" # ================================== Outputs =================================== # ---------------------------- Elasticsearch Output ---------------------------- #output.elasticsearch: # hosts: ["SERVER IP:9200"] # indices: # - index: "winlog_security-%{+yyyy.MM.dd}" # Authentication credentials - either API key or username/password. #api_key: "id:api_key" #username: "USERNAME" #password: "PASSWORD" # ------------------------------ Logstash Output ------------------------------- output.logstash: # The Logstash hosts hosts: ["192.168.0.170:6515"] # ================================= Processors ================================= processors: - add_host_metadata: when.not.contains.tags: forwarded - add_cloud_metadata: ~
文件夹移动至C:\Program Files,并重命名为Winlogbeat

image20210708154144025.png

管理员打开powershell
PS C:\Windows\system32> cd 'C:\Program Files\Winlogbeat' PS C:\Program Files\Winlogbeat> .\install-service-winlogbeat.ps1

安装完成后提示

image20210708155533498.png


​ 如果弹出无法安装提示

image20210708155337100.png

​ 需要运行以下命令安装

​ PowerShell.exe -ExecutionPolicy UnRestricted -File .\install-service-winlogbeat.ps1


测试配置文件

.\winlogbeat.exe setup -e

开启服务

Start-Service winlogbeat

image20210708160346403.png

三、配置Logstash

vim /opt/logstash/config/winlog-security.conf

# ---------------input 输入模块----------------------- input{ beats{ #winlogbeat为数据源,使用beats插件 type => "winlog_security" #输入数据打上winlog_security 类型 host => "0.0.0.0" #接收任意主机数据 port => 6515 #定义端口,需和采集器配置一致 codec => plain{ charset => "UTF-8" } } } # ---------------filter 过滤模块----------------------- filter{ if [type] == "winlog_security" { #此文件的数据源才过滤处理 date{ match => ["event.time","dd/MMM/yyyy:HH:mm:ss Z"] } ruby{ code => "event.set('event.time', event.get('@timestamp').time.localtime + 8*60*60)" } mutate{ #删除不需要的字段 copy => {"[@metadata][ip_address]" => "serverip"} copy => {"[log][level]" => "severity_label"} remove_field => ["[agent]","@version","[process]","tags"] remove_field => ["task","api","keywords","record_id"] remove_field => ["[ecs]","[log]","[winlog_channel]"] remove_field => ["[keywords]","provider_guid"] remove_field => ["[os]","opcode","id","related","kind","message","[event]"] } if ([winlog][event_data][LogonType] == "3") { #由于只是需要用户安全登录日志,将一些系统的登录日志删除 drop {} } if ([winlog][event_data][LogonType] == "5") { drop {} } if ([user][domain] == "Window Manager") { drop {} } } } # ---------------output 输出模块----------------------- output{ if [type] == "winlog_security" { elasticsearch { #输出到es hosts => ["192.168.0.170:9200"] user => "elastic" password => "PASSWORD" index => "winlog_security-%{+yyyy.MM.dd}" #创建索引 } } }

四、配置kibana

登录kibana

http://192.168.0.170:5601/

创建索引模式

image20210708162810158.png

image20210708162852171.png

image20210708162930324.png

image20210708163401902.png

image20210708163426479.png

创建完成后,在Discover就可以看得刚创建的索引

image20210708163450220.png

image20210708163932156.png

五、Grafana展示

参考 Grafana安装

添加数据源

image20210708164910450.png

image20210708165005025.png

绘制图表-登录状态

image20210708165122539.png

绘制图标-登录失败top10

image20210708165207804.png

绘制图标-最新日志

image20210708165406737.png

image20210708165454337.png

其他图表类似,最后展示如下

image20210708164331129.png

上一篇:ELK监控IIS-Web日志+Grafana展示
下一篇:没有了
网友评论