Skip to content

Commit d48bb65

Browse files
v1.1.25
- added parsing of the NGINX access.log
1 parent 22c6b1d commit d48bb65

File tree

4 files changed

+136
-2
lines changed

4 files changed

+136
-2
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ RUN make install
2323
WORKDIR /goaccess
2424
RUN cp /goaccess-temp/goaccess.tar.gz .
2525
RUN tar --strip-components=1 -xzvf goaccess.tar.gz
26-
RUN sed -i "s/GWSocket<\/a>/GWSocket<\/a> ( <a href='https:\/\/tiny.one\/xgoan'>GOAN<\/a> <span>v1.1.24<\/span> )/" /goaccess/resources/tpls.html
26+
RUN sed -i "s/GWSocket<\/a>/GWSocket<\/a> ( <a href='https:\/\/tiny.one\/xgoan'>GOAN<\/a> <span>v1.1.25<\/span> )/" /goaccess/resources/tpls.html
2727
RUN sed -i "s/bottom: 190px/bottom: 260px/" /goaccess/resources/css/app.css
2828
RUN ./configure --enable-utf8 --enable-geoip=mmdb --with-getline
2929
RUN make

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,9 @@ services:
176176
- SKIP_ARCHIVED_LOGS
177177
- by default the following file(s) are read and parsed.
178178
- *.log
179+
- NGINX_ACCESS
180+
- the following file(s) are read and parsed.
181+
- access.log
179182

180183

