--- tags: 流量監控作業程序 --- # 告警正規化及欄位存取格式 ## 告警日誌正規化 當觸發流量偵測規則產生了告警日誌(json格式),以tail的方式將日誌資料一筆一筆導入Fluentd進行處裡 ``` <source> @type tail path /fluentd/suricata/eve*.json pos_file /fluentd/Buffers/suricata.pos @label @SURICATA tag suricata <parse> @type json </parse> </source> ``` 插入額外所需的欄位及欄位值{key value} - log_time 日誌產生的時間(此處為抓取timestamp時間再將之切換格式輸出) - _log_type Traffic - module 隸屬於之模組 - dump_status 0 - ticket 0 ``` <filter **> @type record_transformer auto_typecast true enable_ruby true <record> log_time ${Time.strptime(record["timestamp"], "%Y-%m-%dT%H:%M:%S.%N%z").strftime('%Y-%m-%dT%H:%M:%S.%N%:z')} _log_type traffic module suricata dump_status 0 ticket 0 </record> </filter> ``` 正規化後的資料傳送至Elasticsearch中名為(suricata-西元-月)的index 緩衝區設定上限為5G,每塊上限為15MB,為其30秒進行一次沖洗週期 ``` <match **> @type elasticsearch host localhost port 19200 index_name suricata-%Y-%m include_timestamp true reload_on_failure true reconnect_on_error true with_transporter_log true reload_connections false request_timeout 15s pipeline my_timestamp_pipeline suppress_type_name true <buffer time> @type file timekey 1d flush_mode interval flush_interval 30s retry_max_interval 30s path /fluentd/Buffers/ES_Buffers/suricata chunk_limit_size 15M total_limit_size 5G # default is 64G timekey_use_utc false </buffer> </match> ``` ## 地端存取資料庫 可透過Elasicsearch-head提供的一個網頁界面提供使用者進行查詢,檢視存儲Elasticsearch的資料 ``` http://{ESM Edge IP}:19100 ``` 欄位介紹(待補)