mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2026-02-24 10:35:37 +08:00
指标数据增加占比数据
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
package metrics
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
|
||||
@@ -49,6 +50,12 @@ func (this *StatsAction) RunGet(params struct {
|
||||
}
|
||||
var statMaps = []maps.Map{}
|
||||
for _, stat := range statsResp.MetricStats {
|
||||
// 占比
|
||||
var ratio float32
|
||||
if stat.SumTotal > 0 {
|
||||
ratio = stat.Value * 100 / stat.SumTotal
|
||||
}
|
||||
|
||||
statMaps = append(statMaps, maps.Map{
|
||||
"id": stat.Id,
|
||||
"time": serverconfigs.HumanMetricTime(item.PeriodUnit, stat.Time),
|
||||
@@ -57,6 +64,7 @@ func (this *StatsAction) RunGet(params struct {
|
||||
"cluster": maps.Map{"id": stat.NodeCluster.Id, "name": stat.NodeCluster.Name},
|
||||
"node": maps.Map{"id": stat.Node.Id, "name": stat.Node.Name},
|
||||
"server": maps.Map{"id": stat.Server.Id, "name": stat.Server.Name},
|
||||
"ratio": fmt.Sprintf("%.2f", ratio),
|
||||
})
|
||||
}
|
||||
this.Data["stats"] = statMaps
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
<tr>
|
||||
<th>指标对象</th>
|
||||
<th>指标值</th>
|
||||
<th>占比</th>
|
||||
<th>时间</th>
|
||||
<th>集群</th>
|
||||
<th>节点</th>
|
||||
@@ -17,6 +18,7 @@
|
||||
<tr v-for="stat in stats">
|
||||
<td>{{stat.keys}}</td>
|
||||
<td>{{stat.value}}</td>
|
||||
<td>{{stat.ratio}}%</td>
|
||||
<td>{{stat.time}}</td>
|
||||
<td>{{stat.cluster.name}}</td>
|
||||
<td>{{stat.node.name}}</td>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{$layout "layout"}
|
||||
{$template "item_menu"}
|
||||
|
||||
<warning-message>修改统计对象、统计周期、统计数值等参数后,将重新记录数据。</warning-message>
|
||||
<warning-message>修改统计对象、统计周期、统计数值等任一参数时,将重新记录数据。</warning-message>
|
||||
|
||||
<form class="ui form" data-tea-action="$" data-tea-success="success">
|
||||
<csrf-token></csrf-token>
|
||||
|
||||
Reference in New Issue
Block a user