logstash 根据type 判断输出
# 更多ELK资料请访问 http://devops.taobao.com 一、配置前需要注意: 1.Use chmod to modify nginx log file privilege. E.g. chmod 664 access.log
2.Modify /etc/default/logstash => LS_USER field to change logstash user, e.g. root -------------------------------------------------------------------------- 二、logstash配置文件: input {
file {
type => "nginx-access"
path => "/var/nginx/access.log" # MODIFY REQUIRED! point to nginx access.log file
start_position => beginning # read file from beginning, instead of from end as default
ignore_older => 0 # do not ignore old file
}
file {
type => "nginx-error"
path => "/var/nginx/error.log" # MODIFY REQUIRED! point to nginx error.log file
start_position => beginning
ignore_older => 0
}
} filter {
# separate parsing for nginx access and error log
if [type] == "nginx-access" {
# default nginx access log pattern (nginx 1.4.6). You may change it if it doesn't fit
grok {
match => { "message" => "%{COMBINEDAPACHELOG}+%{GREEDYDATA:extra_fields}" }
}
} else if [type] == "nginx-error" {
# default nginx error log pattern (nginx 1.4.6). You may change it if it doesn't fit (but ensure "clientip" field)
grok {
match => [ "message" , "(?<timestamp>%{YEAR}[./-]%{MONTHNUM}[./-]%{MONTHDAY}[- ]%{TIME}) \[%{LOGLEVEL:severity}\] %{POSINT:pid}#%{NUMBER}: %{GREEDYDATA:errormessage}(?:, client: (?<clientip>%{IP}|%{HOSTNAME}))(?:, server: %{IPORHOST:server}?)(?:, request: %{QS:request})?(?:, upstream: (?<upstream>\"%{URI}\"|%{QS}))?(?:, host: %{QS:request_host})?(?:, referrer: \"%{URI:referrer}\")?"]
}
} # add geo-location info
geoip {
source => "clientip"
}
} output {
# output to local Elasticsearch server as index, separated by log type and date
elasticsearch {
hosts => ["127.0.0.1"]
index => "%{type}-%{+YYYY.MM.dd}"
}
} -------------------------------------------------------------------------- github地址:https://github.com/adventure-yunfei/ELK-for-nginx-log
logstash 根据type 判断输出的更多相关文章
- logstash 通过type判断
[elk@zjtest7-frontend type]$ cat input.conf input { file { type => "type_a" path => ...
- Logstash type来标记事件类型,通过type判断
/*************** 根据type判断 input { file { type => "zj_frontend_access" path => [" ...
- logstash收集的日志输出到elasticsearch中
logstash收集的日志输出到elasticsearch中 一.需求 二.实现步骤 1.编写pipeline文件 1.`elasticsearch`配置参数解析: 2.可能会报的一个异常 2.准备测 ...
- 浏览器解析js和type判断数据类型
### 浏览器解析: - 1.当浏览器(内核.引擎)解析和渲染js的时候,会给js提供一个运行的环境,这个环境叫做“全局作用域(后端global / 客服端window scope)” - 2.代码自 ...
- ThinkPHP 模板判断输出--Switch 标签
ThinkPHP 模板引擎支持 switch 判断,根据不同情况输出不同的值,格式如下:<switch name="变量名" > <case value=& ...
- 类型(type)判断
windows下源文件编码问题 在windows下不要直接右击桌面创建.txt再改成.c,这种方式容易引起编码问题 windows下gvim的设置: 先打开gvim再用:w newfile.c这种方式 ...
- Python中为什么推荐使用isinstance来进行类型判断?而不是type
转自:http://www.xinxingzhao.com/blog/2016/05/23/python-type-vs-isinstance.html Python在定义变量的时候不用指明具体的的类 ...
- type,isinstance判断一个变量的数据类型
type,isinstance判断一个变量的数据类型 import types type(x) is types.IntType # 判断是否int 类型 type(x) is types.Strin ...
- logstash输出到elasticsearch多索引
目标:将json格式的两类日志输出到elasticsearch两类索引 1. 安装logstash. 2. 编写logstash处理配置文件,创建一个test.conf文件,内容如下: input { ...
随机推荐
- yii2不用composer使用redis
1.下载redis https://github.com/yiisoft/yii2-redis 2.下载解压放到 basic\vendor\yiisoft\yii2-redis 3.编辑文件: bas ...
- 翻译题(map使用)
What Are You Talking About 点我 Problem Description Ignatius is so lucky that he met a Martian yesterd ...
- C#中委托和事件
目 录 将方法作为方法的参数 将方法绑定到委托 更好的封装性 限制类型能力 范例说明 Observer 设计模式简介 实现范例的Observer 设计模式 .NET 框架中的委托与事件 为什么委托定义 ...
- activity 的返回按钮
http://www.2cto.com/kf/201210/160251.html 连续点击两次程序就退出程序,这是一个很有趣的程序功能,下来介绍一下我的实现方式(欢迎大家拍砖指点): 1.在Ac ...
- [置顶] access函数-linux
表头文件 #include<unistd.h> 定义函数 int access(const char * pathname, int mode); 函数说明 检查是否可以读/写某一已存在的 ...
- cf459C Pashmak and Buses
C. Pashmak and Buses time limit per test 1 second memory limit per test 256 megabytes input standard ...
- linux脚本之简单实例
利用脚本计算10的阶乘 简单说明一下: #!/bin/bash说明该shell使用的bash shell程序.这一句不可少for i in `seq 1 10`还可以写成for i in 1 2 3 ...
- UVA 400 Unix ls by sixleaves
题目其实很简单,答题意思就是从管道读取一组文件名,并且按照字典序排列,但是输入的时候按列先输出,再输出行.而且每一行最多60个字符.而每个文件名所占的宽度为最大文件名的长度加2,除了输出在最右边的文件 ...
- VMware Workstation虚拟机使用ISO映像文件
VMware Workstation虚拟机使用ISO映像文件 VMware Workstation虚拟机使用ISO映像文件
- hdu 5570 balls(期望好题)
Problem Description There are n balls with m colors. The possibility of that the color of the i-th b ...