Browse Source

增加告警进程es存储的动态索引

dev
18209 3 days ago
parent
commit
43f237b6e5
  1. 7
      config/configStruct.go
  2. 11
      configFiles/config_知物云测点数据_最新同步.yaml
  3. 2
      consumers/consumerSavoirTheme.go
  4. 2
      dbOperate/elasticsearchHelper.go

7
config/configStruct.go

@ -25,9 +25,10 @@ type KafkaConfig struct {
} }
type EsConfig struct { type EsConfig struct {
Address []string `json:"address"` Address []string `json:"address"`
Index string `json:"index"` Index string `json:"index"`
Auth struct { AlarmIndex string `json:"alarmIndex"`
Auth struct {
UserName string `json:"userName"` UserName string `json:"userName"`
Password string `json:"password"` Password string `json:"password"`
} `json:"auth"` } `json:"auth"`

11
configFiles/config_知物云测点数据_最新同步.yaml

@ -5,21 +5,22 @@ ioConfig:
brokers: brokers:
- 10.8.30.160:30992 - 10.8.30.160:30992
groupId: savoir_last_theme_inout groupId: savoir_last_theme_inout
alarmTopic: "savoir_alarm" alarmTopic: "savoir_alarm" #推送告警的主题
topics: topics:
- savoir_theme - savoir_theme #监听数据的的主题
out: out:
es: es:
address: address:
- "http://10.8.30.160:30092" - "http://10.8.30.160:30092"
index: "savoir_last_theme" index: "savoir_last_theme" #es存测点最后一条数据的新索引
alarmIndex: "savoir_alarms" #推送告警索引
auth: auth:
userName: post userName: post
password: 123 password: 123
interval: 30 #多久写一次es interval: 30 #多久写一次es(秒)
monitor: monitor:
cron: 1/5 * * * * cron: 1/5 * * * * #多久执行一次告警推送(5分钟一次:1、6、11。。)
queryComponent: queryComponent:
postgres: postgres:

2
consumers/consumerSavoirTheme.go

@ -150,7 +150,7 @@ func (the *consumerSavoirTheme) judgeOffline() {
//拿到当前es最后一条数据和当前数据库的配置之后去查是否产生告警 //拿到当前es最后一条数据和当前数据库的配置之后去查是否产生告警
StrValue := "80040003" StrValue := "80040003"
alarmQueryStr := the.getEsAlarmValueStr(gap.StructId, StrValue) alarmQueryStr := the.getEsAlarmValueStr(gap.StructId, StrValue)
allAlarmThemes, err := the.OutEs.SearchAlarmThemeData(the.Info.IoConfig.In.Kafka.AlarmTopic, alarmQueryStr) allAlarmThemes, err := the.OutEs.SearchAlarmThemeData(the.Info.IoConfig.Out.Es.AlarmIndex, alarmQueryStr)
log.Printf("allAlarmThemes----- > %s", allAlarmThemes) log.Printf("allAlarmThemes----- > %s", allAlarmThemes)
if err != nil { if err != nil {
log.Printf("查询es 异常") log.Printf("查询es 异常")

2
dbOperate/elasticsearchHelper.go

@ -135,7 +135,7 @@ func (the *ESHelper) searchThemes(index, reqBody string) (models.EsThemeResp, er
if err != nil { if err != nil {
//return nil, err //return nil, err
} }
log.Println(response.Status()) log.Println(response.Status(), response.Header, response.Body)
r := models.EsThemeResp{} r := models.EsThemeResp{}
// Deserialize the response into a map. // Deserialize the response into a map.
if err := json.NewDecoder(response.Body).Decode(&r); err != nil { if err := json.NewDecoder(response.Body).Decode(&r); err != nil {

Loading…
Cancel
Save