zoukankan      html  css  js  c++  java
  • logstash 收集nginx 日志 windows

    nginx 配置:

        log_format  main  'remote_user=$remote_user&ip=$remote_addr&real_ip=$http_x_forwarded_for&log_time=$time_local&request_time=$request_time&host=$http_host&$args&status=$status&body_bytes_sent=$body_bytes_sent&referer=$http_referer&user_agent=$http_user_agent&forwarded_for=$http_x_forwarded_for';
                            
    
        access_log  logs/access.log  main;
    

      

     location = /s.gif {    
                empty_gif;
            }
    

    logstash 配置:

    input {
    
        file{
                path => "E:/test/nginx-1.18.0/logs/access.log"
                start_position => "beginning"
                stat_interval => "2"
    
            }
    
    
    }
    
    filter{
       urldecode{
          field => message
       } 
       kv{
          field_split => "&"
       }
      }
    
    output {
        jdbc {
          # 配置数据库信息
          connection_string => "jdbc:mysql://localhost:3306/logstash_test?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai"
          driver_class => "com.mysql.cj.jdbc.Driver"
          username => "root"
          password => "123456"
       
          driver_jar_path => "E:/test/logstash-7.14.2/mysql/mysql-connector-java-8.0.25.jar"
    
          statement => ["insert into log_coll(timestamp,args,remote_addr,name,age) VALUES(?,?,?,?,?)", "timestamp","user_agent","remote_addr","name","age"]
    
        }
        stdout {
         codec => rubydebug
       }
    }
    

      

  • 相关阅读:
    oracle查看所有角色
    jQuery 异步提交表单实例解析
    oracle查看用户系统权限
    js中日期操作大全
    oracle 查询用户下所有表
    JS语法字典
    JS定时器例子讲解
    开源软件
    rpm的使用
    lvs+keepalived和haproxy+heartbeat区别
  • 原文地址:https://www.cnblogs.com/chen-msg/p/15329494.html
Copyright © 2011-2022 走看看