暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

ELK 监控交换机日志(以华为交换机为例)

菜鸟运维笔记 2019-07-05
2455

大概思路

huawei switch :

ELK :

logstash:


大概思路

交换机日志----> 服务器---->服务器rsyslog设置指定存储路径文件--->随后就跟elk 监控本机日志一样了

huawei switch 端操作:

#指定发送消息基本,表示从0-7都发送
info-center source default channel 2 log level debugging
#指定从哪个接口发送
info-center loghost source Vlanif1
#指定远程 ELK 服务器ip
info-center loghost 192.168.1.137


ELK ELK 监控交换机日志(以华为交换机为例)端操作 :

修改系统日志的配置文件

vim /etc/rsyslog.conf
#启用udp 514端口监听。
$ModLoad imudp
$UDPServerRun 514



#把来自两个交换机的日志分别放入到指定的log文件中。

:fromhost-ip,isequal, "192.168.1.88"               /var/log/huawei/route.log
:fromhost-ip,isequal, "192.168.1.xx" /var/log/huawei/xxxx.log


#重启rsyslog服务

systemctl restart rsyslog


logstash 端操作:

编辑配置文件

vim /etc/logstash/conf.d/testroute.conf 
input {
syslog {
type => "/var/log/huawei/route.log"
port => 10515
}
}
output {
#stdout {
# codec => rubydebug
#}
elasticsearch {
hosts => ["192.168.1.137:9200"]
index => "test-route-%{+YYYY.MM}"
}
}


修改系统日志的配置文件

vim /etc/rsyslog.conf
#### RULES ####
*.* @@192.168.1.137:10515


重启下日志服务

systemctl restart rsyslog


运行配置文件

/usr/share/logstash/bin/logstash --path.settings /etc/logstash -f /etc/logstash/conf.d/testroute.conf &


稍等大概2-3分钟出现一下内容

[root@lanjing3 conf.d]# /usr/share/logstash/bin/logstash --path.settings /etc/logstash -f /etc/logstash/conf.d/testroute.conf 
Sending Logstash logs to /var/log/logstash which is now configured via log4j2.properties
[2019-01-25T09:35:53,202][WARN ][logstash.config.source.multilocal] Ignoring the 'pipelines.yml' file because modules or command line options are specified
[2019-01-25T09:35:53,282][INFO ][logstash.runner ] Starting Logstash {"logstash.version"=>"6.5.2"}
[2019-01-25T09:36:03,249][INFO ][logstash.pipeline ] Starting pipeline {:pipeline_id=>"main", "pipeline.workers"=>1, "pipeline.batch.size"=>125, "pipeline.batch.delay"=>50}
[2019-01-25T09:36:04,986][INFO ][logstash.outputs.elasticsearch] Elasticsearch pool URLs updated {:changes=>{:removed=>[], :added=>[http://192.168.1.137:9200/]}}
[2019-01-25T09:36:05,966][WARN ][logstash.outputs.elasticsearch] Restored connection to ES instance {:url=>"http://192.168.1.137:9200/"}
[2019-01-25T09:36:06,205][INFO ][logstash.outputs.elasticsearch] ES Output version determined {:es_version=>6}
[2019-01-25T09:36:06,227][WARN ][logstash.outputs.elasticsearch] Detected a 6.x and above cluster: the `type` event field won't be used to determine the document _type {:es_version=>6}
[2019-01-25T09:36:06,321][INFO ][logstash.outputs.elasticsearch] New Elasticsearch output {:class=>"LogStash::Outputs::ElasticSearch", :hosts=>["//192.168.1.137:9200"]}
[2019-01-25T09:36:06,408][INFO ][logstash.outputs.elasticsearch] Using mapping template from {:path=>nil}
[2019-01-25T09:36:06,474][INFO ][logstash.outputs.elasticsearch] Attempting to install template {:manage_template=>{"template"=>"logstash-*", "version"=>60001, "settings"=>{"index.refresh_interval"=>"5s"}, "mappings"=>{"_default_"=>{"dynamic_templates"=>[{"message_field"=>{"path_match"=>"message", "match_mapping_type"=>"string", "mapping"=>{"type"=>"text", "norms"=>false}}}, {"string_fields"=>{"match"=>"*", "match_mapping_type"=>"string", "mapping"=>{"type"=>"text", "norms"=>false, "fields"=>{"keyword"=>{"type"=>"keyword", "ignore_above"=>256}}}}}], "properties"=>{"@timestamp"=>{"type"=>"date"}, "@version"=>{"type"=>"keyword"}, "geoip"=>{"dynamic"=>true, "properties"=>{"ip"=>{"type"=>"ip"}, "location"=>{"type"=>"geo_point"}, "latitude"=>{"type"=>"half_float"}, "longitude"=>{"type"=>"half_float"}}}}}}}}
[2019-01-25T09:36:07,772][INFO ][logstash.pipeline ] Pipeline started successfully {:pipeline_id=>"main", :thread=>"#<Thread:0x51bafc66 run>"}

- MORE | 往期精彩文章 -

ELK v1 elasticsearch安装

ELK v2 kibana的安装

ELK v3 logstash收集日志以收集系统日志messages为例

网络稳定性监控利器 Smokeping


文章转载自菜鸟运维笔记,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论