日志采集字段变更 whether_attache_one_log_line--> whether_attach_one_log_line (#619)

* m3db writetagged应该并发做,不然会导致transfer rpc变慢

* go func指针传参问题

* 新增k8s-mon三个大盘文件

* 新增k8s-mon三个大盘文件

* 修改k8s-mon三个大盘文件

* 日志采集新增带上最后一条日志 到extra字段中,为后续报警做准备

* 日志采集字段变更 whether_attache_one_log_line--> whether_attach_one_log_line

* 日志采集带上日志
This commit is contained in:
ning1875 2021-03-15 16:03:02 +08:00 committed by GitHub
parent b1426945d4
commit 61bd28db31
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 35 additions and 37 deletions

View File

@ -241,7 +241,7 @@ CREATE TABLE `log_collect` (
`created` datetime NOT NULL COMMENT 'created', `created` datetime NOT NULL COMMENT 'created',
`last_updator` varchar(64) NOT NULL DEFAULT '' COMMENT 'last_updator', `last_updator` varchar(64) NOT NULL DEFAULT '' COMMENT 'last_updator',
`last_updated` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, `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`), PRIMARY KEY (`id`),
KEY `idx_nid` (`nid`), KEY `idx_nid` (`nid`),
KEY `idx_collect_type` (`collect_type`) KEY `idx_collect_type` (`collect_type`)

View File

@ -1,6 +1,6 @@
set names utf8; set names utf8;
use n9e_mon; 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;

View File

@ -182,13 +182,13 @@ type LogCollect struct {
Zerofill int `xorm:"zero_fill" json:"zerofill"` Zerofill int `xorm:"zero_fill" json:"zerofill"`
Aggregate string `json:"aggregate"` Aggregate string `json:"aggregate"`
LocalUpdated int64 `xorm:"-" json:"-"` LocalUpdated int64 `xorm:"-" json:"-"`
TimeReg *regexp.Regexp `xorm:"-" json:"-"` TimeReg *regexp.Regexp `xorm:"-" json:"-"`
PatternReg *regexp.Regexp `xorm:"-" json:"-"` PatternReg *regexp.Regexp `xorm:"-" json:"-"`
ExcludeReg *regexp.Regexp `xorm:"-" json:"-"` ExcludeReg *regexp.Regexp `xorm:"-" json:"-"`
TagRegs map[string]*regexp.Regexp `xorm:"-" json:"-"` TagRegs map[string]*regexp.Regexp `xorm:"-" json:"-"`
ParseSucc bool `xorm:"-" json:"-"` ParseSucc bool `xorm:"-" json:"-"`
WhetherAttacheOneLogLine int `json:"whether_attache_one_log_line" xorm:"'whether_attache_one_log_line'"` WhetherAttachOneLogLine int `json:"whether_attach_one_log_line" xorm:"'whether_attach_one_log_line'"`
} }
type ApiCollect struct { type ApiCollect struct {

View File

@ -89,6 +89,6 @@ func DeepCopyStrategy(p *stra.Strategy) *stra.Strategy {
s.Creator = p.Creator s.Creator = p.Creator
s.SrvUpdated = p.SrvUpdated s.SrvUpdated = p.SrvUpdated
s.LocalUpdated = p.LocalUpdated s.LocalUpdated = p.LocalUpdated
s.WhetherAttachOneLogLine = p.WhetherAttachOneLogLine
return &s return &s
} }

View File

@ -314,9 +314,8 @@ func (w *Worker) producer(line string, strategy *stra.Strategy) (*AnalysPoint, e
Tms: tms.Unix(), Tms: tms.Unix(),
Tags: tag, Tags: tag,
} }
// ==1代表要开启带上一条日志 if strategy.WhetherAttachOneLogLine == 1 {
if strategy.WhetherAttacheOneLogLine == 1 { logger.Debugf("[strategy:%+v][WhetherAttacheOneLogLine:%+v]", strategy, strategy.WhetherAttachOneLogLine)
logger.Debugf("[strategy:%+v][WhetherAttacheOneLogLine:%+v]", strategy, strategy.WhetherAttacheOneLogLine)
ret.OneLogLine = line ret.OneLogLine = line
} }
return ret, nil return ret, nil

View File

@ -14,28 +14,28 @@ import (
) )
type Strategy struct { type Strategy struct {
ID int64 `json:"id"` ID int64 `json:"id"`
Name string `json:"name"` //监控策略名 Name string `json:"name"` //监控策略名
FilePath string `json:"file_path"` //文件路径 FilePath string `json:"file_path"` //文件路径
TimeFormat string `json:"time_format"` //时间格式 TimeFormat string `json:"time_format"` //时间格式
Pattern string `json:"pattern"` //表达式 Pattern string `json:"pattern"` //表达式
Exclude string `json:"-"` Exclude string `json:"-"`
MeasurementType string `json:"measurement_type"` MeasurementType string `json:"measurement_type"`
Interval int64 `json:"interval"` //采集周期 Interval int64 `json:"interval"` //采集周期
Tags map[string]string `json:"tags"` Tags map[string]string `json:"tags"`
Func string `json:"func"` //采集方式max/min/avg/cnt Func string `json:"func"` //采集方式max/min/avg/cnt
Degree int64 `json:"degree"` Degree int64 `json:"degree"`
Unit string `json:"unit"` Unit string `json:"unit"`
Comment string `json:"comment"` Comment string `json:"comment"`
Creator string `json:"creator"` Creator string `json:"creator"`
SrvUpdated string `json:"updated"` SrvUpdated string `json:"updated"`
LocalUpdated int64 `json:"-"` LocalUpdated int64 `json:"-"`
TimeReg *regexp.Regexp `json:"-"` TimeReg *regexp.Regexp `json:"-"`
PatternReg *regexp.Regexp `json:"-"` PatternReg *regexp.Regexp `json:"-"`
ExcludeReg *regexp.Regexp `json:"-"` ExcludeReg *regexp.Regexp `json:"-"`
TagRegs map[string]*regexp.Regexp `json:"-"` TagRegs map[string]*regexp.Regexp `json:"-"`
ParseSucc bool `json:"parse_succ"` ParseSucc bool `json:"parse_succ"`
WhetherAttacheOneLogLine int `json:"whether_attache_one_log_line"` WhetherAttachOneLogLine int `json:"whether_attach_one_log_line"`
} }
func GetLogCollects() []*Strategy { func GetLogCollects() []*Strategy {
@ -134,8 +134,7 @@ func ToStrategy(p *models.LogCollect) *Strategy {
s.Creator = p.Creator s.Creator = p.Creator
s.SrvUpdated = p.LastUpdated.String() s.SrvUpdated = p.LastUpdated.String()
s.LocalUpdated = p.LocalUpdated s.LocalUpdated = p.LocalUpdated
s.WhetherAttacheOneLogLine = p.WhetherAttacheOneLogLine s.WhetherAttachOneLogLine = p.WhetherAttachOneLogLine
return &s return &s
} }