Skip to content

Commit a6b87bc

Browse files
committed
update: add english report
1 parent 1718d92 commit a6b87bc

File tree

5 files changed

+95
-54
lines changed

5 files changed

+95
-54
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
## web-log-parser
22
**web-log-parser** is an open source analysis web log tool, developed in python language, with flexible log format configuration
33

4+
[中文说明文档](https://github.com/JeffXue/web-log-parser/blob/master/README_ch.md)
5+
46
---
57

68
## Example
7-
![example picture](https://raw.githubusercontent.com/JeffXue/web-log-parser/master/example.png)
9+
![example picture](https://raw.githubusercontent.com/JeffXue/web-log-parser/master/example_en.png)
810

911
---
1012

bin/config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ def __init__(self, config_file):
3838
self.ignore_urls = all_config.get('filter', 'ignore_urls').split(',')
3939
self.static_file = all_config.get('filter', 'static-file').split(',')
4040

41+
self.report_language = all_config.get('report', 'language')
4142
self.second_line_flag = int(all_config.get('report', 'second_line_flag'))
4243
self.cost_time_flag = int(all_config.get('report', 'cost_time_flag'))
4344
self.cost_time_percentile_flag = int(all_config.get('report', 'cost_time_percentile_flag'))

bin/report.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@
77
from jinja2 import Environment, FileSystemLoader
88

99
env = Environment(loader=FileSystemLoader('./templates'))
10-
report_template = env.get_template('report.html')
10+
if config.report_language == 'english':
11+
report_template = env.get_template('report_en.html')
12+
else:
13+
report_template = env.get_template('report.html')
1114
index_template = env.get_template('index.html')
1215
url_template = env.get_template('url.html')
1316

@@ -69,10 +72,16 @@ def upload_report(data, hours_times, minutes_times):
6972
def generate_web_log_parser_report(data):
7073
if config.goaccess_flag:
7174
data.setdefault('goaccess_file', data.get('source_file') + '_GoAccess.html')
72-
data.setdefault('goaccess_title', u'查看GoAccess生成报告')
75+
if config.report_language == 'english':
76+
data.setdefault('goaccess_title', u'Check GoAccess Report')
77+
else:
78+
data.setdefault('goaccess_title', u'查看GoAccess生成报告')
7379
else:
7480
data.setdefault('goaccess_file', '#')
75-
data.setdefault('goaccess_title', u'GoAccess报告已设置为无效,无法查看')
81+
if config.report_language == 'english':
82+
data.setdefault('goaccess_title', u'GoAccess Report Is Disable!')
83+
else:
84+
data.setdefault('goaccess_title', u'GoAccess报告已设置为无效,无法查看')
7685

7786
hours_times = sorted(list(data.get('hours_hits')))
7887
minutes_times = sorted(list(data.get('minutes_hits')))

conf/config.ini

Lines changed: 79 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,80 @@
1-
[format]
2-
#log-pattern=(\S+)\s-\s-\s\[([^]]+)\s\S+]\s"(\w+)\s(\S+)\s([^"]+)"\s(\d+)\s(\S+)\s(\S+)\s(\S+)\s"([^"]+)"\s"([^"]+)"\s"([^"]+)"\s(\S+)\s"([^"]+)"\s(\S+).*
3-
#log-format=ip datetime method url protocol status business_status instance_id length referer agent real_ip cost host hostname
4-
5-
log-pattern=(\S+)\s\S+\s(\S+)\s(\S+)\s(\d+)\s(\S+)\s(\S+)\s(\S+)\s(\S+)\s(\S+)\s(\S+)
6-
log-format=datetime method url status protocol business_status cost host hostname real_ip
7-
8-
[filter]
9-
# 支持的方法
10-
support_method=POST,GET
11-
# 是否带参数进行分析(但会包括awalys_parameter_keys所指定的参数)
12-
is_with_parameters=0
13-
always_parameter_keys=action
14-
# 访问量排行最大请求数量
15-
urls_most_number=200
16-
# 访问量排行的最低PV阀值,低于该阀值的不会进入访问量排行
17-
urls_pv_threshold=1000
18-
# 当日志统计时长小于urls_pv_threshold_time的情况下,将会使用urls_pv_threshold_min作为最低PV阀值
19-
urls_pv_threshold_time=600
20-
urls_pv_threshold_min=100
21-
22-
# 忽略的url的后缀进行统计,如请求是/customer/get/list.json,将会重写为/customer/get/list进行统计
23-
ignore_url_suffix=.json
24-
25-
# 固定的参数,但is_with_parameters=1时,不会替换一下key的值
26-
fixed_parameter_keys=action,submitType,reportType
27-
# 自定义的参数转换
28-
custom_parameters=t={timeStamp},v={timeStamp},_={timeStamp}
29-
# 忽略的URL
30-
ignore_urls=/slb.html,/server-status,/httpstatus.html,/server-status-dinghuo/,/server-status-dinghuo
31-
# 忽略的请求类型
32-
static-file=css,CSS,dae,DAE,eot,EOT,gif,GIF,ico,ICO,jpeg,JPEG,jpg,JPG,js,JS,map,MAP,mp3,MP3,pdf,PDF,png,PNG,svg,SVG,swf,SWF,ttf,TTF,txt,TXT,woff,WOFF
33-
34-
[report]
35-
# 是否开启每秒PV曲线图
36-
second_line_flag=0
37-
# 是否开启耗时占比分布图
38-
cost_time_percentile_flag=1
39-
# 是否开启耗时分布图
40-
cost_time_flag=0
41-
# 耗时阈值,超过该值的请求会标红
42-
cost_time_threshold=0.500
43-
# 是否上传数据
44-
upload_flag=0
45-
upload_url=http://192.168.1.181:5000/logs/upload/
46-
47-
[goaccess]
48-
goaccess_flag=0
49-
time-format=%H:%M:%S
50-
date-format=%d/%b/%Y
1+
[format]
2+
#log-pattern=(\S+)\s-\s-\s\[([^]]+)\s\S+]\s"(\w+)\s(\S+)\s([^"]+)"\s(\d+)\s(\S+)\s(\S+)\s(\S+)\s"([^"]+)"\s"([^"]+)"\s"([^"]+)"\s(\S+)\s"([^"]+)"\s(\S+).*
3+
#log-format=ip datetime method url protocol status business_status instance_id length referer agent real_ip cost host hostname
4+
5+
log-pattern=(\S+)\s\S+\s(\S+)\s(\S+)\s(\d+)\s(\S+)\s(\S+)\s(\S+)\s(\S+)\s(\S+)\s(\S+)
6+
log-format=datetime method url status protocol business_status cost host hostname real_ip
7+
8+
[filter]
9+
# 支持的方法
10+
# supported request method, otherwise no statistics
11+
support_method=POST,GET
12+
13+
# 是否带参数进行分析(但会包括awalys_parameter_keys所指定的参数)
14+
# enable flag for statistics url parameter,By default, the parameters in the URL will be converted, such as? Key = 123 when converting to key = {key}
15+
is_with_parameters=0
16+
always_parameter_keys=action
17+
18+
# 访问量排行最大请求数量
19+
# the maximum number of URLs separately counted
20+
urls_most_number=200
21+
22+
# 访问量排行的最低PV阀值,低于该阀值的不会进入访问量排行
23+
# The lowest PV threshold of the traffic ranking. Those below this threshold will not enter the traffic ranking.
24+
urls_pv_threshold=1000
25+
26+
# 当日志统计时长小于urls_pv_threshold_time的情况下,将会使用urls_pv_threshold_min作为最低PV阀值
27+
# When the log statistics duration is less than urls_pv_threshold_time, urls_pv_threshold_min will be used as the minimum PV threshold
28+
urls_pv_threshold_time=600
29+
urls_pv_threshold_min=100
30+
31+
# 忽略的url的后缀进行统计,如请求是/customer/get/list.json,将会重写为/customer/get/list进行统计
32+
# Ignored URL suffixes for statistics
33+
ignore_url_suffix=.json
34+
35+
# 固定的参数,但is_with_parameters=1时,不会替换一下key的值
36+
# configure special parameter key values, separated by commas, when configured key = 123, will not be replaced with key = {key}
37+
fixed_parameter_keys=action,submitType,reportType
38+
39+
# 自定义的参数转换
40+
# configure special parameter key-value pairs, separated by commas, when configured t = {timeStamp}, the value of t key will be replaced with a fixed {timeStamp}
41+
custom_parameters=t={timeStamp},v={timeStamp},_={timeStamp}
42+
43+
# 忽略的URL
44+
# urls will be ignore
45+
ignore_urls=/slb.html,/server-status,/httpstatus.html,/server-status-dinghuo/,/server-status-dinghuo
46+
47+
# 忽略的请求类型
48+
# file suffixes will be ignore
49+
static-file=css,CSS,dae,DAE,eot,EOT,gif,GIF,ico,ICO,jpeg,JPEG,jpg,JPG,js,JS,map,MAP,mp3,MP3,pdf,PDF,png,PNG,svg,SVG,swf,SWF,ttf,TTF,txt,TXT,woff,WOFF
50+
51+
[report]
52+
# 报告语言, chinese or english, default chinese
53+
language=chinese
54+
55+
# 是否开启每秒PV曲线图
56+
# flags for PV curve graph per second
57+
second_line_flag=0
58+
59+
# 是否开启耗时占比分布图
60+
# flags for the time-consuming proportion distribution map
61+
cost_time_percentile_flag=1
62+
63+
# 是否开启耗时分布图
64+
# flags for response time interval proportion map and response time distribution map
65+
cost_time_flag=0
66+
67+
# 耗时阈值,超过该值的请求会标红
68+
# Time-consuming threshold, requests exceeding this value are marked red
69+
cost_time_threshold=0.500
70+
71+
# 是否上传数据
72+
# upload flag and upload url
73+
upload_flag=0
74+
upload_url=http://192.168.1.181:5000/logs/upload/
75+
76+
[goaccess]
77+
goaccess_flag=0
78+
time-format=%H:%M:%S
79+
date-format=%d/%b/%Y
5180
goaccess-log-format=%h %^[%d:%t %^] "%r" %s %b "%R" "%u"

example_en.png

959 KB
Loading

0 commit comments

Comments
 (0)