ELK初体验

Administrator
发布于 2022-10-05 / 426 阅读
0
0

ELK初体验

https://www.jb51.net/article/239956.htm

需求一

查看nginx的日志

步骤

  1. 将nginx的日志格式修改为json格式
 # json日志格式
    log_format json '{"@timestamp": "$time_local", '
                        '"remote_addr": "$remote_addr", '
                        '"referer": "$http_referer", '
                        '"request": "$request", '
                        '"status": $status, '
                        '"bytes": $body_bytes_sent, '
                        '"agent": "$http_user_agent", '
                        '"x_forwarded": "$http_x_forwarded_for", '
                        '"up_addr": "$upstream_addr",'
                        '"up_host": "$upstream_http_host",'
                        '"up_resp_time": "$upstream_response_time",'
                        '"request_time": "$request_time"'
                        ' }';
    access_log  /var/log/nginx/access.log json;

评论