mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-12 19:30:26 +08:00
访问日志查询过慢的时候,提示建议增加新的日志节点
This commit is contained in:
@@ -3,12 +3,14 @@
|
|||||||
package logs
|
package logs
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||||
"github.com/iwind/TeaGo/lists"
|
"github.com/iwind/TeaGo/lists"
|
||||||
timeutil "github.com/iwind/TeaGo/utils/time"
|
timeutil "github.com/iwind/TeaGo/utils/time"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
type IndexAction struct {
|
type IndexAction struct {
|
||||||
@@ -46,6 +48,8 @@ func (this *IndexAction) RunGet(params struct {
|
|||||||
this.Data["hasError"] = params.HasError
|
this.Data["hasError"] = params.HasError
|
||||||
this.Data["hasWAF"] = params.HasWAF
|
this.Data["hasWAF"] = params.HasWAF
|
||||||
this.Data["pageSize"] = params.PageSize
|
this.Data["pageSize"] = params.PageSize
|
||||||
|
this.Data["isSlowQuery"] = false
|
||||||
|
this.Data["slowQueryCost"] = ""
|
||||||
|
|
||||||
day := params.Day
|
day := params.Day
|
||||||
ipList := []string{}
|
ipList := []string{}
|
||||||
@@ -59,6 +63,7 @@ func (this *IndexAction) RunGet(params struct {
|
|||||||
|
|
||||||
this.Data["hasError"] = params.HasError
|
this.Data["hasError"] = params.HasError
|
||||||
|
|
||||||
|
var before = time.Now()
|
||||||
resp, err := this.RPC().HTTPAccessLogRPC().ListHTTPAccessLogs(this.AdminContext(), &pb.ListHTTPAccessLogsRequest{
|
resp, err := this.RPC().HTTPAccessLogRPC().ListHTTPAccessLogs(this.AdminContext(), &pb.ListHTTPAccessLogsRequest{
|
||||||
RequestId: params.RequestId,
|
RequestId: params.RequestId,
|
||||||
ServerId: params.ServerId,
|
ServerId: params.ServerId,
|
||||||
@@ -75,6 +80,12 @@ func (this *IndexAction) RunGet(params struct {
|
|||||||
return
|
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 {
|
if len(resp.HttpAccessLogs) == 0 {
|
||||||
this.Data["accessLogs"] = []interface{}{}
|
this.Data["accessLogs"] = []interface{}{}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -19,6 +19,8 @@
|
|||||||
</http-access-log-search-box>
|
</http-access-log-search-box>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
<warning-message v-if="isSlowQuery">看起来你的访问日志查询非常慢({{slowQueryCost}}s),建议通过添加新的 <a href="/db">[日志节点]</a> 来分散存储访问日志。</warning-message>
|
||||||
|
|
||||||
<p class="comment" v-if="accessLogs.length == 0">暂时还没有访问日志。</p>
|
<p class="comment" v-if="accessLogs.length == 0">暂时还没有访问日志。</p>
|
||||||
|
|
||||||
<table class="ui table selectable" v-if="accessLogs.length > 0">
|
<table class="ui table selectable" v-if="accessLogs.length > 0">
|
||||||
|
|||||||
Reference in New Issue
Block a user