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
       }
    }
    

      

  • 相关阅读:
    委托示例一则
    JQuery学习笔记(3)JQuery中的DOM操作
    JQuery学习笔记(2)JQuery选择器
    把.net的web开发补起来,徐图之
    今天把swagger补了一下
    Azure Cosmos DB Core (SQL)
    wcf callback channel问题多多
    gitlab安装
    Kubernetes
    搜索功能实现
  • 原文地址:https://www.cnblogs.com/chen-msg/p/15329494.html
Copyright © 2011-2022 走看看