nginx 日志解析

nginx变量 nginx内置变量 阅读详情

Nginx是一个高性能的HTTP和反向代理服务器。Nginx access日志记录了web应用的访问记录。大致记录了访问方式(POST/GET)、客户端IP、远程用户、请求时间、请求状态码、访问host地址、请求页面大小、reffer信息、x_forwarded_for地址等等。nginx access日志的格式不是一成不变的,是可以自定义的。Nginx access具体日志格式与在服务器的存储位置可以查看nginx.conf配置文件。Nginx详细记录了每一次web请求。

设置nginx日志格式

默认变量格式:log_format combined '$remote_addr - $remote_user [$time_local] "$request" $status $body_bytes_sent "$http_referer" "$http_user_agent"';

$remote_addr变量:记录了客户端的IP地址(普通情况下)。

$remote_user变量:当nginx开启了用户认证功能后,此变量记录了客户端使用了哪个用户进行了认证。

$time_local变量:记录了当前日志条目的时间。

$request变量:记录了当前http请求的方法、url和http协议版本。

$status变量:记录了当前http请求的响应状态,即响应的状态码,比如200、404等响应码,都记录在此变量中。

$body_bytes_sent变量:记录了nginx响应客户端请求时,发送到客户端的字节数,不包含响应头的大小。

$http_referer变量:记录了当前请求是从哪个页面过来的,比如你点了A页面中的超链接才产生了这个请求,那么此变量中就记录了A页面的url。

$http_user_agent变量:记录了客户端的软件信息,比如,浏览器的名称和版本号。

增加变量:

'"$http_host" "$request_time" "$upstream_response_time" "$upstream_connect_time" "$upstream_header_time"';

$http_host 请求地址,即浏览器中你输入的地址(IP或域名)

$request_time:处理请求的总时间,包含了用户数据接收时间

$upstream_response_time:建立连接和从上游服务器接收响应主体的最后一个字节之间的时间

$upstream_connect_time:花费在与上游服务器建立连接上的时间

$upstream_header_time:建立连接和从上游服务器接收响应头的第一个字节之间的时间

修改后的自定义格式:

 log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '

                      '$status $body_bytes_sent "$http_referer" '

                      '"$http_user_agent" "$http_x_forwarded_for" '

                      '"$http_host" "$request_time" "$upstream_response_time" "$upstream_connect_time" "$upstream_header_time"';

Nginx的详细配置 参考:nginx短篇(6):访问日志-朱双印博客

解析nginx日志

日志内容:

192.168.100.175 - - [14/Jun/2020:20:18:59 +0800] "POST /mall_open_api.php?token=9f1063d6bf1ec1 HTTP/1.0" 300 1829 "-" "Dart/2.8 (dart:io)" "-" "mall-api.carisok.com" "0.556" "0.556" "0.000" "0.556"
192.168.100.173 - - [14/Jun/2020:20:18:59 +0800] "POST /mall_open_api.php?token=a3a9c69  HTTP/1.0" 200 1829 "-" "Dart/2.8 (dart:io)" "-" "mall-api.carisok.com" "0.446" "0.445" "0.000" "0.445"
192.168.100.175 - - [14/Jun/2020:20:19:03 +0800] "POST /mall_open_api.php?token=b9b0eadf7  HTTP/1.0" 200 731 "-" "Dart/2.8 (dart:io)" "-" "mall-api.carisok.com" "0.153" "0.154" "0.000" "0.154"
192.168.100.176 - - [14/Jun/2020:20:19:14 +0800] "POST /mall_open_api.php?token=242b947c  HTTP/1.0" 200 97 "-" "Dart/2.8 (dart:io)" "-" "mall-api.carisok.com" "0.425" "0.425" "0.000" "0.425"

日志解析:正则表达式,通过java的pattern和matter类捕获变量

