Browse Source

恢复告警字符串数组

dev
18209 3 days ago
parent
commit
78adb501f6
  1. 5
      consumers/consumerSavoirTheme.go
  2. 14
      dbOperate/elasticsearchHelper.go
  3. 14
      models/esTheme.go

5
consumers/consumerSavoirTheme.go

@ -155,9 +155,8 @@ func (the *consumerSavoirTheme) judgeOffline() {
if err != nil { if err != nil {
log.Printf("查询es 异常") log.Printf("查询es 异常")
} }
for _, alarmTheme := range allAlarmThemes { for _, alarmThemeName := range allAlarmThemes {
detailPoint := extractSensorName(alarmTheme.Detail) if theme.SensorName == alarmThemeName {
if theme.SensorName == detailPoint {
if offlineMin < float64(gap.OfflineGap) { if offlineMin < float64(gap.OfflineGap) {
alarmMsg := models.KafkaAlarm{ alarmMsg := models.KafkaAlarm{
MessageMode: "AlarmAutoElimination", MessageMode: "AlarmAutoElimination",

14
dbOperate/elasticsearchHelper.go

@ -208,17 +208,17 @@ func (the *ESHelper) SearchThemeData(index string, queryBody string) ([]models.E
return themes, err return themes, err
} }
func (the *ESHelper) SearchAlarmThemeData(index string, queryBody string) ([]models.EsAlarmTheme, error) { func (the *ESHelper) SearchAlarmThemeData(index string, queryBody string) ([]string, error) {
var themes []models.EsAlarmTheme var sensorNames []string
themesResp, err := the.searchAlarmThemes(index, queryBody) themesResp, err := the.searchAlarmThemes(index, queryBody)
var theme models.EsAlarmTheme var sensorName string
if len(themesResp.Hits.Hits) > 0 { for _, themesResptheme := range themesResp.Hits.Hits {
theme = models.EsAlarmTheme(themesResp.Hits.Hits[0].Source) sensorName = themesResptheme.Source.SensorName
themes = append(themes, theme) sensorNames = append(sensorNames, sensorName)
} }
return themes, err return sensorNames, err
} }
func (the *ESHelper) BulkWrite(index, reqBody string) { func (the *ESHelper) BulkWrite(index, reqBody string) {

14
models/esTheme.go

@ -17,17 +17,9 @@ type EsTheme struct {
} }
type EsAlarmTheme struct { type EsAlarmTheme struct {
SensorName string `json:"sensor_name"` SensorName string `json:"sensor_name"`
FactorName string `json:"factor_name"` SensorId string `json:"source_id"`
FactorProtoCode string `json:"factor_proto_code"` Detail string `json:"detail"`
Data map[string]any `json:"data"`
Detail string `json:"detail"`
Factor int `json:"factor"`
CollectTime time.Time `json:"collect_time"`
Sensor int `json:"sensor"`
Structure int `json:"structure"`
IotaDevice []string `json:"iota_device"`
CreateTime time.Time `json:"create_time"`
} }
type EsThemeResp struct { type EsThemeResp struct {

Loading…
Cancel
Save