qtypes

package module
v0.5.12 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2017 License: Apache-2.0 Imports: 22 Imported by: 52

README

qframe-types

Types package for qframe-static

Documentation

Index

Constants

View Source
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)
)
View Source
const (
	Gauge             = "gauge"
	Counter           = "counter"
	CumulativeCounter = "cumcounter"
)

The different types of metrics that are supported

View Source
const (
	FILTER    = "filter"
	COLLECTOR = "collector"
	HANDLER   = "handler"
	CACHE     = "cache"
)

Variables

This section is empty.

Functions

func AddToAll added in v0.2.0

func AddToAll(metrics *[]Metric, dims map[string]string)

AddToAll adds a map of dimensions to a list of metrics

func AssembleDefaultDimensions added in v0.5.8

func AssembleDefaultDimensions(cnt *types.Container) map[string]string

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

func AssembleServiceSlot(cnt *types.Container) string

AssembleServiceSlot create {{.Service.Name}}.{{.Task.Slot}}

func AssembleTaskSlot added in v0.5.8

func AssembleTaskSlot(cnt *types.Container) string

AssembleServiceSlot create {{.Service.Name}}.{{.Task.Slot}}

func LogStrToInt added in v0.5.3

func LogStrToInt(level string) int

func ParseValStr added in v0.5.10

func ParseValStr(s string) (str string, flt float64, err error)

func Sha1HashString added in v0.5.11

func Sha1HashString(s string) string

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 NewBase added in v0.3.0

func NewBase(src string) Base

func NewTimedBase added in v0.3.0

func NewTimedBase(src string, t time.Time) Base

func (*Base) AppendSource added in v0.3.0

func (b *Base) AppendSource(src string)

func (*Base) GenDefaultID added in v0.5.11

func (b *Base) GenDefaultID() string

GenDefaultID uses "<source>-<time.UnixNano()>" and does a sha1 hash.

func (*Base) GetLastSource added in v0.5.1

func (b *Base) GetLastSource() string

func (*Base) GetMessageDigest added in v0.5.11

func (b *Base) GetMessageDigest() string

func (*Base) GetTimeRFC added in v0.3.0

func (b *Base) GetTimeRFC() string

func (*Base) GetTimeUnix added in v0.3.0

func (b *Base) GetTimeUnix() int64

func (*Base) GetTimeUnixNano added in v0.3.0

func (b *Base) GetTimeUnixNano() int64

func (*Base) InputsMatch added in v0.3.1

func (b *Base) InputsMatch(inputs []string) bool

func (*Base) IsLastSource added in v0.3.1

func (b *Base) IsLastSource(src string) bool

func (*Base) NewExtMetric added in v0.3.2

func (base *Base) NewExtMetric(src, name string, metricTyp string, val float64, dimensions map[string]string, t time.Time, buffered bool) Metric

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

func NewCPUStats added in v0.2.5

func NewCPUStats(src Base, stats *dc.Stats) *CPUStats

func (*CPUStats) ToMetrics added in v0.2.2

func (cs *CPUStats) ToMetrics(src string) []Metric

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

type Dimensions struct {
	Map map[string]string
}

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)

func NewFilter added in v0.2.0

func NewFilter(name string, t string, d map[string]string) Filter

NewFilter returns a Filter with compiled regex

func (*Filter) ToJSON added in v0.2.0

func (f *Filter) ToJSON() string

ToJSON Transforms Filter to JSON

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

type IntMemoryStats struct {
	Base
	Stats        *runtime.MemStats
	NumGoroutine int
}

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 NewMessage(base Base, name, mType, msg string) Message

func (*Message) GenContainerMsgID added in v0.5.11

func (m *Message) GenContainerMsgID() string

GenContainerMsgID uses "<container_id>-<time.UnixNano()>-<MSG>" and does a sha1 hash.

func (*Message) GetContainerName added in v0.4.3

func (m *Message) GetContainerName() string

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

func New(source, name string) Metric

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 WithValue added in v0.2.0

func WithValue(source, name string, value float64) Metric

WithValue returns metric with value of type Gauge

func (*Metric) AddDimension added in v0.2.0

func (m *Metric) AddDimension(name, value string)

AddDimension adds a new dimension to the Metric.

func (*Metric) AddDimensions added in v0.2.0

func (m *Metric) AddDimensions(dimensions map[string]string)

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 (m *Metric) GetDimensionList() string

func (*Metric) GetDimensionString added in v0.5.3

func (m *Metric) GetDimensionString() string

func (*Metric) GetDimensionValue added in v0.2.0

func (m *Metric) GetDimensionValue(dimension string) (value string, ok bool)

GetDimensionValue returns the value of a dimension if it's set.

func (*Metric) GetDimensions added in v0.2.0