String pattern = "(?<ip>\\d+\\.\\d+\\.\\d+\\.\\d+)(?<datetime> - - \\[(.*?)])(?<t1>\\s[\\\\\"]+)(?<requestMethod>[A-Z[/url]]+)(?<t2> )(?<requestUrl>\\S+\\s+)(?<protocol>\\S+\")(?<status> \\d+)(?<bytes> \\d+)" +
                "(?<referer> \"(.*?)\")(?<agent> \"(.*?)\")(?<forwarded> \"(.*?)\")(?<host> \"(.*?)\")" +
                "(?<requestTime> \"(.*?)\")(?<responseTime> \"(.*?)\")(?<connectTime> \"(.*?)\")(?<headerTime> \"(.*?)\")"

实现代码: 先逐行读取文件中的日志,存储到list中,然后通过并行计算框架 ForkJoin 解析list中每一个日志信息并合并相同URI的统计信息。最终得出每条URI当天的访问统计数据(总的访问次数、成功次数、平均访问响应时间等)

public class forkJoin_log {

    public static void main(String[] args) {
        Long start_time = System.currentTimeMillis();
        //逐行读取日志文件
        String fileName = "C:\\Users\\Administrator\\Desktop\\log\\access_20200615.log";
        //String fileName = "C:\\Users\\Lin\\Desktop\\log.txt";
        ArrayList<String> logList = readFileByLines(fileName);
        System.out.println("log size: " + logList.size());
        Long load_file_time = System.currentTimeMillis();
        System.out.println("load file time: "+ (load_file_time - start_time));
        //创建分治任务线程池
        ForkJoinPool fjp = new	ForkJoinPool(5);
        //创建分治任务
        Log fib = new Log(logList,0,logList.size());
        //启动分治任务
        Map<String,	RequestMsg> result = fjp.invoke(fib);
        //输出结果
        Long end_time = System.currentTimeMillis();
        System.out.println("result size: "+result.size());
        System.out.println("forkjoin compute_time: "+ (end_time - load_file_time));
        System.out.println("total time: "+ (end_time-start_time));
    }

    //分治任务
    static class Log extends RecursiveTask<Map<String,RequestMsg>> {
        private int start;
        private int end;
        private ArrayList<String> logList;
        Log(ArrayList<String> logList,int start,int end){
            this.logList = logList;
            this.start	= start;
            this.end = end;
        }
        @Override
        protected	Map<String,	RequestMsg> compute(){
            //终止条件(不可再细分,就执行计算任务)
            if(end - start == 1)
                return	calc(logList.get(start));
            int	mid	= (start+end)/2;
            Log f1 = new Log(logList,start,mid);
            Log f2 = new Log(logList,mid,end);
            //f1创建⼦任务,f2执行计算任务,避免出现只分配任务不执行任务的情况
            f1.fork();
            //等待⼦任务结果,并合并结果
            return 	merge(f2.compute(), f1.join());
        }
    }

    public static Map<String,	RequestMsg> merge(Map<String,RequestMsg> requestMap1, Map<String,RequestMsg> requestMap2){
        Map<String,	RequestMsg> result = new HashMap<>();
        result.putAll(requestMap1);
        //合并结果
        requestMap2.forEach((k,v)	->	{
            RequestMsg rm = result.get(k);
            if	(rm!=null){
                //result.put(k,c+v);
                Integer succeed_visit_times = rm.getSucceed_visit_times() + v.getSucceed_visit_times();
                if(succeed_visit_times != 0){
                    if(rm.getSucceed_visit_times()==0){
                        rm.setMax_request_time(v.getMax_request_time());
                        rm.setMin_request_time(v.getMin_request_time());
                        rm.setMax_response_time(v.getMax_response_time());
                        rm.setMin_response_time(v.getMin_response_time());
                        rm.setAverage_request_time(v.getAverage_request_time());
                        rm.setAverage_response_time(v.getAverage_response_time());
                        rm.setSucceed_visit_times(v.getSucceed_visit_times());
                    }
                    else if (v.getSucceed_visit_times()==0){
                        //
                    }
                    else {
                        Double all_request_time = rm.getAverage_request_time() * rm.getSucceed_visit_times() + v.getAverage_request_time() * v.getSucceed_visit_times();
                        Double all_response_time = rm.getAverage_response_time() * rm.getSucceed_visit_times() + v.getAverage_response_time() * v.getSucceed_visit_times();
                        BigDecimal b1 = new BigDecimal(all_request_time);
                        BigDecimal b2 = new BigDecimal(all_response_time);
                        BigDecimal b3 = new BigDecimal(succeed_visit_times);
                        Double average_request_time = b1.divide(b3, 3, BigDecimal.ROUND_HALF_UP).doubleValue();
                        Double average_response_time = b2.divide(b3, 3, BigDecimal.ROUND_HALF_UP).doubleValue();
                        rm.setAverage_request_time(average_request_time);
                        rm.setAverage_response_time(average_response_time);
                        rm.setSucceed_visit_times(succeed_visit_times);
                    }
                }
                rm.setVisit_times(rm.getVisit_times() + v.getVisit_times());
            }
            else
                result.put(k,v);
        });
        return result;
    }
    public static Map<String,RequestMsg> calc(String log){
        Map<String,	RequestMsg> result = new HashMap<>();
        parseLine(log,result);
        return result;
    }

