Filebeat Nginx Module 自定义字段
Filebeat Nginx Module 自定义字段
一、修改/usr/local/nginx/conf/nginx.conf中
log_format access '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for" '
'"$http_x_real_ip" "$server_addr" "$host" '
'$request_time $upstream_response_time "$upstream_addr" '
'"$time_iso8601"';
access_log /var/log/nginx/access.log access;
二、启用filebeat的nginx module
filebeat modules enable nginx
三、filebeat nginx module 增加字段
文件 /usr/share/filebeat/module/nginx/access/ingest/default.json 中
原始:
"grok": {
"field": "message",
"patterns":[
"\"?%{IP_LIST:nginx.access.remote_ip_list} - %{DATA:nginx.access.user_name} \\[%{HTTPDATE:nginx.access.time}\\] \"%{GREEDYDATA:nginx.access.info}\" %{NUMBER:nginx.access.response_code} %{NUMBER:nginx.access.body_sent.bytes} \"%{DATA:nginx.access.referrer}\" \"%{DATA:nginx.access.agent}\""
],
"pattern_definitions": {
"IP_LIST": "%{IP}(\"?,?\\s*%{IP})*"
}
修改后:
"grok": {
"field": "message",
"patterns":[
"\"?%{IP_LIST:nginx.access.remote_ip_list} - %{DATA:nginx.access.user_name} \\[%{HTTPDATE:nginx.access.time}\\] \"%{GREEDYDATA:nginx.access.info}\" %{NUMBER:nginx.access.response_code} %{NUMBER:nginx.access.body_sent.bytes} \"%{DATA:nginx.access.referrer}\" \"%{DATA:nginx.access.agent}\" \"%{DATA:nginx.access.xff}\" \"%{DATA:nginx.access.x_real_ip}\" \"%{DATA:nginx.access.server_addr}\" \"%{DATA:nginx.access.host}\" %{DATA:nginx.access.request_time} %{DATA:nginx.access.upstream_response_time} \"%{DATA:nginx.access.upstream_addr}\" \"%{DATA:nginx.access.time_iso8601}\""
],
"pattern_definitions": {
"IP_LIST": "%{IP}(\"?,?\\s*%{IP})*"
}
四、文件 /etc/filebeat/fields.yml 中
找到nginx字段配置
在
- name: agent
type: text
description: >
Contains the un-parsed user agent string. Only present if the user
agent Elasticsearch plugin is not available or not used.
后面加入
- name: xff
type: group
description: >
http_x_forwarded_for.
- name: x_real_ip
type: group
description: >
http_x_real_ip.
- name: server_addr
type: group
description: >
server_addr 服务器地址.
- name: host
type: group
description: >
host http_host http主机头.
- name: request_time
type: group
description: >
request_time 请求时间.
- name: upstream_response_time
type: group
description: >
upstream_response_time 后端响应时间.
- name: upstream_addr
type: group
description: >
upstream_addr 后端地址.
- name: time_iso8601
type: group
description: >
time_iso8601 iso8601格式时间.
五、Filebeta中 nginx 日志路径定义
在文件 /etc/filebeat/modules.d/nginx.yml 中修改日志路径
- module: nginx
# Access logs
access:
enabled: true
# Set custom paths for the log files. If left empty,
# Filebeat will choose the paths depending on your OS.
var.paths: ["/data/wwwlogs/*.log*"]
# Error logs
error:
enabled: true
# Set custom paths for the log files. If left empty,
# Filebeat will choose the paths depending on your OS.
var.paths: ["/usr/local/nginx/logs/error.log*"]
Filebeat Nginx Module 自定义字段的更多相关文章
- Emiller's Advanced Topics In Nginx Module Development
Emiller的Nginx模块开发指南 By Evan Miller DRAFT: August 13, 2009 (changes) 翻译:Kongch @2010年1月5日 0:04am -- 2 ...
- destoon模块自定义字段的添加并让其支持搜索的方法
今天看了看模块设置里的自定义字段功能的用法,试着加了个新字段glry,设置了值,然后去数据库moduleid的article表看,字段成功加上了. 于是去template下article文件夹的lis ...
- SharePoint 2013 图文开发系列之自定义字段
SharePoint使用的优势,就在于开箱即用.快速搭建,SharePoint自身为我们提供了很多字段类型,已经很丰富了.但是,在实际应用中,我们还需要一些功能特殊的字段,下面,我们简单介绍下字段的开 ...
- [SharePoint 2010] 自定义字段类型开发(二)
在SharePoint 2010中实现View Action Button效果. http://www.sharepointblogs.be/blogs/vandest/archive/2008/06 ...
- Redmine自定义字段增多后会变慢
问题: 在Redmine部署使用后,发现更新事务时速度慢,进行了相关试验,去掉了可能影响速度的插件,仍然很慢.以下为对比试验: 1.包含12个自定义字段的项目,更新用时2136ms,记录如下: Sta ...
- phpcms v9调用自定义字段的方法步骤
代码如下:{loop $shigongtu $r}<img src="{$r[url]} " title="测试"/>{/loop} 2 首页,分页 ...
- Java自定义表单、自定义字段
最近想实现用户自定义数据库中的字段,我想大部分人第一想到的就是EAV(Entity-Attribute-Value),这种方式对于写一个小的毕业设计应该还可以使用,当然也有很多CMS系统采用这种方式, ...
- sharepoint2010问卷调查(4)-实现问卷的重复答复次数(采用自定义字段类型和JS)
sharepoint的问卷调查可以设置重复和一次答复.但是设置一次后,调查过的用户再进行答复.会提示如下图: 分析下:该提示用户体验很不好.给用户感觉是系统出问题了.因此网上有人提出用eventhan ...
- sharepoint2010问卷调查(3)-实现问卷的开始和结束时间(采用自定义字段类型)
接着上面的图片调查,sharepoint自带的问卷调查是没有开始和结束时间的.这个在项目过程不太实用.问卷一般有开始和结束时间的.因此需要自己 动手开发一个自定义字段类型字段.如下图: 开发添加栏目会 ...
随机推荐
- js 表面使用 表面学习 -输出
JavaScript 能够以不同方式"显示"数据: 使用 window.alert() 写入警告框 使用 document.write() 写入 HTML 输出 使用 innerH ...
- UiPathExcel写入操作
一.Excel 写操作 1.写一个单元格 (1)控件介绍 Write Cell: 使用Write Cell控件,在指定单元格写入内容 常用属性介绍: Destination: Cell: 要写 ...
- linux系统健康检查脚本
#!/bin/bash echo "You are logged in as `whoami`"; if [ `whoami` != root ]; then echo " ...
- 不存在的!python说不给数据的浏览器是不存在的!
有时候我们些代码是总发此疑惑? 为什么别人采集 xx 网站的时候能成功,而我却总是不返回给数据出现这种原因时往往是我们没有给够伪装, 被识别了出来~ 就像人,你出门肯定是要穿衣服的对不,如果你不穿! ...
- SpringCloudAlibaba分布式流量控制组件Sentinel实战与源码分析-中
实战示例 控制台初体验 Sentinel的控制台启动后,控制台页面的内容数据都是空的,接下来我们来逐步操作演示结合控制台的使用,在上一节也已说明整合SpringCloud Alibaba第一步先加入s ...
- 基于ABP实现DDD--聚合和聚合根实践
在下面的例子中涉及Repository.Issue.Label.User这4个聚合根,接下来以Issue聚合为例进行分析,其中Issue聚合是由Issue[聚合根].Comment[实体].Iss ...
- 初学者对html的认知
首先是关于本人对一个新事物的理解路线 对html的认知: what:首先我得知道它是什么?html是一门超文本标记语言,它不是一门编程语言 why:它为什么会存在?它存在的意义是什么?随着互联网的发展 ...
- ACWing94. 递归实现排列型枚举
题面 把 1∼n 这 n个整数排成一行后随机打乱顺序,输出所有可能的次序. 输入格式 一个整数 n. 输出格式 按照从小到大的顺序输出所有方案,每行 1 个. 首先,同一行相邻两个数用一个空格隔开. ...
- Class对象共嫩
需求:写一个"框架",不能改变该类的任何代码的前提下,可以帮我们创建任意类的对象,并且执行其中任意方法 实现: 1.配置文件 2.反射 步骤: 1.将需要创建的对象的全类名和需要执 ...
- CSp2021/ NOIp2021 游记
目录 Part 1. CSp2021 J S Part 2. NOIp2021 总结 Part 1. CSp2021 J 好水 挂飞 239pts,1= S 好毒瘤 rnm,写了个暴力就去搞 T2 \ ...