filebeat获取nginx的access日志配置

产生nginx日志的服务器即生产者服务器配置:
拿omp.chinasoft.com举例:
.nginx.conf主配置文件添加日志格式 log_format log_json '{ "remote_addr": "$remote_addr", '
'"remote_user": "$remote_user", '
'"time_local": "$time_local", '
'"request_url": "$scheme://$host$request_uri", '
'"status": "$status", '
'"body_bytes_sent": "$body_bytes_sent", '
'"http_referer": "$http_referer", '
'"http_user_agent": "$http_user_agent", '
'"http_x_forwarded_for": "$http_x_forwarded_for", '
'"request_time": "$request_time", '
'"timestamp": "$msec", '
'"request_method": "$request_method", '
'"root_id": "$root_id", '
'"trace_id": "$http_trace_id", '
'"span_id": "$http_span_id" '
'}'; .vhosts虚拟主机配置 a.server部分添加追踪参数
####### 添加链路追踪参数 #########
set $app_name "omp.chinasoft.com";
set $root_id $pid.$msec.$remote_addr.$connection.$connection_requests;
if ($http_root_id != "")
{
set $root_id $http_root_id;
}
.location部分添加
####### 添加链路追踪参数 ######### fastcgi_param ROOT_ID $root_id;
fastcgi_param APP_NAME $app_name; .调整日志的路径
error_log /data/www/logs/nginx_log/error/omp.chinasoft.com_error.log;
access_log /data/www/logs/nginx_log/access/omp.chinasoft.com_access.log log_json; # 具体配置
# cat /usr/local/nginx/config/vhost.d/omp.chinasoft.com
server {
listen ;
server_name omp.chinasoft.com;
return https://$server_name$request_uri;
} server {
listen ssl;
ssl_certificate /usr/local/nginx/config/cert2016/chinasoft_com.crt;
ssl_certificate_key /usr/local/nginx/config/cert2016/chinasoft_com.key;
ssl_session_cache shared:SSL1:20m;
ssl_session_timeout 60m;
ssl_protocols TLSv1 TLSv1. TLSv1.; server_name omp.chinasoft.com;
index index.html index.php;
root /var/www/vhosts/cloud_oa/public; client_max_body_size 800M; add_header Ws-From 'http/1.1 2.1.1.1 stable'; set $app_name "omp.chinasoft.com";
set $root_id $pid.$msec.$remote_addr.$connection.$connection_requests;
if ($http_root_id != "")
{
set $root_id $http_root_id;
} location / {
try_files $uri $uri/ /index.php?$query_string;
} location ~ /*\.php {
fastcgi_param ROOT_ID $root_id;
fastcgi_param APP_NAME $app_name;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param APP_ENV "production";
fastcgi_pass unix:/tmp/php5.6-fpm.sock;
fastcgi_index index.php;
} location ~ .*\.(xml|gif|jpg|jpeg|png|bmp|swf|woff|woff2|ttf|js|css)$ {
expires 30d;
} #error_log /var/log/nginx/omp.chinasoft.com_error.log;
#access_log /var/log/nginx/omp.chinasoft.com_access.log;
error_log /data/www/logs/nginx_log/error/omp.chinasoft.com_error.log;
access_log /data/www/logs/nginx_log/access/omp.chinasoft.com_access.log log_json;
} 3.filebeat的配置 # cat /usr/local/filebeat-7.3.1-linux-x86_64/modules.d/nginx.yml
# Module: nginx
# Docs: https://www.elastic.co/guide/en/beats/filebeat/7.3/filebeat-module-nginx.html
filebeat.inputs:
# 采集nginx错误日志
- type: log
enabled: true
paths:
- /data/www/logs/nginx_log/error/*_error.log
fields:
log_type: ngx_error
fields_under_root: true
tail_files: true
multiline.pattern: '^\['
multiline.negate: true
multiline.match: after # 采集nginx访问日志
- type: log
enabled: true
paths:
- /data/www/logs/nginx_log/access/*_access.log
fields:
log_type: ngx_access
fields_under_root: true
tail_files: true
exclude_lines: ['\.(xml|gif|jpg|jpeg|png|bmp|swf|woff|woff2|ttf|js|css|svg|ico)'] # 输出
output.kafka:
hosts: ["1.1.1.1:19092"]
topic: filebeats-log # 启动filebeat命令
./filebeat -c modules.d/nginx.yml
/usr/local/filebeat-7.3.1-linux-x86_64/filebeat -c /usr/local/filebeat-7.3.1-linux-x86_64/modules.d/nginx.yml & 查看kafka日志具体内容的命令:
kafka配置路径,可以查看日志存放的路径:
config/server.config /usr/local/elk/kafka/bin/kafka-run-class.sh kafka.tools.DumpLogSegments --files /data/kafka/logs/filebeats-log-omp-0/00000000000000000000.log --print-data-log filebeat udp监听配置
filebeat.inputs: # 监听udp
- type: udp
enabled: true
host: "0.0.0.0:9999" output.kafka:
hosts: ["10.10.18.242:9092"]
topic: filebeats-log # 采集者
processors:
- drop_fields:
fields: ["ecs", "input", "agent", "@metadata", "tags"]

filebeat获取nginx的access日志配置的更多相关文章

  1. CentOS6.9安装Filebeat监控Nginx的访问日志发送到Kafka

    一.下载地址: 官方:https://www.elastic.co/cn/downloads/beats/filebeat 百度云盘:https://pan.baidu.com/s/1dvhqb0 二 ...

  2. Nginx的访问日志配置信息详解

    Nginx的访问日志可以让我们知晓用户的地址,网站的那些部分最受欢迎,以及用户浏览时间等.Nginx会把每个用户的访问日志记录到指定的日志文件中. Nginx主要有两个参数来控制 log_format ...

  3. Nginx的Access日志记录的时机

    想当然了,所以犯了一个低级的错误... nginx的access访问日志可以记录下访问到nginx的相关信息.包含请求地址,请求路径,返回码,请求的处理时间等信息.. 然后问题来了,这个日志是什么时候 ...

  4. Tomcat访问(access)日志配置

    在tomcat的access中打印出请求的情况可以帮助我们分析问题,通常比较关注的有访问IP.线程号.访问url.返回状态码.访问时间.持续时间. 最近在跟一个图片请求超时的问题,需要在项目的acce ...

  5. Nginx实践:(1) Nginx安装及日志配置

    1. 安装 (1)  Nginx下载地址:https://nginx.org/download/nginx-1.14.0.tar.gz (2)  安装时可能出现依赖库不存在,比如prec包,可以使用y ...

  6. Servlet、Tomcat访问(access)日志配置、记录Post请求参数

    一.运行环境: Maven:3.5.2(点击下载) ,下载页 Tomcat:8.5.29(点击下载) ,下载页 JDK:jdk1.7.0_80(点击下载) ,下载页 MavenDependency: ...

  7. Nginx 分析access日志文件

    Nginx Access Log日志统计分析常用命令 IP相关统计 统计IP访问量 awk '{print $1}' access.log | sort -n | uniq | wc -l 查看某一时 ...

  8. nginx php mysql日志配置

    1.编辑mysql的配置文件my.cnf,这个文件通常在/etc目录下,但我用rpm装mysql的时候这个配置文件是在/usr目录下,但我测试过,无论是放在/etc目录下,还是放在     /usr目 ...

  9. 【mapreudce】6.对Nginx的access日志进行数据清洗,我们提取出文件数据的ip,时间,url

    1.首先我们需要一个util辅助类 package cn.cutter.demo.hadoop.mapreduce.nginxlog.util; import java.text.ParseExcep ...

随机推荐

  1. iniparser——C配置文件解析库

    简介 ini文件则是一些系统或者软件的配置文件,iniparser是免费.独立的INI解析器,Github地址(也是主要更新地址)请点击这个,官网上的tarball版本比较老,主要是为了保留之前的di ...

  2. C语言基础知识-数组和字符串

    C语言基础知识-数组和字符串 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.数组概述 在程序设计中,为了方便处理数据把具有相同类型的若干变量按有序形式组织起来的方式我们称为数组 ...

  3. Nastya Hasn't Written a Legend(Codeforces Round #546 (Div. 2)E+线段树)

    题目链接 传送门 题面 题意 给你一个\(a\)数组和一个\(k\)数组,进行\(q\)次操作,操作分为两种: 将\(a_i\)增加\(x\),此时如果\(a_{i+1}<a_i+k_i\),那 ...

  4. 摘:Windows系统内存计数器理解解析_备忘录_51Testing软件测试网...

    [原创]Windows系统内存计数器理解解析 2008-05-13 11:42:23 / 个人分类:性能测试 说明:本文的计数器以Windows2003为准. 序言;F9n)\%V1a6Z C)?ZV ...

  5. 如何使用git,进行项目的管理

    1.首先,现在git上个创建一个项目, 2.然后在本地创建一个springboot工程 3.使用git命令   git init 将这个springboot项目交给git进行管理 4.创建一个dev分 ...

  6. Pycharm 主题背景色的配置

    PyCharm是一种Python IDE,带有一整套可以帮助用户在使用Python语言开发时提高其效率的工具.那么它的主题背景如何设置呢? 具体操作:   步骤一:选择 “file” 菜单下的 “se ...

  7. 如何使用 淘宝 NPM 镜像

    淘宝 NPM 镜像 原文链接 http://npm.taobao.org/ 这是一个完整 npmjs.org 镜像,你可以用此代替官方版本(只读),同步频率目前为 10分钟 一次以保证尽量与官方服务同 ...

  8. postgres linux系统下连接方法

    psql -U 用户名 -h ip  -p 端口号 -w 库名称 查询实例下的数据结构 语法:select 字段名  from  实例名“.”表名(account.tb_user) 如:  selec ...

  9. stm32flash的读写特性

    在使用stm32自带的flash保存数据时候,如下特点必须知道: 1.必须是先擦除一个扇区,才能写入 2.读数据没有限制 3.写数据必须是2字节,同时写入地址以一定要考虑字节对齐, 4.一般都是在最后 ...

  10. RobotFrameWork框架介绍与安装

    一.RobotFrameWork介绍 1.简称RF,基于python研发的一款自动化测试框架.开源.跨平台的测试框架 2.RF是基于RF基金来研发的一款软件,目前已完全能够在python3环境下应用 ...