    public static ArrayList<String> readFileByLines(String fileName) {
        File file = new File(fileName);
        BufferedReader reader = null;
        ArrayList<String> logLIST = new ArrayList<String>();
        try {
            System.out.println("以行为单位读取文件内容,一次读一整行:");
            reader = new BufferedReader(new FileReader(file));
            String tempString = null;
            int line = 1;
            //一次读入一行,直到读入null为文件结束
            while ((tempString = reader.readLine()) != null) {
                //显示行号
                logLIST.add(tempString);
            }
            reader.close();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if (reader != null) {
                try {
                    reader.close();
                } catch (IOException e1) {
                }
            }
        }
        return logLIST;
    }
    public static RequestMsg parseLine(String str,Map<String, RequestMsg> url){

        String requestStatus="";
        RequestMsg requestMsg = new RequestMsg();

        //部分变量之间没有空格符,需注意
        String pattern = "(?<ip>\\d+\\.\\d+\\.\\d+\\.\\d+)(?<datetime> - - \\[(.*?)])(?<t1>\\s[\\\\\"]+)(?<requestMethod>[A-Z[/url]]+)(?<t2> )(?<requestUrl>\\S+\\s)(?<protocol>\\S+\")(?<status> \\d+)(?<bytes> \\d+)" +
                "(?<referer> \"(.*?)\")(?<agent> \"(.*?)\")(?<forwarded> \"(.*?)\")(?<host> \"(.*?)\")" +
                "(?<requestTime> \"(.*?)\")(?<responseTime> \"(.*?)\")(?<connectTime> \"(.*?)\")(?<headerTime> \"(.*?)\")";
        //String pattern = "(?<ip>\\d+\\.\\d+\\.\\d+\\.\\d+)(?<datetime> - - \\[(.*?)])(?<t1>\\s[\\\\\"]+)(?<requestMethod>[A-Z[/url]]+)(?<t2>  )(?<requestUrl>\\S+\\s)(?<protocol>\\S+\")(?<status>\\s+\\d+)(?<bytes>\\s+\\d+)";
        Pattern r = Pattern.compile(pattern);
        Matcher m = r.matcher(str);
        if(m.find()){
            String gap = " + ";
            String ip = m.group("ip");
            String datetime = m.group("datetime").replaceAll(" - - |\\[|\\]","");
            String requestMethod = m.group("requestMethod");
            //获取 requestUrl 并去掉参数
            String requestUrl = m.group("requestUrl");
            Pattern r1 = Pattern.compile("\\/(.*?)\\?");
            Matcher m1 = r1.matcher(requestUrl);
            while(m1.find()) requestUrl=m1.group().replaceAll(" |\\?","");
            requestUrl = requestUrl.replaceAll(" ","");
            requestUrl = requestUrl.length()>255?requestUrl.substring(0,250):requestUrl;
            requestUrl = requestUrl.indexOf(",")!=-1?requestUrl.substring(requestUrl.indexOf(",")+1):requestUrl;

            String protocol = m.group("protocol").replaceAll("\"","");
            String status = m.group("status").substring(1);
            String bytes = m.group("bytes").substring(1);
            String referer = m.group("referer").substring(1).replaceAll("\"","");
            String requestTime = m.group("requestTime").substring(1).replaceAll("\"","");
            requestTime = requestTime.equals("-")?"0.000":requestTime ;
            String responseTime = m.group("responseTime").substring(1).replaceAll("\"","");
            responseTime = responseTime.equals("-")?"0.000":responseTime ;
            responseTime = responseTime.indexOf(",")!=-1?responseTime.substring(responseTime.indexOf(",")+1):responseTime;


            //记录当次的接口信息
            requestMsg.setVisit_times(1);
            requestMsg.setRemote_addr(ip);
            requestMsg.setTime_local(datetime);
            requestMsg.setRequestMethod(requestMethod);
            requestMsg.setRequestUrl(requestUrl);
            requestMsg.setProtocol(protocol);
            requestMsg.setStatus(Integer.parseInt(status));
            requestMsg.setBytes(Integer.parseInt(bytes));
            requestMsg.setHttp_referer(referer);
            requestMsg.setRequest_time(new Double(requestTime));
            requestMsg.setResponse_time(new Double(responseTime));
            //记录访问成功的相关变量
            if(status.equals("200")) {
                requestMsg.setMax_request_time(new Double(requestTime));
                requestMsg.setMin_request_time(new Double(requestTime));
                requestMsg.setMax_response_time(new Double(responseTime));
                requestMsg.setMin_response_time(new Double(responseTime));
                requestMsg.setAverage_request_time(new Double(requestTime));
                requestMsg.setAverage_response_time(new Double(responseTime));
                requestMsg.setSucceed_visit_times(1);
            }else{
                requestMsg.setAverage_request_time(new Double(0));
                requestMsg.setAverage_response_time(new Double(0));
                requestMsg.setSucceed_visit_times(0);
            }
            url.put(requestUrl,requestMsg);

        }
        return  requestMsg;
    }
}


