91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

Logstash將解析的日志插入MySQL數據庫

發布時間:2020-08-08 04:12:22 來源:網絡 閱讀:544 作者:rong341233 欄目:系統運維

1.首先Logstash需要安裝logstash-output-jdbc插件(以下方式基于docker)
Dockerfile如下:

FROM logstash:7.4.0
RUN sed -i 's#https://rubygems.org#https://gems.ruby-china.com#g' Gemfile && logstash-plugin install logstash-output-jdbc

2.解析nginx日志

        date {
                match => ["timestamp", "dd/MMM/yyyy:HH:mm:ss Z"]   #解析時間
        }
        urldecode {
                field => "Http_Request"     #請求日志轉為中文
        }
        geoip {     #獲取IP插件
                database => "/usr/share/logstash/geodb/GeoLite2-City.mmdb"
                source => "Client_IP"
                target => "geoip"
                fields => ["country_name","region_name", "city_name", "ip", "longitude", "latitude", "location"]
                add_field => [ "[geoip][coordinates]", "%{[geoip][longitude]}" ]
                add_field => [ "[geoip][coordinates]", "%{[geoip][latitude]}"  ]
        } 
        useragent {   #解析用戶瀏覽器特征
                source => "User_Agent"
                target => "ua"
        }
        mutate {     #日志必要處理
                convert => [ "[geoip][coordinates]", "float" ]
                convert => [ "Http_Status_Code", "integer" ]
                convert => [ "Http_Bytes", "integer" ]
                convert => [ "Request_Time", "float" ]
                convert => [ "Upstream_Response_Time", "float" ]
                remove_field => [ "beat", "@version", "auth", "prospector", "source", "offset"]
                gsub =>["timestamp","\ \+0800",""]    #將時間的+0800進行刪除
                gsub =>["User_Agent","\"",""]  #將瀏覽器的雙引號去除

        }
output {
        jdbc {
                connection_string => "jdbc:mysql://mysql/elk?user=root&password=123456&useUnicode=true&characterEncoding=UTF8"
                driver_jar_path => "/usr/share/logstash/geodb/mysql-connector-java-8.0.18.jar"    #主意加載mysql連接器
                statement => ["INSERT INTO nginx_access_log(Client_IP,X_Forwarded_For,time,App_Version,Device,Device_Name,System_Version,Http_Method,Site,Http_Request,Http_Status_Code,Http_Referrer,Usercode,NetType,Openudid,Request_Time,Upstream_Response_Time,User_agent,city,province) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)","Client_IP","X_Forwarded_For","timestamp","App_Version","Device","Device_Name","System_Version","Http_Method","Site","Http_Request","Http_Status_Code","Http_Referrer","Usercode","NetType","Openudid","Request_Time","Upstream_Response_Time","User_Agent","[geoip][city_name]","[geoip][region_name]"]
#此處注意,比如需要插入城市信息[geoip][city_name]
        }
}               
向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

临夏县| 健康| 水城县| 曲沃县| 武隆县| 淮南市| 高雄县| 健康| 夏河县| 沁源县| 怀来县| 天峻县| 枣强县| 临城县| 平罗县| 广东省| 遂平县| 洛隆县| 丹江口市| 谷城县| 金堂县| 林口县| 玛曲县| 平舆县| 奇台县| 陆丰市| 贡山| 马山县| 太原市| 海宁市| 衡山县| 大港区| 即墨市| 汨罗市| 灌云县| 天全县| 聂拉木县| 伊金霍洛旗| 永年县| 田东县| 招远市|