Documentation
¶
Index ¶
- Variables
- func DefaultIPs(t configs.IPType) []string
- func GetListeningIPs(addr string) []string
- func GetSystemType() string
- func HashLabels(lbs labels.Labels) string
- func Map2slice(m map[string]struct{}) []string
- func MatchTraces(labels map[string]string) (string, string)
- func SendFailEvent(dataID int32, e chan<- define.Event)
- func UniqueSlice(lst []string) []string
- type BaseTask
- func (t *BaseTask) GetConfig() define.TaskConfig
- func (t *BaseTask) GetGlobalConfig() define.Config
- func (t *BaseTask) GetSemaphore() Semaphore
- func (t *BaseTask) GetStatus() define.Status
- func (t *BaseTask) GetTaskID() int32
- func (t *BaseTask) Init()
- func (t *BaseTask) PostRun(ctx context.Context)
- func (t *BaseTask) PreRun(ctx context.Context)
- func (t *BaseTask) Reload()
- func (t *BaseTask) SetConfig(config define.TaskConfig)
- func (t *BaseTask) SetGlobalConfig(config define.Config)
- func (t *BaseTask) Stop()
- func (t *BaseTask) Wait()
- type BufferBuilder
- type CmdbEventSender
- type CustomMetricEvent
- type Event
- func (e *Event) AsMapStr() common.MapStr
- func (e *Event) Fail(code define.NamedCode)
- func (e *Event) FailWithTime(code define.NamedCode, start, end time.Time)
- func (e *Event) GetType() string
- func (e *Event) IgnoreCMDBLevel() bool
- func (e *Event) Success()
- func (e *Event) SuccessOrTimeout()
- func (e *Event) SuccessWithTime(start, end time.Time)
- func (e *Event) TaskDuration() time.Duration
- type EventTask
- type GatherUpEvent
- func NewGatherUpEvent(task define.Task, upCode define.NamedCode) *GatherUpEvent
- func NewGatherUpEventWithConfig(dataID int32, taskConfig define.TaskConfig, upCode define.NamedCode, ...) *GatherUpEvent
- func NewGatherUpEventWithDims(task define.Task, upCode define.NamedCode, customDims common.MapStr) *GatherUpEvent
- func NewGatherUpEventWithValue(task define.Task, upCode define.NamedCode, value float64) *GatherUpEvent
- type HostInfo
- type MetricEvent
- type NoopSemaphore
- type PingEvent
- type PromEvent
- type Semaphore
- type SemaphorePool
- type SimpleEvent
- type StandardEvent
- type StatusEvent
- type TimestampHandler
Constants ¶
This section is empty.
Variables ¶
var DefaultSemaphorePool = NewSemaphorePool()
var ErrNaN = errors.New("value is NaN or Inf")
var LookupIP = func(ctx context.Context, t configs.IPType, domain string) ([]net.IP, error) { // 选择解析ip类型 var network string switch t { case configs.IPv4: network = "ip4" case configs.IPv6: network = "ip6" default: network = "ip" } ret := utils.CheckIpOrDomainValid(domain) if ret == utils.Domain { network = "ip" } ips, err := net.DefaultResolver.LookupIP(ctx, network, domain) if err != nil { return nil, err } resultIPs := make([]net.IP, 0, len(ips)) for _, ip := range ips { if ip == nil { logger.Debugf("ips is empty") continue } if p4 := ip.To4(); p4 != nil { ip = p4 } resultIPs = append(resultIPs, ip) } if len(resultIPs) == 0 { return nil, &net.AddrError{ Err: "no address found", Addr: domain, } } return resultIPs, nil }
LookupIP 按照类型解析域名为ip列表
Functions ¶
func HashLabels ¶
func UniqueSlice ¶
Types ¶
type BaseTask ¶
type BaseTask struct { Status define.Status GlobalConfig define.Config TaskConfig define.TaskConfig HookPreRun utils.HookManager HookPostRun utils.HookManager // contains filtered or unexported fields }
BaseTask :
func (*BaseTask) GetConfig ¶
func (t *BaseTask) GetConfig() define.TaskConfig
func (*BaseTask) GetGlobalConfig ¶
func (*BaseTask) GetSemaphore ¶
func (*BaseTask) SetConfig ¶
func (t *BaseTask) SetConfig(config define.TaskConfig)
func (*BaseTask) SetGlobalConfig ¶
type BufferBuilder ¶
type BufferBuilder struct {
// contains filtered or unexported fields
}
BufferBuilder :
func (*BufferBuilder) GetBuffer ¶
func (b *BufferBuilder) GetBuffer(initSize int) []byte
GetBuffer :
type CmdbEventSender ¶
type CmdbEventSender struct {
// contains filtered or unexported fields
}
func (*CmdbEventSender) DuplicateRecordByCMDBLevel ¶
func (s *CmdbEventSender) DuplicateRecordByCMDBLevel(m common.MapStr, labels []configs.Label) []common.MapStr
DuplicateRecordByCMDBLevel 根据下发的信息,将一条数据复制为多条返回
type CustomMetricEvent ¶
type CustomMetricEvent struct { *MetricEvent Timestamp int64 }
CustomMetricEvent metricbeat转自定义时序上报
func (*CustomMetricEvent) AsMapStr ¶
func (e *CustomMetricEvent) AsMapStr() common.MapStr
type Event ¶
type Event struct { DataID int32 BizID int32 TaskID int32 TaskType string Available float64 Status int32 ErrorCode define.NamedCode StartAt time.Time EndAt time.Time AvailableDuration time.Duration Labels []map[string]string }
Event :
func (*Event) FailWithTime ¶
func (*Event) SuccessWithTime ¶
type EventTask ¶
type EventTask struct { BaseTask // contains filtered or unexported fields }
EventTask 事件任务类型
func (*EventTask) CheckRunning ¶
CheckRunning 检查是否正在运行,使用锁控制
func (*EventTask) ResetRunningState ¶
func (t *EventTask) ResetRunningState()
ResetRunningState 重置running锁
type GatherUpEvent ¶
type GatherUpEvent struct { DataID int32 Time time.Time Metrics common.MapStr Dimensions common.MapStr }
func NewGatherUpEvent ¶
func NewGatherUpEvent(task define.Task, upCode define.NamedCode) *GatherUpEvent
func NewGatherUpEventWithConfig ¶
func NewGatherUpEventWithConfig(dataID int32, taskConfig define.TaskConfig, upCode define.NamedCode, customDims common.MapStr, value float64) *GatherUpEvent
func (*GatherUpEvent) AsMapStr ¶
func (e *GatherUpEvent) AsMapStr() common.MapStr
func (*GatherUpEvent) GetType ¶
func (e *GatherUpEvent) GetType() string
func (*GatherUpEvent) IgnoreCMDBLevel ¶
func (e *GatherUpEvent) IgnoreCMDBLevel() bool
func (*GatherUpEvent) KVs ¶
func (e *GatherUpEvent) KVs() []define.LogKV
type MetricEvent ¶
MetricEvent :
func (*MetricEvent) GetType ¶
func (e *MetricEvent) GetType() string
type NoopSemaphore ¶
type NoopSemaphore struct{}
func (*NoopSemaphore) Release ¶
func (ns *NoopSemaphore) Release(_ int64)
func (*NoopSemaphore) TryAcquire ¶
func (ns *NoopSemaphore) TryAcquire(_ int64) bool
type PromEvent ¶
type PromEvent struct { Key string Value float64 Labels common.MapStr AggValue common.MapStr DimensionString string // ordered dimension string HashKey string TS int64 Exemplar *exemplar.Exemplar }
PromEvent store the lines prometheus data
func NewPromEvent ¶
func NewPromEvent(line string, ts int64, offsetTime time.Duration, handler TimestampHandler) (PromEvent, error)
NewPromEvent 优先使用 V2 作为解析方式 出错再回退到 V1 还出错的话就抛出异常
func NewPromEventFast ¶
func NewPromEventFast(line string, ts int64, offsetTime time.Duration, handler TimestampHandler) (PromEvent, error)
NewPromEventFast 同 NewPromEvent 但不计算 PromEvent 哈希值
func (*PromEvent) GetAggValue ¶
GetAggValue get same timestamp and same dimension metrics
func (*PromEvent) GetTimestamp ¶
GetTimestamp get the timestamp of the metric or local time
func (*PromEvent) ProduceHashKey ¶
func (pe *PromEvent) ProduceHashKey()
ProduceHashKey the hash of dimension map string
type Semaphore ¶
type Semaphore interface { Acquire(ctx context.Context, n int64) error TryAcquire(n int64) bool Release(n int64) }
Semaphore 统一信号量接口
type SemaphorePool ¶
type SemaphorePool struct {
// contains filtered or unexported fields
}
func NewSemaphorePool ¶
func NewSemaphorePool() *SemaphorePool
NewSemaphorePool 获取信号量池,同一池同key的信号量限制互通
func (*SemaphorePool) Delete ¶
func (p *SemaphorePool) Delete(key string)
func (*SemaphorePool) GetSemaphore ¶
GetSemaphore 获取信号量实例,weight以第一次配置为准,同pool所有实例同key共享信号量
type SimpleEvent ¶
type SimpleEvent struct { *Event TargetHost string TargetPort int ResolvedIP string // DNS解析模式为全部时对应的实际请求IP,其他情况为空 }
SimpleEvent :
type StandardEvent ¶
type StandardEvent struct { StatusEvent Labels []map[string]string DataID int32 BizID int32 TaskID int32 Time time.Time Metrics map[string]interface{} Dimensions map[string]string }
StandardEvent :
func NewStandardEvent ¶
func NewStandardEvent(task define.TaskConfig) *StandardEvent
NewStandardEvent :
type StatusEvent ¶
StatusEvent 状态参数
func (*StatusEvent) GetType ¶
func (e *StatusEvent) GetType() string
func (*StatusEvent) IgnoreCMDBLevel ¶
func (e *StatusEvent) IgnoreCMDBLevel() bool
IgnoreCMDBLevel :
type TimestampHandler ¶
TimestampHandler 默认为ms,其他情况自行计算
func GetTimestampHandler ¶
func GetTimestampHandler(timestampUnit string) (TimestampHandler, error)
GetTimestampHandler 获取时间戳处理工具