public class RequestMsg {
    //基础变量
    private Integer visit_times;       //  访问次数
    private String remote_addr;        //  ip:120.92.182.49
    private String time_local;         //  [11/Jun/2020:00:00:51 +0800]
    private String requestMethod;      //  GET POST
    private String requestUrl;         //  /aggr/robot.php
    private String protocol;           //  HTTP/1.0
    private Integer status;            //  200
    private Integer bytes;             //  1550
    private String http_referer;       //  请求源url
    private Double request_time;       //  处理请求的总时间 0.340 (秒)
    private Double response_time;      //  服务端的响应时间 0.340 (秒)
    private Double connect_time;       //  0.000 (秒)
    private Double header_time;        //  0.340 (秒)
    private Double log_date;           //  日志日期 20200101

    //聚合变量
    private Double max_request_time;   // 最大处理请求时间:状态码为200的请求的最大客户端请求时间
    private Double max_response_time;  // 最大服务端响应时间:状态码为200的请求的最大服务端响应时间
    private Double min_request_time;   // 最小处理请求时间:状态码为200的请求的最小客户端请求时间
    private Double min_response_time;  // 最小服务端响应时间:状态码为200的请求的最小服务端响应时间
    private Double average_request_time;   // 平均处理请求时间:状态码为200的请求的平均客户端请求时间
    private Double average_response_time;  // 平均服务端响应时间:状态码为200的请求的平均服务端响应时间
    private Integer succeed_visit_times;   // 状态码为200 的次数

    @Override
    public String toString() {
        String RequestMsg = "RequestMsg = {visit_times="+visit_times + "; remote_addr="+remote_addr + "; time_local="+time_local
                + "; requestMethod="+requestMethod + "; requestUrl="+requestUrl + "; protocol="+protocol + "; status="+status
                + "; bytes="+bytes + "; http_referer="+http_referer + "; request_time="+request_time + "; response_time="+response_time
                + "; connect_time="+connect_time + "; header_time="+header_time + "; log_date="+log_date
                + "; max_request_time=" + max_request_time
                + "; max_response_time="+max_response_time + "; min_request_time="+min_request_time
                + "; min_response_time="+min_response_time + "; average_request_time="+average_request_time
                + "; average_response_time="+average_response_time + "; succeed_visit_times="+succeed_visit_times;
        return RequestMsg;
    }

