Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
so-operation-api
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
smart-operation
so-operation-api
Commits
c618c05b
Commit
c618c05b
authored
Aug 15, 2023
by
李科
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 告警总览
parent
ea1e61a8
Changes
9
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
563 additions
and
221 deletions
+563
-221
go.mod
go.mod
+3
-0
go.sum
go.sum
+6
-0
src/bean/entity/alert_overview.go
src/bean/entity/alert_overview.go
+3
-19
src/bean/vo/response/alert.go
src/bean/vo/response/alert.go
+43
-0
src/bean/vo/response/alert_overview.go
src/bean/vo/response/alert_overview.go
+3
-3
src/pkg/beagle/constant/constant.go
src/pkg/beagle/constant/constant.go
+15
-2
src/service/alert_class.go
src/service/alert_class.go
+12
-0
src/service/alert_overview.go
src/service/alert_overview.go
+467
-197
src/service/metric_config.go
src/service/metric_config.go
+11
-0
No files found.
go.mod
View file @
c618c05b
...
@@ -108,6 +108,9 @@ require (
...
@@ -108,6 +108,9 @@ require (
github.com/shurcooL/vfsgen v0.0.0-20200824052919-0d455de96546 // indirect
github.com/shurcooL/vfsgen v0.0.0-20200824052919-0d455de96546 // indirect
github.com/sirupsen/logrus v1.9.2 // indirect
github.com/sirupsen/logrus v1.9.2 // indirect
github.com/syndtr/goleveldb v1.0.0 // indirect
github.com/syndtr/goleveldb v1.0.0 // indirect
github.com/tidwall/gjson v1.16.0 // indirect
github.com/tidwall/match v1.1.1 // indirect
github.com/tidwall/pretty v1.2.0 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
github.com/ugorji/go/codec v1.2.9 // indirect
github.com/ugorji/go/codec v1.2.9 // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
...
...
go.sum
View file @
c618c05b
...
@@ -647,6 +647,12 @@ github.com/tealeg/xlsx v1.0.5 h1:+f8oFmvY8Gw1iUXzPk+kz+4GpbDZPK1FhPiQRd+ypgE=
...
@@ -647,6 +647,12 @@ github.com/tealeg/xlsx v1.0.5 h1:+f8oFmvY8Gw1iUXzPk+kz+4GpbDZPK1FhPiQRd+ypgE=
github.com/tealeg/xlsx v1.0.5/go.mod h1:btRS8dz54TDnvKNosuAqxrM1QgN1udgk9O34bDCnORM=
github.com/tealeg/xlsx v1.0.5/go.mod h1:btRS8dz54TDnvKNosuAqxrM1QgN1udgk9O34bDCnORM=
github.com/thoas/go-funk v0.9.3 h1:7+nAEx3kn5ZJcnDm2Bh23N2yOtweO14bi//dvRtgLpw=
github.com/thoas/go-funk v0.9.3 h1:7+nAEx3kn5ZJcnDm2Bh23N2yOtweO14bi//dvRtgLpw=
github.com/thoas/go-funk v0.9.3/go.mod h1:+IWnUfUmFO1+WVYQWQtIJHeRRdaIyyYglZN7xzUPe4Q=
github.com/thoas/go-funk v0.9.3/go.mod h1:+IWnUfUmFO1+WVYQWQtIJHeRRdaIyyYglZN7xzUPe4Q=
github.com/tidwall/gjson v1.16.0 h1:SyXa+dsSPpUlcwEDuKuEBJEz5vzTvOea+9rjyYodQFg=
github.com/tidwall/gjson v1.16.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA=
github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM=
github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs=
github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM=
github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM=
github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=
github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=
...
...
src/bean/entity/alert_overview.go
View file @
c618c05b
...
@@ -21,24 +21,8 @@ type AlertArray struct {
...
@@ -21,24 +21,8 @@ type AlertArray struct {
TotalCount
int
`json:"total_count"`
// 总预警数
TotalCount
int
`json:"total_count"`
// 总预警数
}
}
type
RiskLevel
Distribution
struct
{
type
Alert
Distribution
struct
{
Name
string
`json:"name"`
// 名称
Name
string
`json:"name"`
// 名称
//RiskLevel int `json:"risk_level"` // 风险等级,1:低风险,2:一般风险,3:较大风险,4:重大风险
//Percentage string `json:"percentage"` // 百分比
Value
int
`json:"value"`
}
type
AlertStatusDistribution
struct
{
Name
string
`json:"name"`
// 名称
//Status int `json:"status"` // 状态,1:已恢复 2:未恢复 3:已关闭
//Percentage string `json:"percentage"` // 百分比
Value
int
`json:"value"`
}
type
AlertClassDistribution
struct
{
Name
string
`json:"name"`
// 名称
//ClassId int `json:"class_id"` // 预警分类id
//Percentage string `json:"percentage"` // 百分比
Value
int
`json:"value"`
Value
int
`json:"value"`
}
}
...
...
src/bean/vo/response/alert.go
View file @
c618c05b
...
@@ -62,3 +62,46 @@ type Hits struct {
...
@@ -62,3 +62,46 @@ type Hits struct {
MaxScore
float64
`json:"max_score"`
MaxScore
float64
`json:"max_score"`
Hits
[]
SubHits
`json:"hits"`
Hits
[]
SubHits
`json:"hits"`
}
}
type
AggAlertOverview
struct
{
Group
struct
{
DocCountErrorUpperBound
int
`json:"doc_count_error_upper_bound"`
SumOtherDocCount
int
`json:"sum_other_doc_count"`
Buckets
[]
struct
{
Key
int
`json:"key"`
DocCount
int
`json:"doc_count"`
Group
struct
{
DocCountErrorUpperBound
int
`json:"doc_count_error_upper_bound"`
SumOtherDocCount
int
`json:"sum_other_doc_count"`
Buckets
[]
struct
{
Key
string
`json:"key"`
DocCount
int
`json:"doc_count"`
UnresolvedCount
struct
{
DocCount
int
`json:"doc_count"`
}
`json:"unresolved_count"`
}
`json:"buckets"`
}
`json:"group"`
}
`json:"buckets"`
}
`json:"group"`
}
type
AlertDistributionGroup
struct
{
Group
struct
{
DocCountErrorUpperBound
int
`json:"doc_count_error_upper_bound"`
SumOtherDocCount
int
`json:"sum_other_doc_count"`
Buckets
[]
struct
{
Key
int
`json:"key"`
DocCount
int
`json:"doc_count"`
}
`json:"buckets"`
}
`json:"group"`
}
type
DateHistogramGroup
struct
{
Group
struct
{
Buckets
[]
struct
{
KeyAsString
string
`json:"key_as_string"`
Key
int64
`json:"key"`
DocCount
int
`json:"doc_count"`
}
`json:"buckets"`
}
`json:"group"`
}
src/bean/vo/response/alert_overview.go
View file @
c618c05b
...
@@ -6,9 +6,9 @@ import (
...
@@ -6,9 +6,9 @@ import (
type
AlertOverviewItem
struct
{
type
AlertOverviewItem
struct
{
AlertOverview
[]
entity
.
AlertOverview
`json:"alert_overview"`
AlertOverview
[]
entity
.
AlertOverview
`json:"alert_overview"`
RiskLevelDistribution
[]
entity
.
RiskLevelDistribution
`json:"risk_level_distribution"`
RiskLevelDistribution
[]
entity
.
AlertDistribution
`json:"risk_level_distribution"`
AlertStatusDistribution
[]
entity
.
Alert
StatusDistribution
`json:"alert_status_distribution"`
AlertStatusDistribution
[]
entity
.
Alert
Distribution
`json:"alert_status_distribution"`
AlertClassDistribution
[]
entity
.
Alert
ClassDistribution
`json:"alert_class_distribution"`
AlertClassDistribution
[]
entity
.
Alert
Distribution
`json:"alert_class_distribution"`
AlertFrequencyDistribution
entity
.
AlertFrequencyDistribution
`json:"alert_frequency_distribution"`
AlertFrequencyDistribution
entity
.
AlertFrequencyDistribution
`json:"alert_frequency_distribution"`
}
}
...
...
src/pkg/beagle/constant/constant.go
View file @
c618c05b
...
@@ -148,7 +148,7 @@ func RiskLeveText(code int) string {
...
@@ -148,7 +148,7 @@ func RiskLeveText(code int) string {
case
RiskLevelCritical
:
case
RiskLevelCritical
:
return
"重大风险"
return
"重大风险"
default
:
default
:
return
""
return
"
未知
"
}
}
}
}
...
@@ -159,6 +159,19 @@ const (
...
@@ -159,6 +159,19 @@ const (
AlertClosed
AlertClosed
)
)
func
AlertStatusText
(
code
int
)
string
{
switch
code
{
case
AlertRecovered
:
return
"已恢复"
case
AlertNotRecovered
:
return
"未恢复"
case
AlertClosed
:
return
"已关闭"
default
:
return
"未知"
}
}
// 是否处置(工单管理),1:已处置,2:未处置
// 是否处置(工单管理),1:已处置,2:未处置
const
(
const
(
IsDisposedYes
=
1
IsDisposedYes
=
1
...
@@ -172,7 +185,7 @@ func DisposedStatusText(code int) string {
...
@@ -172,7 +185,7 @@ func DisposedStatusText(code int) string {
case
IsDisposedNo
:
case
IsDisposedNo
:
return
"未处置"
return
"未处置"
default
:
default
:
return
"未知
状态
"
return
"未知"
}
}
}
}
...
...
src/service/alert_class.go
View file @
c618c05b
...
@@ -155,6 +155,18 @@ func (a *AlertClassSvc) List(req request.ListAlertClass) (resp response.AlertCla
...
@@ -155,6 +155,18 @@ func (a *AlertClassSvc) List(req request.ListAlertClass) (resp response.AlertCla
return
return
}
}
func
(
a
*
AlertClassSvc
)
AlertObjectList
()
(
resp
response
.
AlertClassList
,
err
error
)
{
db
,
err
:=
client
.
GetDbClient
()
if
err
!=
nil
{
return
}
session
:=
db
.
NewSession
()
defer
session
.
Close
()
session
.
Where
(
"parent_id <> 0"
)
resp
.
TotalCount
,
err
=
session
.
OrderBy
(
"sort_order"
)
.
FindAndCount
(
&
resp
.
List
)
return
}
func
(
a
*
AlertClassSvc
)
Tree
(
req
request
.
ListAlertClass
)
(
resp
[]
*
response
.
AlertClassNode
,
err
error
)
{
func
(
a
*
AlertClassSvc
)
Tree
(
req
request
.
ListAlertClass
)
(
resp
[]
*
response
.
AlertClassNode
,
err
error
)
{
db
,
err
:=
client
.
GetDbClient
()
db
,
err
:=
client
.
GetDbClient
()
if
err
!=
nil
{
if
err
!=
nil
{
...
...
src/service/alert_overview.go
View file @
c618c05b
This diff is collapsed.
Click to expand it.
src/service/metric_config.go
View file @
c618c05b
...
@@ -93,6 +93,17 @@ func (m *MetricConfigSvc) List(req request.ListMetricConfig) (resp response.Metr
...
@@ -93,6 +93,17 @@ func (m *MetricConfigSvc) List(req request.ListMetricConfig) (resp response.Metr
return
return
}
}
func
(
m
*
MetricConfigSvc
)
NameList
()
(
resp
response
.
MetricConfigList
,
err
error
)
{
db
,
err
:=
client
.
GetDbClient
()
if
err
!=
nil
{
return
}
session
:=
db
.
NewSession
()
defer
session
.
Close
()
resp
.
TotalCount
,
err
=
session
.
Select
(
"id,metric_name"
)
.
FindAndCount
(
&
resp
.
List
)
return
}
func
(
m
*
MetricConfigSvc
)
Delete
(
ids
[]
string
)
(
err
error
)
{
func
(
m
*
MetricConfigSvc
)
Delete
(
ids
[]
string
)
(
err
error
)
{
db
,
err
:=
client
.
GetDbClient
()
db
,
err
:=
client
.
GetDbClient
()
if
err
!=
nil
{
if
err
!=
nil
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment