zoukankan      html  css  js  c++  java
  • ELK之使用filebeat收集java运行日志

      安装filebeat修改配置文件/etc/filebeat/filebeat.yml

    filebeat.prospectors:
    - type: log
      enabled: true
    #日志路径
      paths:
        - /home/ekp/linux64/tomcat/logs/catalina.out
    #日志tags
      tags: [ekp-tomcat]
    #排除空行
      exclude_lines: ['^$']
    #java多行日志合并
      multiline:
        pattern: '^d{4}-d{1,2}-d{1,2}sd{1,2}:d{1,2}:d{1,2}'
        negate: true
        match: after
     
    filebeat.config.modules:
      path: ${path.config}/modules.d/*.yml
      reload.enabled: false
    setup.template.settings:
      index.number_of_shards: 3
    setup.kibana:
    #输出至logstash
    output.logstash:
      hosts: ["10.1.4.242:5044"]
    

      传输用logstash配置/etc/logstash/conf.d/beat-redis.conf 如下

    input{
        beats{
            port => 5044
        }
    }
    
    output{
        if "nginx-ekp-log" in [tags]{
            redis {
    	    host => "10.1.4.243"
      	    port => "6379"
    	    password => "123456"
     	    db => "1"
    	    data_type => 'list'
    	    key => "nginx-ekp-log"
            }
        }
        if "ekp-tomcat" in [tags]{
            redis {
    	    host => "10.1.4.243"
      	    port => "6379"
    	    password => "123456"
     	    db => "2"
    	    data_type => 'list'
    	    key => "ekp-tomcat"
            }
    	#stdout{
    	#    codec => rubydebug
    	#}
        }
    }
    

        过滤分析logstash配置/etc/logstash/conf.d/redis-elastic.conf如下

    input{
        redis {
    	host => "10.1.4.243"
    	port => "6379"
    	password => "123456"
    	db => "1"
    	data_type => "list"
    	key => "nginx-ekp-log"
        }
        redis {
    	host => "10.1.4.243"
    	port => "6379"
    	password => "123456"
    	db => "2"
    	data_type => "list"
    	key => "ekp-tomcat"
        }
    }
    
    filter{
        if "nginx-ekp-log" in [tags] {
            json {
    	source => "message"
            }
        }
        if [user_ua] != "-" {
    	useragent {
                target => "agent"
    	    source => "user_ua"
    	}
        }
        if [lan_ip] != "-" {
          geoip {
                source => "lan_ip"
                target => "geoip"
                # database => "/usr/share/GeoIP/GeoIPCity.dat"
                add_field => [ "[geoip][coordinates]", "%{[geoip][longitude]}" ]
                add_field => [ "[geoip][coordinates]", "%{[geoip][latitude]}"  ]
                }
                mutate {
                            convert => [ "[geoip][coordinates]", "float"]
                }
         }
    }
    
    output{
       if "nginx-ekp-log" in [tags] {
    	elasticsearch{
    	hosts => ["10.1.4.244:9200"]
    	index => "nginx-ekp-log-%{+YYYY.MM}"
            }
       }
       if "ekp-tomcat" in [tags] {
        elasticsearch{
        hosts => ["10.1.4.244:9200"]
        index => "ekp-tomcat-%{+YYYY.MM}"
        }
       }
    
     # stdout{
     #      codec => rubydebug
     #   }
    }
    

      启动filebeat,logstash即可把java日志多行合并进行收集

      

  • 相关阅读:
    CTF---隐写术入门第二题 小苹果
    文件上传
    文件读取
    sqlmap之绕过waf思路
    【小技巧分享】如何通过微博图片进行社工Po主
    Windows 11恢复传统右键菜单-2021.10.5正式版
    sql注入之Oracle注入
    CTF之buuctf
    常见sql注入payload
    信息收集之Github
  • 原文地址:https://www.cnblogs.com/minseo/p/10069215.html
Copyright © 2011-2022 走看看