### 設定yum源
# rpm --import
# tee /etc/yum.repos.d/elastic.repo << eof
[logstash-5.x]
name=elastic repository for 5.x packages
baseurl=
gpgcheck=1
gpgkey=
enabled=1
autorefresh=1
type=rpm-md
eof# yum install -y logstash
# tee filter.conf << eof
input
}filter
}output
}eof
# /usr/share/logstash/bin/logstash -f filter.conf --path.settings /etc/logstash
sending logstash's logs to /var/log/logstash which is now configured via log4j2.properties
the stdin plugin is now waiting for input:
12|fwd|343|dd
2017-09-18t01:35:03.342z dnode [12, fwd, 343, dd]
# tee filter.conf << eof
input
}filter
ruby
}output
}eof
# /usr/share/logstash/bin/logstash -f ruby.conf --path.settings /etc/logstash
sending logstash's logs to /var/log/logstash which is now configured via log4j2.properties
the stdin plugin is now waiting for input:
r|g2
如果想要給一串很長的字元的很多欄位都打上標籤,即多個自定義組合的情況,那麼正則必須能完全匹配整個字串(可以使用.*的方式跳過不關心的字段)
### 1. 先實現rb指令碼,輸入從變數讀取,輸出也儲存到變數
### 2. 指令碼的輸入由變數改成event.get("name")
### 3. 指令碼的輸出由變數改成event.set("name", $value)
樣例字串一[new] tcp樣例字串二
[man] name=fwd age=12#[wonmen]name=xb age=10將字串轉換成json將ruby指令碼放入logstash的filter外掛程式中### 編寫rb指令碼實現所需功能
# vim ruby.rb
$result = hash.new
$people =
begin
msgs = "[man] name=fwd age=12#[wonmen]name=xb age=10"
msgs.split("#").each
$people.push(ret)
}$result["peoples"] = $people
puts $result
end# ruby ruby.rb
, ]}
logstash實踐# vim ruby.conf
input
}filter
$people.push(ret)
}$result["peoples"] = $people
event.set("message", $result)
event.set("[@metadata][drop]", false)
rescue
puts $!
event.set("[@metadata][drop]", true)
end'
}}output
}}# /usr/share/logstash/bin/logstash -f ruby.conf --path.settings /etc/logstash
sending logstash's logs to /var/log/logstash which is now configured via log4j2.properties
the stdin plugin is now waiting for input:
[man] name=fwd age=12#[wonmen]name=xb age=10
, [1] ]}
}
關於logstash中grok外掛程式的正規表示式例子
elastic文件
elastic外掛程式文件
Logstash過濾外掛程式grok簡單測試
logstash 配置文件 vim usetime.conf input filter output 過濾正則表達示 s 呼叫.用時 異常 呼叫gz 廣州銀行 用時 usetime d usetime 251 測試的日誌 07 29 00 01 17 info b10005 15 impl.gzcl...
Logstash 參考指南(過濾器外掛程式)
過濾器外掛程式對事件執行中間處理,過濾器通常根據事件的特徵有條件地應用。下面是一些過濾器外掛程式,有關elastic支援外掛程式的列表,請參閱支援矩陣。外掛程式描述 github倉庫 aggregate 聚合來自單個任務的多個事件的資訊 logstash filter aggregate alter...
Logstash常用外掛程式
logstash外掛程式 常用的流行外掛程式 input 外掛程式 filters 外掛程式 output 外掛程式 input 外掛程式 流行的logstash輸入外掛程式 file 檔案流 檔案輸入外掛程式從輸入的內容中流事件,每個事件都被假定為單行。它會自動檢測到旋轉的旋轉並處理它。它保留了讀...