    public Double getLog_date() {
        return log_date;
    }

    public void setLog_date(Double log_date) {
        this.log_date = log_date;
    }

    public Double getMax_request_time() {
        return max_request_time;
    }

    public void setMax_request_time(Double max_request_time) {
        this.max_request_time = max_request_time;
    }

    public Double getMax_response_time() {
        return max_response_time;
    }

    public void setMax_response_time(Double max_response_time) {
        this.max_response_time = max_response_time;
    }

    public Double getMin_request_time() {
        return min_request_time;
    }

    public void setMin_request_time(Double min_request_time) {
        this.min_request_time = min_request_time;
    }

    public Double getMin_response_time() {
        return min_response_time;
    }

    public void setMin_response_time(Double min_response_time) {
        this.min_response_time = min_response_time;
    }

    public Integer getVisit_times() {
        return visit_times;
    }

    public void setVisit_times(Integer visit_times) {
        this.visit_times = visit_times;
    }

    public String getRemote_addr() {
        return remote_addr;
    }

    public void setRemote_addr(String remote_addr) {
        this.remote_addr = remote_addr;
    }

    public String getTime_local() {
        return time_local;
    }

    public void setTime_local(String time_local) {
        this.time_local = time_local;
    }

    public String getRequestMethod() {
        return requestMethod;
    }

    public void setRequestMethod(String requestMethod) {
        this.requestMethod = requestMethod;
    }

    public String getRequestUrl() {
        return requestUrl;
    }

    public void setRequestUrl(String requestUrl) {
        this.requestUrl = requestUrl;
    }

    public String getProtocol() {
        return protocol;
    }

