简介
本文章适用于ELK的logstash 配置SNMP Trap插件,接收告警通知。
默认情况下是安装此插件的,如没有可手动安装。
一般用于网络设备。
注意此插件不支持v3版本。
参考:https://www.elastic.co/guide/en/logstash/current/plugins-inputs-snmptrap.html
配置
vim /etc/logstash/conf.d/trap.conf
input {
snmptrap {
type => "snmp-trap"
community =>"public"
port => 162
}
}
output {
elasticsearch {
hosts => ["http://192.168.0.1:9200"]
index => "snmp-trap-v2-%{+YYYY.MM}"
user => elastic
password => "songxwn.com"
}
}
# 以上示例文件中,团体名字为public,配置端口为默认的162。
注意:如果要需要解析OID,需要指定mib库yaml格式的目录。
Logstash 配置接收UDP日志
报文分析
经配置设备的SNMP Trap服务器后,分析报文不为SNMP Trap报文。
由简单的UDP报文承载告警信息,字符编码为中文编码 (GB18030)。
端口号为UDP 9000。
input {
udp {
type => "UDP-Logs"
port => 9000
codec => plain{ charset => "GB18030"
}
}