func (m *Metric) GetDimensions(defaults map[string]string) (dimensions map[string]string)

GetDimensions returns the dimensions of a metric merged with defaults. Defaults win.

func (*Metric) IsFiltered added in v0.2.0

func (m *Metric) IsFiltered(f Filter) bool

IsFiltered checks if metrics is filtered with a given filter

func (*Metric) IsSubDim added in v0.2.0

func (m *Metric) IsSubDim(other map[string]string) bool

IsSubDim checks if the 2st map contains all items in the second

func (*Metric) RemoveDimension added in v0.2.0

func (m *Metric) RemoveDimension(name string)

RemoveDimension removes a dimension from the Metric.

func (*Metric) SetTime added in v0.2.0

func (m *Metric) SetTime(mtime time.Time)

SetTime to metric

func (*Metric) ToJSON added in v0.2.0

func (m *Metric) ToJSON() string

ToJSON Transforms metric to JSON

func (*Metric) ToOpenTSDB added in v0.5.3

func (m *Metric) ToOpenTSDB() string

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

func AggregateNetStats(iface string, s1, s2 NetStats) NetStats

func NewNetStats added in v0.4.0

func NewNetStats(base Base, cnt *types.Container) NetStats

func (*NetStats) ToMetrics added in v0.4.0

func (ns *NetStats) ToMetrics(src string) []Metric

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 Packet added in v0.5.10

type Packet struct {
	Bucket   string
	ValFlt   float64
	ValStr   string
	Modifier string
	Sampling float32
}

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 NewNamedPlugin(qChan QChan, cfg *config.Config, typ, pkg, name, version string) Plugin

func NewPlugin

func NewPlugin(qChan QChan, cfg *config.Config) Plugin

func (*Plugin) CfgBool added in v0.1.3

func (p *Plugin) CfgBool(path string) (bool, error)

func (*Plugin) CfgBoolOr added in v0.1.3

func (p *Plugin) CfgBoolOr(path string, alt bool) bool

func (*Plugin) CfgInt added in v0.2.6

func (p *Plugin) CfgInt(path string) (int, error)

func (*Plugin) CfgIntOr added in v0.2.6

func (p *Plugin) CfgIntOr(path string, alt int) int

func (*Plugin) CfgString added in v0.1.3

func (p *Plugin) CfgString(path string) (string, error)

func (*Plugin) CfgStringOr added in v0.1.2

func (p *Plugin) CfgStringOr(path, alt string) string

func (*Plugin) DispatchMsgCount added in v0.5.4

func (p *Plugin) DispatchMsgCount()

func (*Plugin) GetCfgItems added in v0.4.4

func (p *Plugin) GetCfgItems(key string) []string

func (*Plugin) GetInputs added in v0.1.3

func (p *Plugin) GetInputs() (res []string)

func (*Plugin) Log added in v0.1.2

func (p *Plugin) Log(logLevel, msg string)

func (*Plugin) SendMsgCount added in v0.5.4

func (p *Plugin) SendMsgCount(tick time.Time, pre map[string]float64) map[string]float64

func (*Plugin) StartTicker added in v0.4.2

func (p *Plugin) StartTicker(name string, durMs int) Ticker

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

func (p *Plugin) StopProcessingMessage(qm Message, allowEmptyInput bool) bool

************** This mess needs to be abstracted...

Interface over all messages or such

func (*Plugin) StopProcessingMetric added in v0.5.4

func (p *Plugin) StopProcessingMetric(qm Metric, allowEmptyInput bool) bool

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

func NewQChan

func NewQChan() QChan

NewQChan create an instance of QChan

func (*QChan) Broadcast

func (qc *QChan) Broadcast()

func (*QChan) Log added in v0.5.12

func (qc *QChan) Log(logLevel, msg string)

func (*QChan) SendData added in v0.5.4

func (qc *QChan) SendData(val interface{})

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 NewQMsg

func NewQMsg(typ, source string) QMsg

func (*QMsg) LogString

func (qm *QMsg) LogString() (lout string)

func (*QMsg) TimeString

func (qm *QMsg) TimeString() (lout string)

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

type Ticker added in v0.4.2

type Ticker struct {
	Name              string
	Duration          time.Duration
	DurationMs        int
	DurationTolerance float64
	ForceTick         bool
	Tick              time.Time
	LastTick          time.Time
}

func NewForceTicker added in v0.4.2

func NewForceTicker(name string, durMs int) Ticker

func NewTicker added in v0.4.2

func NewTicker(name string, durMs int) Ticker

func (Ticker) DispatchTicker added in v0.4.2

func (t Ticker) DispatchTicker(qchan QChan)

func (*Ticker) SkipTick added in v0.4.2

func (t *Ticker) SkipTick(lastTick time.Time) (time.Duration, bool)

Jump to

Keyboard shortcuts

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