Splunk通过WMI远程读取Windows主机日志
Splunk通过WMI远程读取Windows主机日志
在开始之前首先要保证,安装Splunk Enterprise的主机是管理员组成员,要进行远程监控的主机是所属管理的域用户。以下操作为在安装Splunk的主机上进行。
Winodws主机上的WMI权限设置
(1)更改用户COM安全权限
在搜索菜单中,输入dcomcnfg.exe运行
更改访问权限:Component Service->Computers->My Computer->Properties->COM Security->Edit Limits
添加用户,选择要访问并收取Log的主机名。
确认添加的用户是否有Local Access和Remove Access权限
添加用户的Launch and Activation Pemissions。
确认添加的用户有Local Launch,Remote Launch,Remote Activation权限
(2)WMI权限设置
注意:如果Root->Security时有报错,请检查主机是否是管理员组成员。
在开始菜单中运行WmiMgmt.msc。WMI Control(Local)->Properties->Security->Root->Security
添加用户并确认用户权限有四个:Execute Methods,Enable Account,Remote Enable,Read Security。
根据以下图步骤选择用户的命名空间。更改为This namespace and subnamespaces.
重启计算机,已便更新设置。
(3)测试WMI是否可用
1.登录运行Splunk Enterprise的计算机。打开命令提示符(点击搜索,输入cmd),右击选择Run Administrator。修改路径为Splunk的安装路径子目录bin
。在命令行输入cd c:\Program Files\Splunk\bin
2.确定Splunk Enterprise当前存储数据的位置,命令行输入splunk show datastore-dir
,根据提示输入Splunk的用户名和密码
3.命令行输入splunk set datastore-dir %TEMP%
,修改Splunk Enterprise临时存储其数据的位置。此操作将数据存储目录设置为TEMP环境变量中指定的当前目录。可以按此格式进行修改为自定义目录。
4.重启Splunk服务。
5.测试对WMI提供程序的访问,输入代码splunk cmd splunk-wmi -wql "select * from win32_service" -namespace \\<host>\root\cimv2
,将<host>
修改为要收集日志主机的IP或主机名称。
如果数据流没有错误信息,则表明Splunk Enterprise可以连接到WMI。
如果数据流出现错误信息,可查看error="<msg>"
中描述的具体问题。
如出现一下相同字段,可以检查IP是否可以ping通;防火墙是否关闭;WMI服务是否开启;RPC服务是否正常启动。
使用Splunk Web配置远程事件日志监视
1.创建索引。点击setting->indexes
为新索引起名字,本教程的名字为wmi。
2.添加设置远程机的日志收取
转到Splunk的home界面,点击Add Date.
选择Monitor
点击Remote Event Logs
填写Event Log collection name,名字可以自行定义。Event Log collection name,需要监视得主机名或着IP都可以。点击Find logs,选择需要监视主机上可用得时间日志通道列表,可以根据实际情况进行选择。
点击Next,查看主机名是否为监视主机得主机名,修改Index为最开始创建得名字。点击Review知道完成添加数据得操作。
利用Search&Reporting来查询数据是否成功传输到splunk。host=主机名 index=索引名。如果有日志信息证明成功。到这里我们就大功告成了。