ELK+syslog+nginx访问日志收集+分词处理
admin
2023-03-17 13:21:19
0

一、nginx访问日志配置:

1、日志格式配置:

log_format json '{"@timestamp":"$time_iso8601",'

                    '"host":"$server_addr",'

                    '"clientip":"$remote_addr",'

                    '"size":$body_bytes_sent,'

                    '"xff":"$http_x_forwarded_for",'

                    '"upstreamhost":"$upstream_addr",'

                    '"status":"$status",'

                    '"responsetime":$request_time,'

                    '"upstreamtime":"$upstream_response_time",'

                    '"http_host":"$host",'

                    '"url":"$uri"}';

2、访问日志配置:

access_log   syslog:server=xx.xx.xx.xx:5140 json;


二、logstash配置


input {

     syslog{

           port => "5140"

          }

}

filter {

     json {

          source =>"message"

          remove_field => ["message"]

          }

}

output {

          elasticsearch { hosts => ['xx.xx.xx.xx:9200','xx.xx.xx.xx:9200']

                          index => 'nginx_rfd-%{+YYYY.MM.dd.HH}'

                          template => "/usr/local/logstash/nginx.json"

                          template_name => "nginx_*"

                          template_overwrite => true

                        }

}


注意index名称要包含到template_name里


三、自定义mappings

cat /usr/local/logstash/nginx.json

{

    "template": "nginx_*",

    "order":1,

    "settings": { "index.refresh_interval" : "60s" },

    "mappings": {

        "_default_": {

            "_all" : { "enabled" : false },

            "properties": {

                "@timestamp" : { "type" : "date" },

                "@version" : { "type" : "integer", "index" : "not_analyzed" },

                "url": {

                    "type": "string",

                    "index": "not_analyzed"

                },

                "host": {

                    "type": "ip",

                    "index": "not_analyzed"

                },

                "clientip": {

                    "type": "ip",

                    "index": "not_analyzed"

                },

                "size": {

                    "type": "integer"

                },

                "xff": {

                    "type": "string",

                    "index": "not_analyzed"

                },

                "upstreamhost": {

                    "type": "string",

                    "index": "not_analyzed"

                },

                "http_host": {

                    "type": "string",

                    "index": "not_analyzed"

                },

                "status": {

                    "type": "integer"

                },

                "responseTime": {

                    "type": "string",

                    "index": "not_analyzed"

                },

                "upstreamtime": {

                    "type": "string",

                    "index": "not_analyzed"

                }

            }

        }

    }

}


四、生成统计图形

ELK+syslog+nginx访问日志收集+分词处理


五、参考文档

https://elasticsearch.cn/article/154

http://blog.csdn.net/choelea/article/details/53320140

http://www.cnblogs.com/hanyifeng/p/5860731.html


相关内容

热门资讯

【第一财经】“乐乐上海麻将开挂... 【第一财经】“乐乐上海麻将开挂器?”(外卦神器下载)您好,乐乐上海麻将这个游戏其实有挂的,确实是有挂...
【今日要闻】“免安装麻将机辅助... 家人们!今天小编来为大家解答免安装麻将机辅助器透视挂怎么安装这个问题咨询软件客服徽9784099的挂...
玩家分享攻略“新毛豆牛牛是不是... 有 亲,根据资深记者爆料新毛豆牛牛是可以开挂的,确实有挂(咨询软件无需打...
终于明白“皮皮跑胡子是不是有挂... 家人们!今天小编来为大家解答皮皮跑胡子透视挂怎么安装这个问题咨询软件客服徽9784099的挂在哪里买...
我来教教您“乐易四川麻将辅助器... 我来教教您“乐易四川麻将辅助器?”(透视曝光猫腻)您好,乐易四川麻将这个游戏其实有挂的,确实是有挂的...
今日重磅消息“掌酷天天开心到底... 今日重磅消息“掌酷天天开心到底是不是挂?”(必胜开挂神器)您好,掌酷天天开心这个游戏其实有挂的,确实...
日本一航空自卫队基地水体检出“... 近日,日本航空自卫队位于宫崎县的一处基地内部和周边多处水体检测出全氟和多氟烷基物质超标。最新公布的调...
最新引进“沈阳老友麻将辅助器?... 最新引进“沈阳老友麻将辅助器?”(必胜开挂神器)您好,沈阳老友麻将这个游戏其实有挂的,确实是有挂的,...
我来教教您“开心休闲可以开挂吗... 家人们!今天小编来为大家解答开心休闲透视挂怎么安装这个问题咨询软件客服徽9752949的挂在哪里买很...
苹果iPhone Fold外屏... 快科技12月24日消息,据报道,苹果首款折叠屏iPhone Fold外屏尺寸仅为5.3英寸,这比已经...