• ELK 收集交换机日志(以华为交换机为例)


    大概思路
      交换机日志----> 服务器---->服务器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 :
    修改系统日志的配置文件
    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>"}
     
  • 相关阅读:
    Spring知识整理
    业务开发(四)—— 服务器
    TCP/IP协议知识整理
    XSS
    Java并发编程(一) —— 线程
    业务开发(三)—— 前端
    Effective Java——(一)创建和销毁对象
    Java编程思想——异常
    Git使用
    网络基础(一)
  • 原文地址:https://www.cnblogs.com/xuewenlong/p/12857602.html
Copyright © 2020-2023  润新知