From 40e1b4653d7be974361a622a0880cb56da173fb2 Mon Sep 17 00:00:00 2001 From: GoEdgeLab Date: Tue, 14 Dec 2021 15:50:21 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=BF=E9=97=AE=E6=97=A5=E5=BF=97=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E8=BF=87=E6=85=A2=E7=9A=84=E6=97=B6=E5=80=99=EF=BC=8C?= =?UTF-8?q?=E6=8F=90=E7=A4=BA=E5=BB=BA=E8=AE=AE=E5=A2=9E=E5=8A=A0=E6=96=B0?= =?UTF-8?q?=E7=9A=84=E6=97=A5=E5=BF=97=E8=8A=82=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/web/actions/default/servers/logs/index.go | 11 +++++++++++ web/views/@default/servers/logs/index.html | 2 ++ 2 files changed, 13 insertions(+) diff --git a/internal/web/actions/default/servers/logs/index.go b/internal/web/actions/default/servers/logs/index.go index 2bec0cb3..41e646de 100644 --- a/internal/web/actions/default/servers/logs/index.go +++ b/internal/web/actions/default/servers/logs/index.go @@ -3,12 +3,14 @@ package logs import ( + "fmt" "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils" "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" "github.com/iwind/TeaGo/lists" timeutil "github.com/iwind/TeaGo/utils/time" "regexp" "strings" + "time" ) type IndexAction struct { @@ -46,6 +48,8 @@ func (this *IndexAction) RunGet(params struct { this.Data["hasError"] = params.HasError this.Data["hasWAF"] = params.HasWAF this.Data["pageSize"] = params.PageSize + this.Data["isSlowQuery"] = false + this.Data["slowQueryCost"] = "" day := params.Day ipList := []string{} @@ -59,6 +63,7 @@ func (this *IndexAction) RunGet(params struct { this.Data["hasError"] = params.HasError + var before = time.Now() resp, err := this.RPC().HTTPAccessLogRPC().ListHTTPAccessLogs(this.AdminContext(), &pb.ListHTTPAccessLogsRequest{ RequestId: params.RequestId, ServerId: params.ServerId, @@ -75,6 +80,12 @@ func (this *IndexAction) RunGet(params struct { return } + var cost = time.Since(before).Seconds() + if cost > 5 { + this.Data["slowQueryCost"] = fmt.Sprintf("%.2f", cost) + this.Data["isSlowQuery"] = true + } + if len(resp.HttpAccessLogs) == 0 { this.Data["accessLogs"] = []interface{}{} } else { diff --git a/web/views/@default/servers/logs/index.html b/web/views/@default/servers/logs/index.html index 5c462a63..f334f4c9 100644 --- a/web/views/@default/servers/logs/index.html +++ b/web/views/@default/servers/logs/index.html @@ -19,6 +19,8 @@ +看起来你的访问日志查询非常慢({{slowQueryCost}}s),建议通过添加新的 [日志节点] 来分散存储访问日志。 +

暂时还没有访问日志。