mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-07 15:20:25 +08:00
节点运行日志增加标签筛选
This commit is contained in:
27
internal/utils/nodelogutils/utils.go
Normal file
27
internal/utils/nodelogutils/utils.go
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
|
||||||
|
//go:build community
|
||||||
|
// +build community
|
||||||
|
|
||||||
|
package nodelogutils
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/iwind/TeaGo/maps"
|
||||||
|
)
|
||||||
|
|
||||||
|
// FindCommonTags 查找常用的标签
|
||||||
|
func FindNodeCommonTags() []maps.Map {
|
||||||
|
return []maps.Map{
|
||||||
|
{
|
||||||
|
"name": "端口监听",
|
||||||
|
"code": "LISTENER",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "WAF",
|
||||||
|
"code": "WAF",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "访问日志",
|
||||||
|
"code": "ACCESS_LOG",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
package node
|
package node
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/TeaOSLab/EdgeAdmin/internal/utils/nodelogutils"
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/clusters/cluster/node/nodeutils"
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/clusters/cluster/node/nodeutils"
|
||||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||||
@@ -23,6 +24,7 @@ func (this *LogsAction) RunGet(params struct {
|
|||||||
DayTo string
|
DayTo string
|
||||||
Keyword string
|
Keyword string
|
||||||
Level string
|
Level string
|
||||||
|
Tag string
|
||||||
}) {
|
}) {
|
||||||
// 初始化节点信息(用于菜单)
|
// 初始化节点信息(用于菜单)
|
||||||
_, err := nodeutils.InitNodeInfo(this.Parent(), params.NodeId)
|
_, err := nodeutils.InitNodeInfo(this.Parent(), params.NodeId)
|
||||||
@@ -31,11 +33,14 @@ func (this *LogsAction) RunGet(params struct {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.Data["tags"] = nodelogutils.FindNodeCommonTags()
|
||||||
|
|
||||||
this.Data["nodeId"] = params.NodeId
|
this.Data["nodeId"] = params.NodeId
|
||||||
this.Data["dayFrom"] = params.DayFrom
|
this.Data["dayFrom"] = params.DayFrom
|
||||||
this.Data["dayTo"] = params.DayTo
|
this.Data["dayTo"] = params.DayTo
|
||||||
this.Data["keyword"] = params.Keyword
|
this.Data["keyword"] = params.Keyword
|
||||||
this.Data["level"] = params.Level
|
this.Data["level"] = params.Level
|
||||||
|
this.Data["tag"] = params.Tag
|
||||||
|
|
||||||
countResp, err := this.RPC().NodeLogRPC().CountNodeLogs(this.AdminContext(), &pb.CountNodeLogsRequest{
|
countResp, err := this.RPC().NodeLogRPC().CountNodeLogs(this.AdminContext(), &pb.CountNodeLogsRequest{
|
||||||
Role: "node",
|
Role: "node",
|
||||||
@@ -44,6 +49,7 @@ func (this *LogsAction) RunGet(params struct {
|
|||||||
DayTo: params.DayTo,
|
DayTo: params.DayTo,
|
||||||
Keyword: params.Keyword,
|
Keyword: params.Keyword,
|
||||||
Level: params.Level,
|
Level: params.Level,
|
||||||
|
Tag: params.Tag,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
this.ErrorPage(err)
|
this.ErrorPage(err)
|
||||||
@@ -59,6 +65,7 @@ func (this *LogsAction) RunGet(params struct {
|
|||||||
DayTo: params.DayTo,
|
DayTo: params.DayTo,
|
||||||
Keyword: params.Keyword,
|
Keyword: params.Keyword,
|
||||||
Level: params.Level,
|
Level: params.Level,
|
||||||
|
Tag: params.Tag,
|
||||||
Offset: page.Offset,
|
Offset: page.Offset,
|
||||||
Size: page.Size,
|
Size: page.Size,
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package logs
|
package logs
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/TeaOSLab/EdgeAdmin/internal/utils/nodelogutils"
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||||
"github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs"
|
"github.com/TeaOSLab/EdgeCommon/pkg/nodeconfigs"
|
||||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||||
@@ -26,12 +27,17 @@ func (this *IndexAction) RunGet(params struct {
|
|||||||
Keyword string
|
Keyword string
|
||||||
Level string
|
Level string
|
||||||
Type string
|
Type string
|
||||||
|
Tag string
|
||||||
}) {
|
}) {
|
||||||
this.Data["dayFrom"] = params.DayFrom
|
this.Data["dayFrom"] = params.DayFrom
|
||||||
this.Data["dayTo"] = params.DayTo
|
this.Data["dayTo"] = params.DayTo
|
||||||
this.Data["keyword"] = params.Keyword
|
this.Data["keyword"] = params.Keyword
|
||||||
this.Data["level"] = params.Level
|
this.Data["level"] = params.Level
|
||||||
this.Data["type"] = params.Type
|
this.Data["type"] = params.Type
|
||||||
|
this.Data["tag"] = params.Tag
|
||||||
|
|
||||||
|
// 常见标签
|
||||||
|
this.Data["tags"] = nodelogutils.FindNodeCommonTags()
|
||||||
|
|
||||||
// 未读数量
|
// 未读数量
|
||||||
countUnreadResp, err := this.RPC().NodeLogRPC().CountNodeLogs(this.AdminContext(), &pb.CountNodeLogsRequest{
|
countUnreadResp, err := this.RPC().NodeLogRPC().CountNodeLogs(this.AdminContext(), &pb.CountNodeLogsRequest{
|
||||||
@@ -53,6 +59,7 @@ func (this *IndexAction) RunGet(params struct {
|
|||||||
Keyword: params.Keyword,
|
Keyword: params.Keyword,
|
||||||
Level: params.Level,
|
Level: params.Level,
|
||||||
IsUnread: params.Type == "unread",
|
IsUnread: params.Type == "unread",
|
||||||
|
Tag: params.Tag,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
this.ErrorPage(err)
|
this.ErrorPage(err)
|
||||||
@@ -70,6 +77,7 @@ func (this *IndexAction) RunGet(params struct {
|
|||||||
Keyword: params.Keyword,
|
Keyword: params.Keyword,
|
||||||
Level: params.Level,
|
Level: params.Level,
|
||||||
IsUnread: params.Type == "unread",
|
IsUnread: params.Type == "unread",
|
||||||
|
Tag: params.Tag,
|
||||||
Offset: page.Offset,
|
Offset: page.Offset,
|
||||||
Size: page.Size,
|
Size: page.Size,
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -266,7 +266,7 @@ func (this *IndexAction) RunGet(params struct {
|
|||||||
Role: nodeconfigs.NodeRoleNode,
|
Role: nodeconfigs.NodeRoleNode,
|
||||||
Offset: 0,
|
Offset: 0,
|
||||||
Size: 20,
|
Size: 20,
|
||||||
Level: "",
|
Level: "error,success,warning",
|
||||||
FixedState: int32(configutils.BoolStateNo),
|
FixedState: int32(configutils.BoolStateNo),
|
||||||
AllServers: true,
|
AllServers: true,
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -21,13 +21,19 @@
|
|||||||
<option value="success">成功</option>
|
<option value="success">成功</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="ui field">
|
||||||
|
<select class="ui dropdown" name="tag" v-model="tag">
|
||||||
|
<option value="">[标签]</option>
|
||||||
|
<option v-for="tag in tags" :value="tag.code">{{tag.name}}</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
<div class="ui field">
|
<div class="ui field">
|
||||||
<input type="text" name="keyword" style="width:10em" v-model="keyword" placeholder="关键词"/>
|
<input type="text" name="keyword" style="width:10em" v-model="keyword" placeholder="关键词"/>
|
||||||
</div>
|
</div>
|
||||||
<div class="ui field">
|
<div class="ui field">
|
||||||
<button type="submit" class="ui button">查询</button>
|
<button type="submit" class="ui button">查询</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="ui field" v-if="dayFrom.length > 0 || dayTo.length > 0 || keyword.length > 0 || level.length > 0">
|
<div class="ui field" v-if="dayFrom.length > 0 || dayTo.length > 0 || keyword.length > 0 || level.length > 0 || tag.length > 0">
|
||||||
<a :href="'/clusters/cluster/node/logs?clusterId=' + clusterId + '&nodeId=' + nodeId">[清除条件]</a>
|
<a :href="'/clusters/cluster/node/logs?clusterId=' + clusterId + '&nodeId=' + nodeId">[清除条件]</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -22,13 +22,19 @@
|
|||||||
<option value="success">成功</option>
|
<option value="success">成功</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="ui field">
|
||||||
|
<select class="ui dropdown" name="tag" v-model="tag">
|
||||||
|
<option value="">[标签]</option>
|
||||||
|
<option v-for="tag in tags" :value="tag.code">{{tag.name}}</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
<div class="ui field">
|
<div class="ui field">
|
||||||
<input type="text" name="keyword" style="width:10em" v-model="keyword" placeholder="关键词"/>
|
<input type="text" name="keyword" style="width:10em" v-model="keyword" placeholder="关键词"/>
|
||||||
</div>
|
</div>
|
||||||
<div class="ui field">
|
<div class="ui field">
|
||||||
<button type="submit" class="ui button">查询</button>
|
<button type="submit" class="ui button">查询</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="ui field" v-if="dayFrom.length > 0 || dayTo.length > 0 || keyword.length > 0 || level.length > 0">
|
<div class="ui field" v-if="dayFrom.length > 0 || dayTo.length > 0 || keyword.length > 0 || level.length > 0 || tag.length > 0">
|
||||||
<a :href="'/clusters/logs?type=' + type">[清除条件]</a>
|
<a :href="'/clusters/logs?type=' + type">[清除条件]</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user