背景:
Ossec安裝后用了一段時間的analogi作為ossec的報警信息顯示平台,但是查看報警分類信息、
以及相關圖標展示等方面總有那么一點點的差強人意,難以分析。因此使用逼格高一點的splunk作為
日志分析平台就變得很有必要了。
操作:
一、ossec服務端配置
(1)配置ossec數據轉發至splunk監聽端口
[root@localhost html]# vim /opt/ossec/etc/ossec.conf
在<ossec_config>標簽下添加<syslog_output>,內容如下,
其中server標簽的IP為接受syslog記錄的服務端,即安裝splunk服務的主機IP。
端口為splunk的本地監聽端口。
<syslog_output> <server>192.168.129.134</server> <port>10002</port> </syslog_output>
(2)使syslog_output模塊生效並重啟ossec服務端。
[root@localhost html]# /opt/ossec/bin/ossec-control enable client-syslog
[root@localhost html]# /opt/ossec/bin/ossec-control restart
二、下載並安裝splunk
(1)從官網下載splunk(需注冊),下載文件為splunklight-6.4.2-00f5bb3fa822-linux-2.6-x86_64.rpm
(2)安裝splunk:rpm -Uvh splunklight-6.4.2-00f5bb3fa822-linux-2.6-x86_64.rpm
[root@localhost Desktop]# rpm -Uvh splunklight-6.4.2-00f5bb3fa822-linux-2.6-x86_64.rpm warning: splunklight-6.4.2-00f5bb3fa822-linux-2.6-x86_64.rpm: Header V4 DSA/SHA1 Signature, key ID 653fb112: NOKEY Preparing... ################################# [100%] Updating / installing... 1:splunk-6.4.2-00f5bb3fa822 ################################# [100%] complete
(3)啟動splunk:# /opt/splunk/bin/splunk start (啟動時會詢問是否同意許可,輸入y后繼續)
[root@localhost Desktop]# /opt/splunk/bin/splunk start ... ... 4. FORCE MAJEURE. Splunk will not be responsible for any failure or delay in its performance under these Terms and Conditions due to causes beyond its reasonable control, including, but not limited to, labor disputes, strikes, lockouts, shortages of or inability to obtain labor, energy, raw materials or supplies, war, acts of terror, riot, acts of God or governmental action. Do you agree with this license? [y/n]: y
... ...
Waiting for web server at http://127.0.0.1:8000 to be available... Done
If you get stuck, we're here to help.
Look for answers here: http://docs.splunk.com
The Splunk web interface is at http://127.0.0.1:8000
(4)Splunk的web接口為http://127.0.0.1:8000,嘗試訪問。
(5)首次登錄請先按着提示輸入admin/changeme后,設定新的密碼。之后的登錄信息為admin+你設定的新密碼。
(6)登錄成功
三、配置Splunk接收來自Ossec的日志轉發
(1)splunk的默認安裝路徑為/opt/splunk,編輯/opt/splunk/etc/system/local/inputs.conf文件添加以下紅色字體內容
指定的ip為ossec服務器的IP地址。
[root@localhost local]# vim /opt/splunk/etc/system/local/inputs.conf [default] host = localhost.localdomain [udp://192.168.129.128:10002] # IP address of OSSEC server disabled = false sourcetype = ossec
(2)重啟Splunk服務
# /opt/splunk/bin/splunk restart
四、Splunk數據導入
(1)導入頁面
數據已成功導入