Browse Source

恢复告警字符串数组

dev
18209 2 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 {
log.Printf("查询es 异常")
}
for _, alarmTheme := range allAlarmThemes {
detailPoint := extractSensorName(alarmTheme.Detail)
if theme.SensorName == detailPoint {
for _, alarmThemeName := range allAlarmThemes {
if theme.SensorName == alarmThemeName {
if offlineMin < float64(gap.OfflineGap) {
alarmMsg := models.KafkaAlarm{
MessageMode: "AlarmAutoElimination",

14
dbOperate/elasticsearchHelper.go

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

14
models/esTheme.go

@ -17,17 +17,9 @@ type EsTheme struct {
}
type EsAlarmTheme struct {
SensorName string `json:"sensor_name"`
FactorName string `json:"factor_name"`
FactorProtoCode string `json:"factor_proto_code"`
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"`
SensorName string `json:"sensor_name"`
SensorId string `json:"source_id"`
Detail string `json:"detail"`
}
type EsThemeResp struct {

Loading…
Cancel
Save