-
Notifications
You must be signed in to change notification settings - Fork 2
/
log_analyzer_test.py
35 lines (34 loc) · 1.58 KB
/
log_analyzer_test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
from log_analyzer import LogAnalyzer, LogParser
# from json import json
if __name__ == '__main__':
lp = LogParser()
lp.load_apache_log_file_into_DB('access.2','access_log')
# lp.load_apache_log_file_into_DB('access_log_2','access_log')
# lp.load_apache_log_file_into_DB('access_log_3','access_log')
# lp.load_apache_log_file_into_DB('access_log_4','access_log')
# la = LogAnalyzer(db = 'test', collection = 'access_log')
# print la.get_log_data(collection_name = 'access_log', page_number = 5)
# print la.get_log_data('access_log')
# print la.count_hits('access_log')
# df = la.load_apache_logs_into_DataFrame()
# data = la.group_by(df,['request_country'])
# print json.dumps(la.daily_bandwidth_sums())
# print la.sum(data, 'request_size')
# print (la.count(data, ['request_country'])['request_country']) #group_by os and browser and return the count of referer based on that groups. notice the field selection after the count, otherwise all the fields will be printed
# print la.count(data, 'referer')
# data = la.group_by(df, 'referer')
# data = la.count(data, 'referer')
# print la.to_dict(data)
# #print la.to_dict(data, 'referer', 'count')
# data = la.group_by(df, 'os')
# data = la.count(data, 'os')
# print data
# data = la.group_by(df, 'request_country')
# data = la.count(data, 'request_country')
# print data
# data = la.group_by(df, 'browser')
# data = la.count(data, 'browser')
# print data
# data = la.group_by(df, 'device')
# data = la.count(data, 'device')
# print data