181184
# **LOG FORMATS**
@@ -207,6 +210,13 @@ date-format %d/%b/%Y
207210
log-format %h %^[%d:%t %^] "%r" %s %b "%R" "%u" %Lm"
208211
```
209212
213+
### NGINX ACCESS LOG FORMAT
214+
```
215+
time-format %T
216+
date-format %d/%b/%Y
217+
log-format %h %^[%d:%t %^] "%r" %s %b "%R" "%u"
218+
```
219+
210220
211221
# **Possible/Known Issues**
212222
- A lot of CPU Usage and 10000 request every second in webUI
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
#!/bin/bash
2+
function nginx_access_init(){
3+
goan_config="/goaccess-config/goaccess.conf"
4+
nginx_html="/var/www/html/index.html"
5+
html_config="/var/www/html/goaccess_conf.html"
6+
archive_log="/goaccess-config/archive.log"
7+
active_log="/goaccess-config/active.log"
8+
9+
if [[ -f ${goan_config} ]]; then
10+
rm ${goan_config}
11+
else
12+
mkdir -p "/goaccess-config/"
13+
cp /goaccess-config/goaccess.conf.bak ${goan_config}
14+
fi
15+
if [[ -f ${nginx_html} ]]; then
16+
rm ${nginx_html}
17+
else
18+
mkdir -p "/var/www/html/"
19+
touch ${nginx_html}
20+
fi
21+
if [[ -f ${html_config} ]]; then
22+
rm ${html_config}
23+
fi
24+
25+
echo -n "" > ${archive_log}
26+
echo -n "" > ${active_log}
27+
}
28+
29+
function nginx_access_goaccess_config(){
30+
echo -e "\n\n\n" >> ${goan_config}
31+
echo "######################################" >> ${goan_config}
32+
echo "# ${goan_version}" >> ${goan_config}
33+
echo "# GOAN_PROXY_CONFIG" >> ${goan_config}
34+
echo "######################################" >> ${goan_config}
35+
echo "time-format %T" >> ${goan_config}
36+
echo "date-format %d/%b/%Y" >> ${goan_config}
37+
echo "log-format %h %^[%d:%t %^] \"%r\" %s %b \"%R\" \"%u\"" >> ${goan_config}
38+
echo "port 7890" >> ${goan_config}
39+
echo "real-time-html true" >> ${goan_config}
40+
echo "output ${nginx_html}" >> ${goan_config}
41+
if [[ "${ENABLE_BROWSERS_LIST}" == "True" || ${ENABLE_BROWSERS_LIST} == true ]]; then
42+
echo -e "\n\tENABLING NGINX ACCESS INSTANCE GOACCESS BROWSERS LIST"
43+
browsers_file="/goaccess-config/browsers.list"
44+
echo "browsers-file ${browsers_file}" >> ${goan_config}
45+
fi
46+
}
47+
48+
function nginx_access(){
49+
nginx_access_init
50+
nginx_access_goaccess_config
51+
52+
echo -e "\nLOADING NGINX ACCESS LOGS"
53+
echo "-------------------------------"
54+
55+
echo $'\n' >> ${goan_config}
56+
echo "#GOAN_DEFAULT_LOG_FILES" >> ${goan_config}
57+
echo "log-file ${archive_log}" >> ${goan_config}
58+
echo "log-file ${active_log}" >> ${goan_config}
59+
60+
goan_log_count=0
61+
goan_archive_log_count=0
62+
63+
echo -e "\n#GOAN_NGINX ACCESS_LOG_FILES" >> ${goan_config}
64+
if [[ -d "${goan_log_path}" ]]; then
65+
66+
echo -e "\n\tAdding proxy logs..."
67+
IFS=$'\n'
68+
69+
for file in $(find "${goan_log_path}" -name 'access.log' ! -name "error.log");
70+
do
71+
if [ -f $file ]
72+
then
73+
if [ -r $file ] && R="Read = yes" || R="Read = No"
74+
then
75+
echo "log-file ${file}" >> ${goan_config}
76+
goan_log_count=$((goan_log_count+1))
77+
echo -ne ' \t '
78+
echo "Filename: $file | $R"
79+
else
80+
echo -ne ' \t '
81+
echo "Filename: $file | $R"
82+
fi
83+
else
84+
echo -ne ' \t '
85+
echo "Filename: $file | Not a file"
86+
fi
87+
done
88+
unset IFS
89+
else
90+
echo "Problem loading directory (check directory or permissions)... ${goan_log_path}"
91+
fi
92+
93+
if [ $goan_log_count != 0 ]
94+
then
95+
echo "Found (${goan_log_count}) proxy logs..."
96+
else
97+
echo "No access.log found. Creating an empty log file..."
98+
touch "${goan_log_path}/access.log"
99+
fi
100+
101+
#additonal config settings
102+
exclude_ips ${goan_config}
103+
debug ${goan_config} ${html_config}
104+
set_geoip_database ${goan_config}
105+
106+
echo -e "\nSKIP ARCHIVED LOGS"
107+
echo "-------------------------------"
108+
echo "FEATURE NOT AVAILABLE FOR NGINX ACCESS"
109+
110+
#write out loading page
111+
echo "<!doctype html><html><head>" > ${nginx_html}
112+
echo "<title>GOAN - ${goan_version}</title>" >> ${nginx_html}
113+
echo "<meta http-equiv=\"refresh\" content=\"1\" >" >> ${nginx_html}
114+
echo "<style>body {font-family: Arial, sans-serif;}</style>" >> ${nginx_html}
115+
echo "</head><body><p><b>${goan_version}</b><br/><br/>loading... <br/><br/>" >> ${nginx_html}
116+
echo "Logs processing: $(($goan_log_count)) (might take some time depending on the number of files to parse)" >> ${nginx_html}
117+
echo "<br/></p></body></html>" >> ${nginx_html}
118+
119+
echo -e "\nRUN NGINX ACCESS GOACCESS"
120+
runGoAccess
121+
}

resources/scripts/start.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ source $(dirname "$0")/logs/npm_error.sh
77
source $(dirname "$0")/logs/traefik.sh
88
source $(dirname "$0")/logs/custom.sh
99
source $(dirname "$0")/logs/ncsa_combined.sh
10+
source $(dirname "$0")/logs/nginx_access.sh
1011

11-
goan_version="GOAN v1.1.24"
12+
goan_version="GOAN v1.1.25"
1213
goan_log_path="/opt/log"
1314

1415
goaccess_ping_interval=15
@@ -80,6 +81,8 @@ elif [[ "${LOG_TYPE}" == "NCSA_COMBINED" ]]; then
8081
ncsa_combined
8182
elif [[ "${LOG_TYPE}" == "CUSTOM" ]]; then
8283
custom
84+
elif [[ "${LOG_TYPE}" == "NGINX_ACCESS" ]]; then
85+
nginx_access
8386
fi
8487
# END PROXY LOGS
8588

0 commit comments

Comments
 (0)