Documentation ¶
Index ¶
- Constants
- func AddToAll(metrics *[]Metric, dims map[string]string)
- func AssembleDefaultDimensions(cnt *types.Container) map[string]string
- func AssembleJSONDefaultDimensions(cnt *types.ContainerJSON) map[string]string
- func AssembleJSONServiceSlot(cnt *types.ContainerJSON) string
- func AssembleJSONTaskSlot(cnt *types.ContainerJSON) string
- func AssembleServiceSlot(cnt *types.Container) string
- func AssembleTaskSlot(cnt *types.Container) string
- func LogStrToInt(level string) int
- func ParseValStr(s string) (str string, flt float64, err error)
- func Sha1HashString(s string) string
- type Base
- func (b *Base) AppendSource(src string)
- func (b *Base) GenDefaultID() string
- func (b *Base) GetLastSource() string
- func (b *Base) GetMessageDigest() string
- func (b *Base) GetTimeRFC() string
- func (b *Base) GetTimeUnix() int64
- func (b *Base) GetTimeUnixNano() int64
- func (b *Base) InputsMatch(inputs []string) bool
- func (b *Base) IsLastSource(src string) bool
- func (base *Base) NewExtMetric(src, name string, metricTyp string, val float64, dimensions map[string]string, ...) Metric
- type CPUStats
- type ContainerEvent
- type ContainerStats
- type Dimensions
- type Filter
- type GelfMsg
- type IntMemoryStats
- type MemoryStats
- type Message
- type Metric
- func (m *Metric) AddDimension(name, value string)
- func (m *Metric) AddDimensions(dimensions map[string]string)
- func (m *Metric) DisableBuffering()
- func (m *Metric) EnableBuffering()
- func (m *Metric) GetDimensionList() string
- func (m *Metric) GetDimensionString() string
- func (m *Metric) GetDimensionValue(dimension string) (value string, ok bool)
- func (m *Metric) GetDimensions(defaults map[string]string) (dimensions map[string]string)
- func (m *Metric) IsFiltered(f Filter) bool
- func (m *Metric) IsSubDim(other map[string]string) bool
- func (m *Metric) RemoveDimension(name string)
- func (m *Metric) SetTime(mtime time.Time)
- func (m *Metric) ToJSON() string
- func (m *Metric) ToOpenTSDB() string
- type NetStats
- type OpenTSDBMetric
- type Packet
- type Plugin
- func (p *Plugin) CfgBool(path string) (bool, error)
- func (p *Plugin) CfgBoolOr(path string, alt bool) bool
- func (p *Plugin) CfgInt(path string) (int, error)
- func (p *Plugin) CfgIntOr(path string, alt int) int
- func (p *Plugin) CfgString(path string) (string, error)
- func (p *Plugin) CfgStringOr(path, alt string) string
- func (p *Plugin) DispatchMsgCount()
- func (p *Plugin) GetCfgItems(key string) []string
- func (p *Plugin) GetInputs() (res []string)
- func (p *Plugin) Log(logLevel, msg string)
- func (p *Plugin) SendMsgCount(tick time.Time, pre map[string]float64) map[string]float64
- func (p *Plugin) StartTicker(name string, durMs int) Ticker
- func (p *Plugin) StopProcessingCntEvent(ce ContainerEvent, allowEmptyInput bool) bool
- func (p *Plugin) StopProcessingCntStats(qcs ContainerStats, allowEmptyInput bool) bool
- func (p *Plugin) StopProcessingMessage(qm Message, allowEmptyInput bool) bool
- func (p *Plugin) StopProcessingMetric(qm Metric, allowEmptyInput bool) bool
- type QChan
- type QMsg
- type StatsdPacket
- type Ticker
Constants ¶
const ( MsgCEE = "cee" MsgTCP = "tcp" MsgFile = "file" MsgDLOG = "docker-log" MsgMetric = "metric" //needs to have name,time and value field ; optional tags (key1=val1,key2=val2) )
const ( Gauge = "gauge" Counter = "counter" CumulativeCounter = "cumcounter" )
The different types of metrics that are supported
const ( FILTER = "filter" COLLECTOR = "collector" HANDLER = "handler" CACHE = "cache" )
Variables ¶
This section is empty.
Functions ¶
func AssembleDefaultDimensions ¶ added in v0.5.8
func AssembleJSONDefaultDimensions ¶ added in v0.5.8
func AssembleJSONDefaultDimensions(cnt *types.ContainerJSON) map[string]string
func AssembleJSONServiceSlot ¶ added in v0.5.8
func AssembleJSONServiceSlot(cnt *types.ContainerJSON) string
AssembleServiceSlot create {{.Service.Name}}.{{.Task.Slot}}
func AssembleJSONTaskSlot ¶ added in v0.5.8
func AssembleJSONTaskSlot(cnt *types.ContainerJSON) string
AssembleServiceSlot create {{.Service.Name}}.{{.Task.Slot}}
func AssembleServiceSlot ¶ added in v0.5.6
AssembleServiceSlot create {{.Service.Name}}.{{.Task.Slot}}
func AssembleTaskSlot ¶ added in v0.5.8
AssembleServiceSlot create {{.Service.Name}}.{{.Task.Slot}}
func LogStrToInt ¶ added in v0.5.3
func Sha1HashString ¶ added in v0.5.11
Types ¶
type Base ¶ added in v0.3.0
type Base struct { BaseVersion string ID string Time time.Time SourceID int SourcePath []string SourceSuccess bool Data map[string]string // Additional Data }
func (*Base) AppendSource ¶ added in v0.3.0
func (*Base) GenDefaultID ¶ added in v0.5.11
GenDefaultID uses "<source>-<time.UnixNano()>" and does a sha1 hash.
func (*Base) GetLastSource ¶ added in v0.5.1
func (*Base) GetMessageDigest ¶ added in v0.5.11
func (*Base) GetTimeRFC ¶ added in v0.3.0
func (*Base) GetTimeUnix ¶ added in v0.3.0
func (*Base) GetTimeUnixNano ¶ added in v0.3.0
func (*Base) InputsMatch ¶ added in v0.3.1
func (*Base) IsLastSource ¶ added in v0.3.1
type CPUStats ¶ added in v0.2.1
type CPUStats struct { Base Container *types.Container PerCpuUsage common.MapStr TotalUsage float64 UsageInKernelmode uint64 UsageInKernelmodePercentage float64 UsageInUsermode uint64 UsageInUsermodePercentage float64 SystemUsage uint64 SystemUsagePercentage float64 }
Inspired by https://github.com/elastic/beats/blob/master/metricbeat/module/docker/cpu/helper.go
type ContainerEvent ¶ added in v0.2.2
type ContainerEvent struct { Base Message string Container types.ContainerJSON Event events.Message EngineInfo types.Info }
func NewContainerEvent ¶ added in v0.4.4
func NewContainerEvent(base Base, cnt types.ContainerJSON, event events.Message, info types.Info) ContainerEvent
func (*ContainerEvent) GetContainerName ¶ added in v0.5.9
func (ce *ContainerEvent) GetContainerName() string
type ContainerStats ¶ added in v0.2.1
type ContainerStats struct { Base Stats *docker.Stats Container docker.APIContainers }
func NewContainerStats ¶ added in v0.3.1
func NewContainerStats(src string, stats *docker.Stats, cnt docker.APIContainers) ContainerStats
func (*ContainerStats) GetContainer ¶ added in v0.3.4
func (cs *ContainerStats) GetContainer() *types.Container
func (*ContainerStats) GetCpuStats ¶ added in v0.2.2
func (cs *ContainerStats) GetCpuStats() CPUStats
Flat out copied from https://github.com/elastic/beats
func (*ContainerStats) GetMemStats ¶ added in v0.3.4
func (cs *ContainerStats) GetMemStats() MemoryStats
func (*ContainerStats) GetNetPerIfaceStats ¶ added in v0.4.0
func (cs *ContainerStats) GetNetPerIfaceStats(iface string) NetStats
func (*ContainerStats) GetNetStats ¶ added in v0.4.0
func (cs *ContainerStats) GetNetStats() NetStats
type Dimensions ¶ added in v0.5.4
func NewDimensions ¶ added in v0.5.4
func NewDimensions() Dimensions
func NewDimensionsFromBytes ¶ added in v0.5.10
func NewDimensionsFromBytes(inp []byte) Dimensions
func NewDimensionsFromString ¶ added in v0.5.10
func NewDimensionsFromString(str string) Dimensions
func NewDimensionsPre ¶ added in v0.5.10
func NewDimensionsPre(dims map[string]string) Dimensions
func (*Dimensions) Add ¶ added in v0.5.4
func (dim *Dimensions) Add(key, val string)
func (*Dimensions) GetDims ¶ added in v0.5.10
func (dim *Dimensions) GetDims() map[string]string
func (*Dimensions) String ¶ added in v0.5.4
func (dim *Dimensions) String() string
type Filter ¶ added in v0.2.0
type Filter struct { Name string `json:"name"` MetricType string `json:"type"` Dimensions map[string]string `json:"dimensions"` }
Filter provides a struct that can filter a metric by Name (regex), type, dimension (subset of Dimensions)
type GelfMsg ¶ added in v0.5.8
type GelfMsg struct { Version string `json:"version"` Host string `json:"host"` ShortMsg string `json:"short_message"` TimeNano float64 `json:"timestamp"` Level int `json:"level"` Command string `json:"_command"` ContainerID string `json:"_container_id"` ContainerName string `json:"_container_name"` ImageID string `json:"_image_id"` // Not the Digest! ImageName string `json:"_image_name"` Tag string `json:"_tag"` SourceAddr string }
type IntMemoryStats ¶ added in v0.4.1
func NewIntMemoryStats ¶ added in v0.4.1
func NewIntMemoryStats(src string) IntMemoryStats
func (*IntMemoryStats) SnapShot ¶ added in v0.4.1
func (s *IntMemoryStats) SnapShot()
func (*IntMemoryStats) ToMetrics ¶ added in v0.4.1
func (s *IntMemoryStats) ToMetrics(src string) []Metric
type MemoryStats ¶ added in v0.2.5
type MemoryStats struct { Base Container *types.Container Failcnt float64 Limit float64 MaxUsage float64 TotalRss float64 TotalRssP float64 Usage float64 UsageP float64 }
Inspired by https://github.com/elastic/beats/blob/master/metricbeat/module/docker/cpu/helper.go
func NewMemoryStats ¶ added in v0.2.5
func NewMemoryStats(src Base, stats *dc.Stats) MemoryStats
func (*MemoryStats) ToMetrics ¶ added in v0.3.4
func (ms *MemoryStats) ToMetrics(src string) []Metric
type Message ¶ added in v0.4.3
type Message struct { Base Container types.ContainerJSON Name string `json:"name"` LogLevel string `json:"loglevel"` MessageType string `json:"type"` Message string `json:"value"` KV map[string]string `json:"data"` }
func NewContainerMessage ¶ added in v0.4.3
func NewContainerMessage(base Base, cnt types.ContainerJSON, name, mType, msg string) Message
func NewMessage ¶ added in v0.4.3
func (*Message) GenContainerMsgID ¶ added in v0.5.11
GenContainerMsgID uses "<container_id>-<time.UnixNano()>-<MSG>" and does a sha1 hash.
func (*Message) GetContainerName ¶ added in v0.4.3
type Metric ¶ added in v0.2.0
type Metric struct { Base Name string `json:"name"` MetricType string `json:"type"` Value float64 `json:"value"` Dimensions map[string]string `json:"dimensions"` Buffered bool `json:"buffered"` }
Metric type holds all the information for a single metric data point. Metrics are generated in collectors and passed to handlers.
func New ¶ added in v0.2.0
New returns a new metric with name. Default metric type is "gauge" and timestamp is set to now. Value is initialized to 0.0.
func NewExt ¶ added in v0.2.0
func NewExt(source, name string, metricTyp string, val float64, dimensions map[string]string, t time.Time, buffered bool) Metric
NewExt provides a more controled creation
func (*Metric) AddDimension ¶ added in v0.2.0
AddDimension adds a new dimension to the Metric.
func (*Metric) AddDimensions ¶ added in v0.2.0
AddDimensions adds multiple new dimensions to the Metric.
func (*Metric) DisableBuffering ¶ added in v0.2.0
func (m *Metric) DisableBuffering()
DisableBuffering takes the metric out of buffering (e.g. ZmqBUF)
func (*Metric) EnableBuffering ¶ added in v0.2.0
func (m *Metric) EnableBuffering()
EnableBuffering puts the metric into buffering handlers (e.g. ZmqBUF)
func (*Metric) GetDimensionList ¶ added in v0.3.2
func (*Metric) GetDimensionString ¶ added in v0.5.3
func (*Metric) GetDimensionValue ¶ added in v0.2.0
GetDimensionValue returns the value of a dimension if it's set.
func (*Metric) GetDimensions ¶ added in v0.2.0
GetDimensions returns the dimensions of a metric merged with defaults. Defaults win.
func (*Metric) IsFiltered ¶ added in v0.2.0
IsFiltered checks if metrics is filtered with a given filter
func (*Metric) IsSubDim ¶ added in v0.2.0
IsSubDim checks if the 2st map contains all items in the second
func (*Metric) RemoveDimension ¶ added in v0.2.0
RemoveDimension removes a dimension from the Metric.
func (*Metric) ToOpenTSDB ¶ added in v0.5.3
type NetStats ¶ added in v0.4.0
type NetStats struct { Base Container *types.Container NameInterface string RxBytes float64 RxDropped float64 RxErrors float64 RxPackets float64 TxBytes float64 TxDropped float64 TxErrors float64 TxPackets float64 }
Inspired by https://github.com/elastic/beats/blob/master/metricbeat/module/docker/net/helper.go
func AggregateNetStats ¶ added in v0.4.0
type OpenTSDBMetric ¶ added in v0.5.12
type OpenTSDBMetric struct { Metric string `json:"metric"` Timestamp int `json:"timestamp"` Value float64 `json:"value"` Tags map[string]string `json:"tags"` }
func (*OpenTSDBMetric) String ¶ added in v0.5.12
func (otm *OpenTSDBMetric) String() string
type Plugin ¶
type Plugin struct { QChan QChan Cfg *config.Config MyID int Typ string Pkg string Version string Name string LogOnlyPlugs []string MsgCount map[string]float64 LocalCfg map[string]string }
func NewNamedPlugin ¶ added in v0.1.2
func (*Plugin) CfgStringOr ¶ added in v0.1.2
func (*Plugin) DispatchMsgCount ¶ added in v0.5.4
func (p *Plugin) DispatchMsgCount()
func (*Plugin) GetCfgItems ¶ added in v0.4.4
func (*Plugin) SendMsgCount ¶ added in v0.5.4
func (*Plugin) StartTicker ¶ added in v0.4.2
func (*Plugin) StopProcessingCntEvent ¶ added in v0.5.4
func (p *Plugin) StopProcessingCntEvent(ce ContainerEvent, allowEmptyInput bool) bool
func (*Plugin) StopProcessingCntStats ¶ added in v0.5.4
func (p *Plugin) StopProcessingCntStats(qcs ContainerStats, allowEmptyInput bool) bool
func (*Plugin) StopProcessingMessage ¶ added in v0.5.4
************** This mess needs to be abstracted...
Interface over all messages or such
type QChan ¶
type QChan struct { Data *bcast.Group Back *bcast.Group Tick *bcast.Group Cfg *config.Config Done chan os.Signal }
QChan holds the broadcast channels to communicate
func NewCfgQChan ¶ added in v0.5.12
func NewCfgQChan(cfg *config.Config) QChan
NewQChan create an instance of QChan
type QMsg ¶
type QMsg struct { QmsgVersion string `json:qmsg_version` Type string `json:"type"` Source string `json:"source"` SourceSuccess bool `json:"source_success"` SourcePath []string `json:"source_path"` SourceID int `json:"source_id"` Host string `json:"host"` Msg string `json:"short_message"` Time time.Time `json:"time"` TimeNano int64 `json:"time_nano"` Level int `json:"level"` //https://en.wikipedia.org/wiki/Syslog#Severity_level KV map[string]string `json:"kv"` Data interface{} `json:"data"` }
func (*QMsg) TimeString ¶
type StatsdPacket ¶ added in v0.5.4
type StatsdPacket struct { Bucket string ValFlt float64 ValStr string Modifier string Sampling float32 Dimensions Dimensions }
func NewStatsdPacket ¶ added in v0.5.4
func NewStatsdPacket(bucket string, val string, modifier string) *StatsdPacket
func NewStatsdPacketDims ¶ added in v0.5.10
func NewStatsdPacketDims(bucket string, val string, modifier string, dims Dimensions) *StatsdPacket
func (*StatsdPacket) AddDimension ¶ added in v0.5.4
func (sd *StatsdPacket) AddDimension(key, val string)
func (*StatsdPacket) DimensionString ¶ added in v0.5.4
func (sd *StatsdPacket) DimensionString() string
func (*StatsdPacket) GenerateID ¶ added in v0.5.10
func (sd *StatsdPacket) GenerateID() string
func (*StatsdPacket) GetBucketKey ¶ added in v0.5.10
func (sd *StatsdPacket) GetBucketKey() string
func (*StatsdPacket) GetDims ¶ added in v0.5.10
func (sd *StatsdPacket) GetDims() map[string]string