goaccess 是一个不错的日志分析工具,包含了json 数据同时支持基于websocket 的实时数据处理,固然咱们能够经过jsonpath
的exporter 转换为支持promethues 的metrics,仍是很方便的html
version: "3" services: metrics: image: sunbird/prometheus-jsonpath-exporter volumes: - "./conf/config.yml:/etc/prometheus-jsonpath-exporter/config.yml" ports: - "9158:9158" command: /etc/prometheus-jsonpath-exporter/config.yml g: image: grafana/grafana ports: - "3000:3000" p: image: prom/prometheus volumes: - "./conf/prometheus.yml:/etc/prometheus/prometheus.yml" ports: - "9090:9090" 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/"
conf/prometheus.ymlnginx
scrape_configs: - job_name: go_access metrics_path: / static_configs: - targets: ['metrics:9158']
conf/config.ymlgit
exporter_port: 9158 # Port on which prometheus can call this exporter to get metrics log_level: info json_data_url: http://web/app.json # Url to get json data used for fetching metric values metric_name_prefix: go_access # All metric names will be prefixed with this value metrics: - name: total_request # Final metric name will be go_access_total_request description: Number of total request path: $.general.total_requests
主要是添加支持json 的处理data/goaccess.confgithub
geoip-database /src/geoip/GeoLiteCity.dat log-format COMBINED real-time-html true log-file /srv/logs/access.log output /srv/report/index.html output /srv/report/app.json
docker-compose up -d
这个只是一种简单的处理实际上咱们能够基于其余的nginx 或者logger exporter 进行prometheus metrics 的处理,对于须要进行离线日志请求分析的,
也是一种不错的方案,须要的操做比较少,可是能够帮助咱们分析好多有用的信息web
https://github.com/project-sunbird/prometheus-jsonpath-exporter
https://github.com/rongfengliang/goaccess-geoip-docker-compose-demo
https://goaccess.io/
https://goessner.net/articles/JsonPath/index.html#e2docker