    public void setProtocol(String protocol) {
        this.protocol = protocol;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public Integer getBytes() {
        return bytes;
    }

    public void setBytes(Integer bytes) {
        this.bytes = bytes;
    }

    public String getHttp_referer() {
        return http_referer;
    }

    public void setHttp_referer(String http_referer) {
        this.http_referer = http_referer;
    }

    public Double getRequest_time() {
        return request_time;
    }

    public void setRequest_time(Double request_time) {
        this.request_time = request_time;
    }

    public Double getResponse_time() {
        return response_time;
    }

    public void setResponse_time(Double response_time) {
        this.response_time = response_time;
    }

    public Double getConnect_time() {
        return connect_time;
    }

    public void setConnect_time(Double connect_time) {
        this.connect_time = connect_time;
    }

    public Double getHeader_time() {
        return header_time;
    }

    public void setHeader_time(Double header_time) {
        this.header_time = header_time;
    }

    public Double getAverage_request_time() {
        return average_request_time;
    }

    public void setAverage_request_time(Double average_request_time) {
        this.average_request_time = average_request_time;
    }

    public Double getAverage_response_time() {
        return average_response_time;
    }

    public void setAverage_response_time(Double average_response_time) {
        this.average_response_time = average_response_time;
    }

    public Integer getSucceed_visit_times() {
        return succeed_visit_times;
    }

    public void setSucceed_visit_times(Integer succeed_visit_times) {
        this.succeed_visit_times = succeed_visit_times;
    }


}

参考链接:

nginx日志解析:java正则解析 - about云VIP小组群 - About云开发 - Powered by Discuz!

从NginxAccess日志中挖掘有价值的漏洞_SRC部落_i春秋社区-分享你的技术,为安全加点温度.

Nginx自定义访问日志的配置方式介绍 下面这篇文章主要给大家介绍了Nginx自定义访问日志的配置方式,需要的朋友可以参考学习,下面来一起看看吧。当然还有更加优化的方案,比如Nginx日志按照日期格式输出,但是Nginx本身是不支持此功能的,只能通过sheel脚本自己进行切割,感兴趣的朋友们可以通过下面推荐的您可能感兴趣的文章进行阅读学习。其实分析Nginx日志,可以得到很多有用的数据,响应耗时的url、请求时间,各个时间段的请求量,并发量。当然,这不是重点,重点是很多公司,对于日志的重要性似乎并不是那么重视,当然这可能跟平台本身有一定的关系。 阅读详情

相关推荐

nginx 日志配置

只有日志的错误级别等于或高于level指定的值才会写入错误日志中。,指定日志的缓存大小为 32k,日志写入前启用 gzip 进行压缩,压缩比使用默认值 1,缓存数据有效时间为1分钟。有一个非常灵活的日志记录模式,每个级别的配置可以有各自独立的访问日志, 所需日志模块。当我们访问的这个server的时候日志将会输出到test.access.log.命令来定义,日志对于统计和排错是非常有利的,下面总结了。详细的日志配置信息可以参考Nginx官方文档​​​​​​​。配置错误日志文件的路径和日志级别。

关注我!带你一路 "狂飙" 到底! 1215

Nginx日志详解

Nginx日志作用 Nginx日志对于统计、系统服务排错很有用。Nginx日志主要分为两种:access_log(访问日志)和error_log(错误日志)。通过访问日志我们可以得到用户的IP地址、浏览器的信息,请求的处理时间等信息。错误日志记录了访问出错的信息,可以帮助我们定位错误的原因。 log_format定义日志格式 Nginx预定义了名为main日志格式,如果没有明确指定日志格式默认使用该格式: log_format main '$remote_addr - $remote_user [$ti

go|Python的个人博客 8120

SPSSAU 中介效应分析实战:Bootstrap 95%置信区间解读的3个关键步骤

本文详细解析了SPSSAU中介效应分析中Bootstrap 95%置信区间的解读方法,涵盖三种典型场景的判别标准与应对策略。通过实战操作指南,帮助研究者准确判断中介效应显著性,特别针对边界模糊和小样本情况提供专业建议,提升统计分析结果的可靠性。

weixin_33691817的博客 496

Nginx 的日志

Nginx 的日志主要有 2 个,一个是access.log, 一个是error.log。 如果你不进行任何配置的话,这 2 个日志将会使用默认的日志配置,这个日志将会位于 /var/log/nginx目录中。 针对虚拟主机的配置 如果你使用了 Nginx 为虚拟主机的话。 那么你可以在你的虚拟主机的配置文件中配置针对每一个特定的虚拟主机输出的日志路径。 例如我们针对虚拟主机的配置。 这样针对这个虚拟主机的所有访问将会把日志设置到你设定的文件中了。 同时我们也建议使用...

HONEY MOOSE 2万+

【保姆级教程/代码】使用PRIDE PPP-AR软件解算ZTD、反演GNSS PWV,并评估精度

在本算例中,我下载了BJFS站2024年的IGS ZTD产品,用于评估PRIDE PPP-AR软件解算出ZTD结果的精度。

weixin_43910227的博客 2365

STM32N6:MCU+NPU架构如何重塑边缘AI部署新范式

STM32N6作为业界首款MCU+NPU架构的通用微控制器,通过集成600 GOPS算力的NPU与800MHz Cortex-M55内核,实现了边缘AI部署的革命性突破。该方案在工业视觉和智能家居等场景中,以超低功耗和成本提供实时AI处理能力,性能较传统MCU提升超100倍,重塑了边缘智能设备的设计范式。

g8f9d0s1a2的博客 1290

nginx的日志解析

欢迎大家关注我的个人订阅号 A321之旅。 目录思路及代码完整代码 习惯的养成真不是一件易事,不知不觉就把计划中的事情给忘了。但不管怎样,想起了就要补上。无论何时,亡羊补牢都是值得的,也许没有价值,但至少能安心。这次讨论的是nginx的日志解析。nginx是大家常用的工具,说实话,真的是非常好用和喜爱。那么它产生的日志就需要进行分析,本文就是一段用于nginx日志解析的小代码。当然,在实际系统中...

A321(timer2007)的技术小屋 478

Versal - 从零构建Petalinux 2024.2 AI边缘计算平台(VD100+SDT+JupyterLab实战)

本文详细介绍了如何从零开始,基于AMD Versal VD100开发板和Petalinux 2024.2构建AI边缘计算平台。内容涵盖开发环境搭建、Petalinux工程创建与配置、SDT新流程实战、启动SD卡制作,并最终集成JupyterLab与Conda,打造出开箱即用的交互式AI开发环境,帮助开发者快速进行算法验证与部署。

5f4d3s2a1q的博客 487

Logstash解析Nginx访问日志

Nginx日志格式 log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$ht...

chaoqianggao4414的博客 1284

Apple 网页 SRP 登录系列文章(二):网页参数提取与会话初始化

本文深入解析了Apple网页SRP登录的第一个关键环节。文章首先指出Apple登录页面采用多层安全架构,包括跨域跳转机制和动态参数生成。重点介绍了四种关键参数(ServiceKey、SCNT、FrameId、ServiceNum)的提取技术,通过正则表达式和JSON路径解析从HTML脚本和HTTP头中获取。最后详细说明了会话初始化流程,包括访问初始页面和构建认证URL。这些技术细节揭示了Apple如何通过复杂机制确保登录过程的安全性。

Sayid_Des的专栏 1129

【小白指南】如何将deepseek引入WPS\Word\Excel中去?

如何将deepseek引入WPS\Word\Excel中去?纯小白都能看的懂,一步步操作就能行

2503_90498422的博客 1万+

logstash grok 解析nginx日志

nginx log format: log_format main '$remote_addr - $remote_user [$time_local] ' '"$request" $status $body_bytes_sent ' '"$http_referer" "$http_user_agent" ' ...

kirrin的专栏 1847

ANSYS 有限元分析 接触分析

目 录一、前沿二、接触单元类三、接触单元关键选项3.1 CONTA174 KeyOption3.2 TARGE170 KeyOption四、接触分析标准步骤4.1 定义实常数4.2 定义接触和目标单元4.3 创建接触和目标单元五、接触分析实例5.1 MPC5.2 标准接触六、尾声七、参考文献 阿阳的 ANSYS 使用指南,本文仅用于个人学习,除此之外,无其他任何用途。 ANSYS 有限元分析 概述 ANSYS 有限元分析 坐标系/工作平面 ANSYS 有限元分析 几何建模 ANSY

Hulunbuir 4万+

grok debugger 正则解析nginx日志

地址:https://grokdebug.herokuapp.com/ 1.捞一段nginx的日志 这个是我的nginx日志格式: '$remote_addr [$time_local] "$request" ' '$request_body $status $body_bytes_sent "$http_referer" "$http_user_agent" ' '$...

ZLC20050116的博客 470

LLaMA-Factory微调教程2:命令行sft微调

本文介绍了如何使用llama-factory项目在本地运行Qwen2-7B大语言模型进行对话。首先通过llamafactory-cli env查看环境配置,然后使用git lfs下载Qwen2-7B模型。创建配置文件qwen2_7b_instruct.yaml,修改模型路径和模板参数。最后通过llamafactory-cli chat命令启动对话服务,加载模型配置文件和tokenizer,完成环境初始化后即可进行交互式对话。

Cachel Wood的博客 8814

Camera2Demo

在Camera2 的基础上进行封装,使得Camera2一堆初始化逻辑与Activity分离,降低耦合度,完成预览拍照并保存的操作

探索高效日志解析:Apache HTTPD & NGINX 访问日志解析器

探索高效日志解析:Apache HTTPD & NGINX 访问日志解析器 在数字化时代,日志文件是网站和应用性能监控的关键。Apache HTTPD 和 NGINX 作为两大主流的 Web 服务器,其访问日志的解析尤为重要。今天,我们将深入介绍一个强大的开源项目——Apache HTTPD & NGINX 访问日志解析器,它能够极大地简化日志解析过程,提升数据处理的效率和准确性。...

gitblog_00738的博客 339

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

python分析nginx日志_Python解析nginx日志文件

项目的一个需求是解析nginx的日志文件。简单的整理如下:日志规则描述首先要明确自己的Nginx的日志格式,这里采用默认Nginx日志格式:log_format main '$remote_addr - $remote_user [$time_local] "$request" ''$status $body_bytes_sent "$http_referer" ''"$http_user_age...

weixin_39910824的博客 99

迈瑞BS系列全自动生化分析仪LIS协议接口手册(内含HL7和ASTM)

迈瑞BS系列全自动生化分析仪LIS协议接口手册,内含HL7和ASTM)

