日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

filebeat获取nginx的access日志配置

發布時間:2025/3/20 编程问答 42 豆豆
生活随笔 收集整理的這篇文章主要介紹了 filebeat获取nginx的access日志配置 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
filebeat獲取nginx的access日志配置產生nginx日志的服務器即生產者服務器配置: 拿omp.chinasoft.com舉例: 1.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" ''}';2.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; } 2.location部分添加 ####### 添加鏈路追蹤參數 #########fastcgi_param ROOT_ID $root_id; fastcgi_param APP_NAME $app_name;3.調整日志的路徑 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 80;server_name omp.chinasoft.com;return 301 https://$server_name$request_uri; }server {listen 443 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.1 TLSv1.2;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: logenabled: truepaths:- /data/www/logs/nginx_log/error/*_error.logfields:log_type: ngx_errorfields_under_root: truetail_files: truemultiline.pattern: '^\['multiline.negate: truemultiline.match: after# 采集nginx訪問日志 - type: logenabled: truepaths:- /data/www/logs/nginx_log/access/*_access.logfields:log_type: ngx_accessfields_under_root: truetail_files: trueexclude_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-logfilebeat udp監聽配置 filebeat.inputs:# 監聽udp - type: udpenabled: truehost: "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"]

?

轉載于:https://www.cnblogs.com/reblue520/p/11548987.html

總結

以上是生活随笔為你收集整理的filebeat获取nginx的access日志配置的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。