访问日志可以使用分表查询

This commit is contained in:
GoEdgeLab
2022-04-17 16:18:43 +08:00
parent 53b1b2c572
commit 9d2eb11e1f
12 changed files with 212 additions and 17 deletions

View File

@@ -32,20 +32,38 @@ func (this *AccessLogsPopupAction) RunGet(params struct {
this.Data["ipFrom"] = item.IpFrom
this.Data["ipTo"] = item.IpTo
accessLogsResp, err := this.RPC().HTTPAccessLogRPC().ListHTTPAccessLogs(this.AdminContext(), &pb.ListHTTPAccessLogsRequest{
Day: timeutil.Format("Ymd"),
Keyword: "ip:" + item.IpFrom + "," + item.IpTo,
Size: 10,
})
// 多找几个Partition
var day = timeutil.Format("Ymd")
partitionsResp, err := this.RPC().HTTPAccessLogRPC().FindHTTPAccessLogPartitions(this.AdminContext(), &pb.FindHTTPAccessLogPartitionsRequest{Day: day})
if err != nil {
this.ErrorPage(err)
return
}
var accessLogs = accessLogsResp.HttpAccessLogs
if len(accessLogs) == 0 {
accessLogs = []*pb.HTTPAccessLog{}
var hasAccessLogs = false
for _, partition := range partitionsResp.ReversePartitions {
accessLogsResp, err := this.RPC().HTTPAccessLogRPC().ListHTTPAccessLogs(this.AdminContext(), &pb.ListHTTPAccessLogsRequest{
Partition: partition,
Day: day,
Keyword: "ip:" + item.IpFrom + "," + item.IpTo,
Size: 10,
})
if err != nil {
this.ErrorPage(err)
return
}
var accessLogs = accessLogsResp.HttpAccessLogs
if len(accessLogs) > 0 {
this.Data["accessLogs"] = accessLogs
hasAccessLogs = true
break
}
}
if !hasAccessLogs {
this.Data["accessLogs"] = []interface{}{}
}
this.Data["accessLogs"] = accessLogs
this.Show()
}