goaccess 是一个很不错的日志实时统计分析工具,我们可以用来方便的分析nginx apcahe iis 等的日志信息
对于geoip 的支持是需要源码编译的,所以基于官方docker 镜像添加了geoip 的支持
dockerfile
# Builds a goaccess image from the current working directory:
FROM alpine:edge
WORKDIR /goaccess
RUN wget https://tar.goaccess.io/goaccess-1.3.tar.gz
RUN tar -xzvf goaccess-1.3.tar.gz
RUN cd goaccess-1.3/
ARG build_deps="build-base ncurses-dev autoconf automake git gettext-dev"
ARG runtime_deps="tini ncurses libintl gettext openssl-dev"
RUN apk update && \
apk add -u $runtime_deps $build_deps geoip-dev && \
wget -O goaccess-1.3.tar.gz https://tar.goaccess.io/goaccess-1.3.tar.gz && \
tar -xzvf goaccess-1.3.tar.gz && \
cd goaccess-1.3 && \
autoreconf -fiv && \
./configure --enable-utf8 --enable-geoip=legacy --with-openssl && \
make && \
make install && \
apk del $build_deps && \
rm -rf /var/cache/apk/* /tmp/goaccess/* /goaccess
VOLUME /srv/data
VOLUME /srv/logs
VOLUME /srv/report
EXPOSE 7890
ENTRYPOINT ["/sbin/tini", "--"]
CMD ["goaccess", "--no-global-config", "--config-file=/srv/data/goaccess.conf"]
docker-compose 文件
version: "3"
services:
log:
image: dalongrong/goaccess-geo
ports:
- "7890:7890"
volumes:
- "./data:/srv/data"
- "./logs:/srv/logs"
- "./html:/srv/report"
- "./geoip/:/src/geoip/"
web:
image: nginx
ports:
- "8080:80"
volumes:
- "./html/:/usr/share/nginx/html/"
goaccess 配置文件
geoip-database /src/geoip/GeoLiteCity.dat
log-format COMBINED
real-time-html true
log-file /srv/logs/access.log
output /srv/report/index.html
geoip 下载地址
http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz
启动&&测试
copy log 文件
启动
docker-compose up -d
- 效果
说明
goaccess 还是挺方便的,可以实时的进行一些访问指标的获取,同时docker 镜像我已经推送官方仓库了 dalongrong/goaccess-geo
参考资料
https://github.com/rongfengliang/goaccess-geoip-docker-compose-demo
https://goaccess.io/