首页 > 系统相关 >filebeat 收集 nginx 日志到 kibana 展示

filebeat 收集 nginx 日志到 kibana 展示

时间:2023-09-28 10:55:05浏览次数:52  
标签:filebeat http addr xpack kibana nginx monitoring log

首先是 nginx.conf 的日志格式

json 格式很多,不一定非要这个

log_format json '{ "access_time": "$time_iso8601", "remote_addr": "$remote_addr", "remote_user": "$remote_user", "request": "$request", "status": $status, "bytes": $body_bytes_sent, "referer": "$http_referer", "agent": "$http_user_agent", "x_forwarded": "$http_x_forwarded_for", "http_eshimin_version": "$http_eshimin_version", "server_addr": "$server_addr", "up_addr": "$upstream_addr", "up_host": "$upstream_http_host", "up_resp_time": "$upstream_response_time", "request_time": $request_time , "domain": "$host"}';

    access_log  logs/access.log json;

然后是 filebeat.yml

filebeat.inputs:
- type: log
  id: my-filestream-id
  enabled: true
  paths:
    - /usr/local/nginx/logs/access.log
  json.keys_under_root: true
  json.overwrite_keys: true
filebeat.config.modules:
  path: ${path.config}/modules.d/*.yml
  reload.enabled: false
setup.template.settings:
  index.number_of_shards: 1
output.logstash:
  hosts: ["192.168.96.239:6044"]
processors:
  - add_host_metadata:
      when.not.contains.tags: forwarded
  - add_cloud_metadata: ~
  - add_docker_metadata: ~
  - add_kubernetes_metadata: ~

logstash.conf

path.data: /data/elk/logstash/data
path.logs: /data/elk/logstash/log
http.host: "192.168.96.239"
node.name: "logstash115"
xpack.monitoring.elasticsearch.hosts: ["http://192.168.96.101:9200"]
xpack.monitoring.enabled: true
xpack.monitoring.elasticsearch.username: "elastic"
xpack.monitoring.elasticsearch.password: "123"
xpack.monitoring.collection.interval: 30s
xpack.monitoring.collection.pipeline.details.enabled: true
xpack.geoip.download.endpoint: "https://geoip.elastic.co/v1/database"

logstash 下面的 nginx.conf

input {
    beats {
      port =>6044
        }
}

filter{ 
mutate{ 
rename => {"status"=>"nginx_status"} 
} 
} 

output {
  elasticsearch {
    hosts => ["http://192.168.96.101:9200"]
    index => "nginx-%{+YYYY.MM.dd}"
    user => "elastic"
    password => "123"
  }
}

kibana 导入仪表盘即可

标签:filebeat,http,addr,xpack,kibana,nginx,monitoring,log
From: https://www.cnblogs.com/fsckzy/p/17735201.html

相关文章

  • thinkPHP框架在nginx环境中提示404错误的几种情况与解决方法
    一、未设置伪静态解决方法:在项目public目录下新建文件,命名为nginx.htaccess,文件内容如下:location/{indexindex.htmlindex.htmindex.php;autoindexoff;if(!-e$request_filename){rewrite^(.*)$/index.php?s=/$1last;break;......
  • nginx配置允许跨域请求
    要在Nginx中设置跨域允许,您可以使用add_header指令来添加CORS(跨源资源共享)响应头。以下是一个示例Nginx配置,演示如何允许跨域请求:server{listen80;server_nameyour_domain.com;location/{#允许所有来源的跨域请求add_header'Access-Con......
  • 2、nginx常用配置----作为web服务端
    目录环境及目的nginx配置文件特点和结构1特性2主配置文件结构常用全局配置1main段2events段web服务相关配置1server_namerootlisten11listen指令常用选项12server_name定义方式2location21alias定义路径别名3index定义主页4error_page定义错误页面5长连接相关指令6限......
  • FastDFS--扩展篇(Php&&Apache2&&Nginx)
         FastDFS不是通用的文件系统,只能通过专用的API来访问,目前提供了CJAVAPHP的API,下面我们来安装php扩展。   让Fastdfs支持php,在FastDFS的源码包解压后里面有个php_client目录,进入此目录,参照README进行安装: phpize./configuremakemakeinstall    ......
  • Nginx神奇的if语法
    我在Nginx里声明了一个变量,中间很多逻辑处理,最后想根据这个变量做http还是https跳转。话不多说,直接上nginx.confset$usessl"0";...if($usessl="1") { proxy_passhttps://$proxyserver; } if($usessl="0") { proxy_passhttp://$proxyserver; }启动......
  • openwrt nginx ssl 增加端口,互联网访问
    虽然已经会配置nginx了但是在openwrt上配置neginx,并允许wan访问,还是需要改一些东西的。尤其是几个运营商封端口。80,8080,10080,443均已沦陷,或即将沦陷。openwrt的nginx-上官飞鸿-博客园(cnblogs.com)所以我将使用10443来配置自己的路由器webwan管理。按上一篇博文的介绍......
  • nginx访问报错“maximum number of descriptors supported by select() is 1024 while
    1、问题背景 项目:一个人力的系统,主要用于考勤打卡环境:windowsservernginx版本:1.22 问题说明:当早上访问人数增加的时候,就会出现nginx的异常nginx的后台报错日志:maximumnumberofdescriptorssupportedbyselect()is1024whileconnectingtoupstream  ......
  • Nginx配置后无法解析PHP问题
    Nginx配置后无法解析PHP问题#Formoreinformationonconfiguration,see:#  *OfficialEnglishDocumentation:http://nginx.org/en/docs/#  *OfficialRussianDocumentation:http://nginx.org/ru/docs/ usernginx;worker_processesauto;error_log/var/l......
  • gunicorn dango nginx 实现同时处理并发请求
    项目是采用 gunicorndangonginx方式部署的。gunicorn.py采用如下方式配置,workers=1bind='0.0.0.0:8000'backlog=2048timeout=6000keepalive=6000errorlog='../error.log'loglevel='info'logFile='../sys.log'accesslog=......
  • 在CentOS系统中安装Nginx
    以下是在CentOS系统中安装Nginx的步骤:1.更新系统软件包:sudoyumupdate2.安装EPEL存储库: sudoyuminstallepel-release3.安装Nginx:sudoyuminstallnginx4.启动Nginx服务:sudosystemctlstartnginx5.设置Nginx服务自启动:sudosystemctlenablenginx6.验证Nginx......