分析:新增失败URL分析功能- 从日志中筛选出响应码非200的请求

- 统计每个URL的失败次数
- 获取失败次数最多的前10个URL
-打印结果
This commit is contained in:
fly6516 2025-04-14 01:46:24 +08:00
parent 6eb33193b8
commit 329b28dc26

11
1-1.py Normal file
View File

@ -0,0 +1,11 @@
from log_analysis_step2 import access_logs
not200 = access_logs.filter(lambda log: log.response_code != 200)
endpointCountPairTuple = not200.map(lambda log: (log.endpoint, 1))
endpointSum = endpointCountPairTuple.reduceByKey(lambda a, b : a + b)
topTenErrURLs = endpointSum.takeOrdered(10, lambda s: -1 * s[1])
print('Top Ten failed URLs: %s' % topTenErrURLs)