gather

package
v0.0.0-...-cf7c423 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 28, 2018 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ENABLE  = 1
	DISABLE = 0
)

Variables

This section is empty.

Functions

func GetLineTime

func GetLineTime(line *string, format *string) (*time.Time, error)

获取日志时间

func Init

func Init(cfgFile string)

func Run

func Run()

启动所有采集任务

func Test

func Test(line string)

Types

type Config

type Config struct {
	Enable bool         `json:"enable"` //是否启用
	Files  []GatherFile `json:"files"`  //需要采集的文件
}

type GatherFile

type GatherFile struct {
	Enable     bool         `json:"enable"`      //是否启用
	ReportStep int          `json:"report_step"` //上报间隔 默认60s
	File       string       `json:"file"`        //文件名
	Format     string       `json:"format"`      //时间格式 默认:2006-01-02 15:04:05
	Items      []GatherItem `json:"items"`       //采集项目
}

type GatherItem

type GatherItem struct {
	Metric string   `json:"metric"` //指标名称
	Rule   string   `json:"rule"`   //采集正则表达式
	Tags   []string `json:"tags"`   //key=正则表达式
	Type   string   `json:"type"`   //上报方式 默认GAUGE 支持MAX、MIN、SUM、AVG
}

type GatherStat

type GatherStat struct {
	Total   float64
	Counter float64
	Max     float64
	Min     float64
}

func (*GatherStat) Rest

func (gs *GatherStat) Rest()

type GatherWorker

type GatherWorker struct {
	GFile      *GatherFile
	ReadPos    int64
	DataChan   []chan *LogInfo
	MetricChan chan *model.MetricValue
}

func NewGatherWorker

func NewGatherWorker(gf *GatherFile) *GatherWorker

func (*GatherWorker) GatherData

func (gw *GatherWorker) GatherData(tag_key string, value float64, tagsStat map[string]*GatherStat)

搜集数据

func (*GatherWorker) ParseLine

func (gw *GatherWorker) ParseLine(line *string, regexpLine *regexp.Regexp, regexpTags map[string]*regexp.Regexp, item *GatherItem) (float64, string, error)

func (*GatherWorker) ReportData

func (gw *GatherWorker) ReportData(item *GatherItem, tagsStat map[string]*GatherStat)

上报数据

func (*GatherWorker) SubWorker

func (gw *GatherWorker) SubWorker(ch chan *LogInfo, item *GatherItem)

单指标上报

func (*GatherWorker) Worker

func (gw *GatherWorker) Worker()

一个文件解析

type LogInfo

type LogInfo struct {
	LogLine *string
	LogTime *time.Time
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL