mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2026-04-21 11:55:17 +08:00
访问日志可以使用分表查询
This commit is contained in:
@@ -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()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user