Browse Source

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

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

1
config/configStruct.go

@ -27,6 +27,7 @@ type KafkaConfig struct {
type EsConfig struct {
Address []string `json:"address"`
Index string `json:"index"`
AlarmIndex string `json:"alarmIndex"`
Auth struct {
UserName string `json:"userName"`
Password string `json:"password"`

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

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

2
consumers/consumerSavoirTheme.go

@ -150,7 +150,7 @@ func (the *consumerSavoirTheme) judgeOffline() {
//拿到当前es最后一条数据和当前数据库的配置之后去查是否产生告警
StrValue := "80040003"
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)
if err != nil {
log.Printf("查询es 异常")

2
dbOperate/elasticsearchHelper.go

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

Loading…
Cancel
Save