复分析 阿尔福斯(Ahlfors) 第三版答案 英文

答案分为十章,有部分习题没有答案,全英文复分析阿尔福斯(Ahlfors) 第三版答案

python解析nginx access日志

python解析nginx access日志,并通过django把解析结果插入数据库。 #coding=utf-8 import os import sys import time from kafka import KafkaConsumer import traceback class nginx_tracker(object): &amp;quot;&amp;quot;&amp;quot; nginx的入口监控...

独孤仁的专栏 1351

解析nginx日志文件

Web服务器的各种系统管理工作包括了多Nginx/Apache 日志的统计,python使这个任务变得极其简单,下面我们来详细讲解下具体的做法,有需要的小伙伴可以参考下。 项目的一个需求是解析nginx的日志文件。 简单的整理如下: 日志规则描述 首先要明确自己的Nginx的日志格式,这里采用默认Nginx日志格式: log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status

人人为我,我为人人 756

爱星物联——nginx日志配置与解析

ngxin是一个高性能的HTTP和反向代理web服务器,爱星物联IoT平台也使用了nginx作为反向代理使用。我们在开发和运维过程中,有时候会遇到一些API接口错误、延时、恶意访问等之类的问题,在排查这些问题时,我们依赖详细的日志,试图从各种日志文件中找到一些蛛丝马迹,以便找到问题的根源。所以,本贴重点介绍一下nginx的日志参数介绍、日志配置及日志解析入库操作,日志存到数据库之后,可以作为日志系统的数据源,也可以手动构建SQL去查询统计分析,还可以通过类似grafana之类的工具去查看日志统计及明细。

