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需求又不想花錢
可以考慮看看

沒有留言: