内容简介:记录着每个请求的基础信息,对这些数据进行分析汇总,可以得到网站请求时间分配、推荐网站、浏览器版本等数据图表。可实时分析每个请求也可在命令行中查看分析结果,为网站分析提供图表支持。前不久,写了一篇对于站点的分析可以加入第三方的统计代码,但是第三方的统计一般实时性并没有那么高,也不利于定制化,比如一些警告。
摘要
HTTP server
的
access log
记录着每个请求的基础信息,对这些数据进行分析汇总,可以得到网站请求时间分配、推荐网站、浏览器版本等数据图表。可实时分析每个请求也可在命令行中查看分析结果,为网站分析提供图表支持。
背景
前不久,写了一篇 《Caddy 简介 - 使用 caddy 实现短网址服务》 可以通过简单的配置对本站作了一些推广,于是想着分析一下访问的来路及其它指标,这样更利于下次的推广。
对于站点的分析可以加入第三方的统计代码,但是第三方的统计一般实时性并没有那么高,也不利于定制化,比如一些警告。
效果
开始
goaccess
是用 C 语言编写的一个分析命令,现在已经可以实现实时分析,分析速度也是极快的。只依赖一个配置文件,也可以方便得在命令行中查看实时状态。
安装
一般可以使用 docker
的,我都会用 docker
来作讲解。下面是所有安装方式
源码安装:
$ wget https://tar.goaccess.io/goaccess-1.3.tar.gz $ tar -xzvf goaccess-1.3.tar.gz $ cd goaccess-1.3/ $ ./configure --enable-utf8 --enable-geoip=legacy $ make $ make install
Debian/Ubuntu
$ echo "deb http://deb.goaccess.io/ $(lsb_release -cs) main" | sudo tee -a /etc/apt/sources.list.d/goaccess.list $ wget -O - https://deb.goaccess.io/gnugpg.key | sudo apt-key add - $ sudo apt-get update $ sudo apt-get install goaccess
centos
$ yum install goaccess
OS X / Homebrew
$ brew install goaccess
Docker
$ docker pull allinurl/goaccess
配置
将所有 goaccess
的相关的文件统一放在 /data/goaccess
$ mkdir -p /data/goaccess/{data,html,logs}
-
data
放置配置文件 -
html
放置生成的html
文件,即前面发的效果图 -
logs
放置access log
文件
在 /data/goaccess/data/goaccess.conf
中写入如下配置:
可参照官方配置修改 goaccess.conf
log-format COMBINED config-dialog false hl-header true json-pretty-print false no-color false no-column-names false no-csv-summary false no-progress false no-tab-scroll false with-mouse false real-time-html true agent-list false with-output-resolver false http-method yes http-protocol yes no-query-string false no-term-resolver false 444-as-404 false 4xx-to-unique-count false all-static-files false double-decode false ignore-crawlers false crawlers-only false ignore-panel REFERRERS ignore-panel KEYPHRASES real-os true static-file .css static-file .js static-file .jpg static-file .png static-file .gif static-file .ico static-file .jpeg static-file .pdf static-file .csv static-file .mpeg static-file .mpg static-file .swf static-file .woff static-file .woff2 static-file .xls static-file .xlsx static-file .doc static-file .docx static-file .ppt static-file .pptx static-file .txt static-file .zip static-file .ogg static-file .mp3 static-file .mp4 static-file .exe static-file .iso static-file .gz static-file .rar static-file .svg static-file .bmp static-file .tar static-file .tgz static-file .tiff static-file .tif static-file .ttf static-file .flv
启动 goaccess
docker run --restart=always -d -p 8080:7890 \ -v "/data/goaccess/data:/srv/data" \ -v "/data/goaccess/html:/srv/report" \ -v "/data/goaccess/logs:/srv/logs" \ -e LANG=zh_CN.UTF-8 \ --name=goaccess allinurl/goaccess \ goaccess --no-global-config --config-file=/srv/data/goaccess.conf \ --ws-url= 127.0.0.1:8080 --output=/srv/report/index.html \ --log-file=/srv/logs/access.log
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网
猜你喜欢:- nginx短篇(6):访问日志
- 使用Fluentd + Elasticsearch收集访问日志
- nginx tcp stream 访问日志配置的优化
- Spring Boot从入门到实战:集成AOPLog来记录接口访问日志
- 10年大数据架构师:日访问百亿级,如何架构并优化日志系统?
- Go Web编程--给自己写的服务器添加错误和访问日志
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Pro CSS and HTML Design Patterns
Michael Bowers / Apress / April 23, 2007 / $44.99
Design patterns have been used with great success in software programming. They improve productivity, creativity, and efficiency in web design and development, and they reduce code bloat and complexit......一起来看看 《Pro CSS and HTML Design Patterns》 这本书的介绍吧!