安信可科技 1259

Apache HTTPD和NGINX访问日志解析器

这是一个Logparsing框架,旨在简化Apache HTTPD和NGINX访问日志文件的解析。 基本思想是,您应该能够拥有一个解析器,可以通过简单地告诉该行写入了哪些配置选项来构造该解析器。这些配置选项是访问日志行的架构。 github地址:https://github.com/nielsbasjes/logparser idea安装插件 Lombok能以简单的注解形式来简化java代码,提高开发人员的开发效率。例如开发中经常需要写的javabean,都需要花时间去添加相应的getter/setter,

chbxw 605

Python HTTP日志分析:Nginx/Apache日志的Python解析

Python凭借其丰富的库生态,可高效解析Nginx与Apache的日志格式,实现结构化数据提取与分析。通过Python的模块化设计,开发者可灵活选择解析方案,将原始日志转化为可操作的数据资产,为运维决策提供支撑。两者均支持通过配置文件自定义字段,例如Nginx可通过。:将日志转为DataFrame,便于统计与可视化。格式,自动解析字段并转换为Python对象。格式与之类似,但字段分隔符为空格,且支持扩展字段如。(Apache)字段,分析慢请求分布。解析字段,再构造DataFrame。

weixin_73725158的博客 1131

php nginx日志分析,php解析nginx日志的实例代码

本节内容:php解析nginx日志1,access_log日志格式复制代码 代码示例:log_format main '$server_name$remote_addr$remote_user[$time_local]"$request"''$status$body_bytes_sent"$http_referer"''"$http_user_agent""$http_x_forwarded_...

weixin_39945445的博客 281

nginx日志解析输出elasticstack

elastic stack 日志采集和解析分离,中间使用redis进行缓存

Jianblog's VED 660

Apache HTTPD & NGINX 访问日志解析器的常见问题解决方案

Apache HTTPD & NGINX 访问日志解析器的常见问题解决方案 基础介绍 Apache HTTPD & NGINX 访问日志解析器是一个开源项目,旨在简化Apache HTTPD和NGINX访问日志文件的解析过程。该项目允许用户通过配置日志格式选项来构建解析器,从而实现对日志文件的高效解析。该项目主要使用Java编程语言开发。 新手常见问题及解决方案 问题1:如何配置解...

gitblog_01006的博客 1070
上一篇: 如何上传大文件(4GB)到虚拟机
下一篇: the desired address is beyond limit for this PLC
Henry_Lin_Wind
博客等级 码龄8年 49粉丝 67原创
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值