Browse Source

[REV] 返回的数据结构中增加ServiceName

pujielan 3 months ago
parent
commit
9d120573aa
2 changed files with 3 additions and 0 deletions
  1. 1 0
      app/observe/service/dto/event.go
  2. 2 0
      app/observe/service/event.go

+ 1 - 0
app/observe/service/dto/event.go

@@ -73,4 +73,5 @@ type EventStatisticResp struct {
 type EventListsResp struct {
 	Total         int64  `json:"total" ch:"StatusMessageCount" gorm:"column:StatusMessageCount"`
 	StatusMessage string `json:"status_message" ch:"StatusMessage" gorm:"column:StatusMessage"`
+	ServiceName   string `json:"service_name" ch:"ServiceName" gorm:"column:ServiceName"`
 }

+ 2 - 0
app/observe/service/event.go

@@ -128,6 +128,7 @@ func (e *Event) EventLists(c *dto.EventStatisticReq, result *[]dto.EventListsRes
 	db.Select([]string{
 		"StatusMessage",
 		"COUNT(*) AS StatusMessageCount",
+		"ServiceName",
 	})
 	if c.AppAlias != "" {
 		db.Where("AppAlias = ?", c.AppAlias)
@@ -147,6 +148,7 @@ func (e *Event) EventLists(c *dto.EventStatisticReq, result *[]dto.EventListsRes
 	db.Where("Timestamp >= ? AND Timestamp <= ?", c.StartTime, c.EndTime)
 	db.Where("StatusCode = 'STATUS_CODE_ERROR' AND StatusMessage != '' AND StatusMessage != 'status code:0'")
 	db.Group("StatusMessage")
+	db.Group("ServiceName")
 	if err := db.Order("StatusMessageCount DESC;").Find(&result).Error; err != nil {
 		return errors.Wrap(err, "统计范围时间内的具体异常失败")
 	}