顯示具有 splunk 標籤的文章。 顯示所有文章
顯示具有 splunk 標籤的文章。 顯示所有文章

2017/02/11

今天朋友介紹graylog
稍微google了一下
看來跟之前學過的ELK是差不多的東西
都是log管理的
不過之前在上ELK課的時候安裝有點複雜
想說還是繼續用splunk好了
不過graylog網站上就直接有ova可以下來用
不用再自己花時間裝 滿方便的
現在好像愈來愈多的軟体都醬做了
省得user安裝的麻煩
於是下載回來稍微玩了一下

ovf的os是用ubuntu 登入後記得改一下密碼
另外要改的是時區 預設使用的是UTC 記得改為自己的時區

sudo cp /usr/share/zoneinfo/Asia/Taipei /etc/localtime

再來就是要改graylog的config了
因為web介面上都不能改
路徑在
/opt/graylog/conf/graylog.conf

改web登入密碼
說明是要用shasum來hash
產生後直接複制貼上

# Create one by using for example: echo -n yourpassword | shasum -a 256
# and put the resulting hash value into the following line
root_password_sha2 = 895027ffec7981a554a916e76676677ee0d5da8bf35ff1ba7f15362e35a9781a

再來改時區 參考以下連結
http://www.joda.org/joda-time/timezones.html

root_timezone = Asia/Taipei

最後改一下搜尋結果顯示高亮

allow_highlighting = true

預設會有一支java起在 udp 514來收syslog
只要在其他設備上設定往這台丟就好了

至於如果要直接吃進file的內容
在splunk是只要直接設定就好了
但graylog比較麻煩
必須要再安裝 Collector Sidecar (支援由其他的机器丟至graylog)
裝好後先修改config file

/etc/graylog/collector-sidecar/collector_sidecar.yml
把tag的地方全部mark
tags:
#    - linux
#    - apache

然後再設定
操作流程請參考官方文件

http://docs.graylog.org/en/2.1/pages/collector_sidecar.html#graylog-collector-sidecar
http://docs.graylog.org/en/2.1/pages/sending_data.html

要注意的是input file 好像不能使用* 要一個一個指定

當log量大但hd容量不夠想限制儲存天數時
在管理介面上 system - indices - Edit
調整數量













在graylog.conf加上以下參數(依需求而定)

elasticsearch_max_time_per_index = 1d
elasticsearch_max_number_of_indices = 180
retention_strategy = delete

https://www.digitalocean.com/community/questions/how-to-config-graylog-data-save-days

目前使用起來感覺跟splunk差不多
不過splunk還是快一點
只是splunk免費版有每天500MB的限制就是了
如果有大量log需求又不想花錢
可以考慮看看

2014/05/13

本來一直使用來統計的google map
這個apps官方只支援到5
當時升到6後必須手動安裝後才能使用
但作者也似乎沒有改版的動作
升到6.1後完全不能用了
Orz
查了一下文件
發現splunk直接提供了一個geostat的指令可以使用
不再需要google map這個app了
指令如下

* | iplocation src | geostats count

因為在我送到splunk的資料中 src 後面帶的是攻擊者的ip
如果是使用其他字串
請自行修改

2014/03/23

一直以來user打電話來詢問網路狀況的時候都會先到splunk去查帳號跟ip 的對應
之後到到LP去查詢該ip 是否被block
但必須要進二個系統去查
有點麻煩
今天在想有沒辦法直接在splunk就可以查到所有的資料
因此必須把lp上的資料丟到splunk上

程式如下

#!/usr/bin/python

import MySQLdb,sys

db = MySQLdb.connect(host="localhost", user="root", passwd="123456", db="test")
cursor = db.cursor()

#cursor.execute("select StartTime,SourceHost,Cause,ReleaseTime from  BlockItem order by StartTime")
cursor.execute("select StartTime,SourceHost,Cause,ReleaseTime from  BlockItem where StartTime between date_add(now(), interval - 5 minute) and now()")
result = cursor.fetchall()
if result:
        for record in result:
                print record[0],
                print "ip=",
                sys.stdout.softspace=0
                print record[1],
                print record[2],
                print record[3]
db.close()

重點在where StartTime between date_add(now(), interval - 5 minute) and now()
每次取出這個時間點往回算5min的資料
以避免splunk重複地計入

2013/10/21

之前在測試 splunk的geo

但因為使用的是enterprise的測試key
最近license 到期了
導致無法使用
轉成free license也沒用
所以再來重裝一次
但目前的最近版本是6
裝完後直接改用free license
免的到時又有問題
直接從splunk app去找也找不到google map
到了官方網站去看
寫的是只支援到5
想說不然下載原始檔用手動裝看看可不可以用
試了後竟然ok了
先醬用囉