Skip to content

Nginx Parser

Sun Jianbo edited this page Jul 18, 2017 · 10 revisions

Nginx Parser 是专门解析Nginx日志的解析器。仅需指定nginx的配置文件地址,即可进行nginx日志解析。

典型配置如下

    "parser":{
	"name":"nginx_parser",
        "type":"nginx",
        "nginx_log_format_path":"/opt/nginx/conf/nginx.conf",
        "nginx_log_format_name":"main",
        "nginx_schema":"time_local date,bytes_sent long,request_time float,body_bytes_sent long",
        "labels":"machine xxx123, team pandora"
    },
  • Nginx Parser是根据您Nginx配置文件自动生成配置正则表达式解析日志的方式,字段名称和Nginx配置文件中 log_format定义的名称一致。
  • nginx_log_format_path 填写nginx配置文件,配置文件中需要包含 log_format格式,如图1.
  • nginx_log_format_name 实际access log使用的格式名称,如图2
  • nginx_schema 默认情况下nginx日志都被解析为string,指定该格式可以设置为float、long、date等三种类型。指定范式为逗号分隔每个字段和类型,每个字段和类型用空格分隔,左边为字段名称,右边为类型。
  • labels中定义的标签如果跟数据有冲突,labels中的标签会被舍弃

http://op26gaeek.bkt.clouddn.com/logformat.png 图1

http://op26gaeek.bkt.clouddn.com/realnginxconfig.png

  • 图2 *

Nginx Parser时完整的logkit配置

http://op26gaeek.bkt.clouddn.com/nginx%01config.png

Clone this wiki locally