Nginx访问日志和错误日志的拆分(Logstash)
2024-09-04 09:42:47
>> from zhuhaiqing.info
input {
file {
type =>> "nginx-access"
path =>> [ "/var/log/nginx/access.log" ]
tags =>> [ "nginx","access"]
start_position =>> beginning
}
file {
type =>> "nginx-error"
path =>> [ "/var/log/nginx/error.log" ]
tags =>> [ "nginx","error"]
start_position =>> beginning
}
}
filter {
if [type] == "nginx-access" {
grok{
match =>> ["message","%{IPORHOST:client_ip}\s{1,}\-\s\-\s\[%{HTTPDATE:time}\]\s{1,}\"(?:%{WORD:verb}\s{1,}%{NOTSPACE:request}(?:\s{1,}HTTP/%{NUMBER:http_version})?|-)\" %{NUMBER:response}\s{1,}(?:%{NUMBER:bytes}|-)\s{1,}%{QS:referrer}\s{1,}%{QS:agent}"]
}
date{
match =>> ["time","dd/MMM/yyyy:HH:mm:ss Z"]
target =>> "logdate"
}
ruby{
code =>> "event.set('logdateunix',event.get('logdate').to_i)"
}
}
else if [type] == "nginx-error" {
grok {
match =>> [
"message", "(?<time>\d{4}/\d{2}/\d{2}\s{1,}\d{2}:\d{2}:\d{2})\s{1,}\[%{DATA:err_severity}\]\s{1,}(%{NUMBER:pid:int}#%{NUMBER}:\s{1,}\*%{NUMBER}|\*%{NUMBER}) %{DATA:err_message}(?:,\s{1,}client:\s{1,}(?<client_ip>%{IP}|%{HOSTNAME}))(?:,\s{1,}server:\s{1,}%{IPORHOST:server})(?:, request: %{QS:request})?(?:, host: %{QS:client_ip})?(?:, referrer: \"%{URI:referrer})?",
"message", "(?<time>\d{4}/\d{2}/\d{2}\s{1,}\d{2}:\d{2}:\d{2})\s{1,}\[%{DATA:err_severity}\]\s{1,}%{GREEDYDATA:err_message}"
]
}
date{
match=>>["time","yyyy/MM/dd HH:mm:ss"]
target=>>"logdate"
}
ruby{
code =>> "event.set('logdateunix',event.get('logdate').to_i)"
}
}
}
output{
elasticsearch{
hosts =>> ["192.168.100.10:9200"]
index =>> "logstash-nginx-%{+YYYY.MM.dd}"
}
}
最新文章
- .html(),.text()和.val()的差异总结
- 【Beta】Daily Scrum
- Cadence16.6安装破解
- JSONArray.toCollection 封装 bean 失败
- 8月1日起,这些新政将影响移动互联网产业-b
- git撤销提交到remote的commit
- hdoj 3785 寻找大富翁【优先队列+sort排序】
- eclipse如何运行maven项目
- iOS常见异常Exec_Bad_Access问题解决办法
- centos, ubuntu 上docker 安装
- 【高速接口-RapidIO】1、RapidIO协议概述
- CodeForces512C-Pluses everywhere-模拟/数学/排列组合模板
- impala系列: 时间函数
- (转)Geth控制台使用及Web3.js使用实战
- kotlin-2(IdeaIU-2018.2汉化破解)
- RobotFramework基本用法(二)
- bzoj 1590: [Usaco2008 Dec]Secret Message 秘密信息
- 用phpstudy搭建的lnmp环境下mysql授权远程连接
- 网络安全部门的漏洞扫描让你头痛不已么——PHP环境选它就可以了
- 重写ListView解决ListView内部ViewPaper滑动事件冲突问题
热门文章
- 同步mysql数据到ElasticSearch的最佳实践
- 利用JavaScript打印出Fibonacci数(不使用全局变量)
- Netty源码学习(七)FastThreadLocal
- cl编译C文件的环境变量修改
- Python的程序结构[5] ->; 模块/Module[0] ->; 内建模块 builtins
- 差分【p3948】 数据结构
- NOIP2016_day1_No1玩具谜题
- 我学MSMQ(一)
- sql server 存储过程中使用变量表,临时表的分析(续)
- 【转】MySQL5.5的my.cnf 参数详解