Elk nginx Log output using JSON format

Source: Internet
Author: User
Tags logstash

JSON nginx default log output format is text non-JSON format, modify the configuration file can output JSON format for easy collection and drawing

Modify Nginx configuration file to add configuration, adding a JSON output format to the log format

Log_format Access_log_json ' {"user_ip": "$http _x_forwarded_for", "lan_ip": "$remote _addr", "Log_time": "$time _iso8601 "," USER_RQP ":" $request "," Http_code ":" $status "," body_bytes_sent ":" $body _bytes_sent "," Req_time ":" $request _time ", "User_ua": "$http _user_agent"};

The log output format is

Configure the Logstash file to see the results before standard output

input{    file{        path = "/data/logs/nginx/http-access.log"        codec = "JSON"}}filter{}output{    stdout{        codec =>rubydebug    }}~                                                                                           ~                                 

Start/usr/share/logstash/bin/logstash-f nginx.conf

Web page access nginx view output, output in JSON format

And then output it to Elasticsearch.

 

Elk nginx Log output using JSON format

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.