diff --git a/sql/n9e_mon.sql b/sql/n9e_mon.sql index 8da70d0a..9e718009 100644 --- a/sql/n9e_mon.sql +++ b/sql/n9e_mon.sql @@ -241,7 +241,7 @@ CREATE TABLE `log_collect` ( `created` datetime NOT NULL COMMENT 'created', `last_updator` varchar(64) NOT NULL DEFAULT '' COMMENT 'last_updator', `last_updated` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - `whether_attache_one_log_line` tinyint(1) not null default 0, + `whether_attach_one_log_line` tinyint(1) not null default 0, PRIMARY KEY (`id`), KEY `idx_nid` (`nid`), KEY `idx_collect_type` (`collect_type`) diff --git a/sql/upgrade/n9e_mon-v3.7.1.sql b/sql/upgrade/n9e_mon-v3.7.1.sql index cd6c1a40..5ee2aab5 100644 --- a/sql/upgrade/n9e_mon-v3.7.1.sql +++ b/sql/upgrade/n9e_mon-v3.7.1.sql @@ -1,6 +1,6 @@ set names utf8; use n9e_mon; -alter table log_collect add `whether_attache_one_log_line` tinyint(1) not null default 0 after last_updated; +alter table log_collect add `whether_attach_one_log_line` tinyint(1) not null default 0 after last_updated; diff --git a/src/models/mon_collect.go b/src/models/mon_collect.go index c18fecca..ef015ad6 100644 --- a/src/models/mon_collect.go +++ b/src/models/mon_collect.go @@ -182,13 +182,13 @@ type LogCollect struct { Zerofill int `xorm:"zero_fill" json:"zerofill"` Aggregate string `json:"aggregate"` - LocalUpdated int64 `xorm:"-" json:"-"` - TimeReg *regexp.Regexp `xorm:"-" json:"-"` - PatternReg *regexp.Regexp `xorm:"-" json:"-"` - ExcludeReg *regexp.Regexp `xorm:"-" json:"-"` - TagRegs map[string]*regexp.Regexp `xorm:"-" json:"-"` - ParseSucc bool `xorm:"-" json:"-"` - WhetherAttacheOneLogLine int `json:"whether_attache_one_log_line" xorm:"'whether_attache_one_log_line'"` + LocalUpdated int64 `xorm:"-" json:"-"` + TimeReg *regexp.Regexp `xorm:"-" json:"-"` + PatternReg *regexp.Regexp `xorm:"-" json:"-"` + ExcludeReg *regexp.Regexp `xorm:"-" json:"-"` + TagRegs map[string]*regexp.Regexp `xorm:"-" json:"-"` + ParseSucc bool `xorm:"-" json:"-"` + WhetherAttachOneLogLine int `json:"whether_attach_one_log_line" xorm:"'whether_attach_one_log_line'"` } type ApiCollect struct { diff --git a/src/modules/agent/log/strategy/strategy.go b/src/modules/agent/log/strategy/strategy.go index 6517b6e9..1ab6917e 100644 --- a/src/modules/agent/log/strategy/strategy.go +++ b/src/modules/agent/log/strategy/strategy.go @@ -89,6 +89,6 @@ func DeepCopyStrategy(p *stra.Strategy) *stra.Strategy { s.Creator = p.Creator s.SrvUpdated = p.SrvUpdated s.LocalUpdated = p.LocalUpdated - + s.WhetherAttachOneLogLine = p.WhetherAttachOneLogLine return &s } diff --git a/src/modules/agent/log/worker/worker.go b/src/modules/agent/log/worker/worker.go index a6ca6e2c..0f36ef0c 100644 --- a/src/modules/agent/log/worker/worker.go +++ b/src/modules/agent/log/worker/worker.go @@ -314,9 +314,8 @@ func (w *Worker) producer(line string, strategy *stra.Strategy) (*AnalysPoint, e Tms: tms.Unix(), Tags: tag, } - // ==1代表要开启带上一条日志 - if strategy.WhetherAttacheOneLogLine == 1 { - logger.Debugf("[strategy:%+v][WhetherAttacheOneLogLine:%+v]", strategy, strategy.WhetherAttacheOneLogLine) + if strategy.WhetherAttachOneLogLine == 1 { + logger.Debugf("[strategy:%+v][WhetherAttacheOneLogLine:%+v]", strategy, strategy.WhetherAttachOneLogLine) ret.OneLogLine = line } return ret, nil diff --git a/src/modules/agent/stra/log.go b/src/modules/agent/stra/log.go index e4be5c67..138d1793 100644 --- a/src/modules/agent/stra/log.go +++ b/src/modules/agent/stra/log.go @@ -14,28 +14,28 @@ import ( ) type Strategy struct { - ID int64 `json:"id"` - Name string `json:"name"` //监控策略名 - FilePath string `json:"file_path"` //文件路径 - TimeFormat string `json:"time_format"` //时间格式 - Pattern string `json:"pattern"` //表达式 - Exclude string `json:"-"` - MeasurementType string `json:"measurement_type"` - Interval int64 `json:"interval"` //采集周期 - Tags map[string]string `json:"tags"` - Func string `json:"func"` //采集方式(max/min/avg/cnt) - Degree int64 `json:"degree"` - Unit string `json:"unit"` - Comment string `json:"comment"` - Creator string `json:"creator"` - SrvUpdated string `json:"updated"` - LocalUpdated int64 `json:"-"` - TimeReg *regexp.Regexp `json:"-"` - PatternReg *regexp.Regexp `json:"-"` - ExcludeReg *regexp.Regexp `json:"-"` - TagRegs map[string]*regexp.Regexp `json:"-"` - ParseSucc bool `json:"parse_succ"` - WhetherAttacheOneLogLine int `json:"whether_attache_one_log_line"` + ID int64 `json:"id"` + Name string `json:"name"` //监控策略名 + FilePath string `json:"file_path"` //文件路径 + TimeFormat string `json:"time_format"` //时间格式 + Pattern string `json:"pattern"` //表达式 + Exclude string `json:"-"` + MeasurementType string `json:"measurement_type"` + Interval int64 `json:"interval"` //采集周期 + Tags map[string]string `json:"tags"` + Func string `json:"func"` //采集方式(max/min/avg/cnt) + Degree int64 `json:"degree"` + Unit string `json:"unit"` + Comment string `json:"comment"` + Creator string `json:"creator"` + SrvUpdated string `json:"updated"` + LocalUpdated int64 `json:"-"` + TimeReg *regexp.Regexp `json:"-"` + PatternReg *regexp.Regexp `json:"-"` + ExcludeReg *regexp.Regexp `json:"-"` + TagRegs map[string]*regexp.Regexp `json:"-"` + ParseSucc bool `json:"parse_succ"` + WhetherAttachOneLogLine int `json:"whether_attach_one_log_line"` } func GetLogCollects() []*Strategy { @@ -134,8 +134,7 @@ func ToStrategy(p *models.LogCollect) *Strategy { s.Creator = p.Creator s.SrvUpdated = p.LastUpdated.String() s.LocalUpdated = p.LocalUpdated - s.WhetherAttacheOneLogLine = p.WhetherAttacheOneLogLine - + s.WhetherAttachOneLogLine = p.WhetherAttachOneLogLine return &s }