timelinemanager

package module
v1.7.2 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2020 License: MIT Imports: 10 Imported by: 13

README

Timeline Manager

This library manages multiple timeline instances to allow the use of multiple backends and provides useful shortcut functions to manipulate these timelines.

Timeline library?

Click here

Sample TOML

hashingAlgorithm = "shake128"
hashSize = 6
dataTTL = "2m"
transportBufferSize = 1024
batchSendInterval = "30s"
requestTimeout = "5s"
serializerBufferSize = 2048
debugInput = false
debugOutput = true
timeBetweenBatches = "10ms"
printStackOnError = true

[openTSDBTransport]
    readBufferSize = 64
    maxReadTimeout = "100ms"
    reconnectionTimeout = "3s"
    maxReconnectionRetries = 5
    disconnectAfterWrites = true

[httpTransport]
    serviceEndpoint = "/api/put"
    method = "POST"
    expectedResponseStatus = 204
    timestampProperty = "timestamp"
    valueProperty = "value"

[[backends]]
    addHostTag    = true
    cycleDuration = "15s"
    host          = "host1"
    port          = 8123
    storage       = "normal"
    type          = "opentsdb"
        [backends.commonTags]
        tag1 = "val1"
        tag2 = "val2"
        tag3 = "val3"

[[backends]]
    addHostTag    = true
    cycleDuration = "25s"
    host          = "host2"
    port          = 8124
    storage       = "archive"
    type          = "opentsdb"
        [backends.commonTags]
        tag4 = "val4"
        tag5 = "val5"
        tag6 = "val6"

[[backends]]
    addHostTag    = false
    cycleDuration = "35s"
    host          = "host3"
    port          = 8125
    storage       = "custom"
    type          = "http"
        [backends.commonTags]
        tag7 = "val7"
        tag8 = "val8"
        tag9 = "val9"

Documentation

Index

Constants

View Source
const (
	// NormalStorage - normal storage backend
	NormalStorage StorageType = "normal"

	// ArchiveStorage - archive storage backend
	ArchiveStorage StorageType = "archive"

	// HTTPTransport - http transport type
	HTTPTransport TransportType = "http"

	// OpenTSDBTransport - opentsdb transport type
	OpenTSDBTransport TransportType = "opentsdb"

	// UDPTransport - udp transport type
	UDPTransport TransportType = "udp"

	// JSONSerializer - json serializer type
	JSONSerializer SerializerType = "json"

	// OpenTSDBSerializer - opentsdb serializer type
	OpenTSDBSerializer SerializerType = "opentsdb"
)
View Source
const (
	// RawJSON - defines a no flattened operation
	RawJSON timeline.FlatOperation = 100
	// RawOpenTSDB - defines a no flattened operation
	RawOpenTSDB timeline.FlatOperation = 101
)

Variables

View Source
var ErrStorageNotFound error = fmt.Errorf("storage type not found")

ErrStorageNotFound - raised when a storage type was not found

View Source
var ErrTransportNotSupported error = fmt.Errorf("transport not supported")

ErrTransportNotSupported - raised when a transport is not supported for the specified storage

Functions

This section is empty.

Types

type BackendItem

type BackendItem struct {
	timeline.Backend
	Storage       StorageType       `json:"storage,omitempty"`
	CycleDuration funks.Duration    `json:"cycleDuration,omitempty"`
	AddHostTag    bool              `json:"addHostTag,omitempty"`
	CommonTags    map[string]string `json:"commonTags,omitempty"`
	Transport     string            `json:"transport,omitempty"`
	// contains filtered or unexported fields
}

BackendItem - one backend configuration

type Configuration

type Configuration struct {
	Backends         []BackendItem     `json:"backends,omitempty"`
	HashingAlgorithm hashing.Algorithm `json:"hashingAlgorithm,omitempty"`
	HashSize         int               `json:"hashSize,omitempty"`
	DataTTL          funks.Duration    `json:"dataTTL,omitempty"`
	timeline.DefaultTransportConfig
	OpenTSDBTransports map[string]OpenTSDBTransportConfigExt `json:"openTSDBTransports,omitempty"`
	HTTPTransports     map[string]HTTPTransportConfigExt     `json:"httpTransports,omitempty"`
	UDPTransports      map[string]UDPTransportConfigExt      `json:"udpTransports,omitempty"`
}

Configuration - configuration

func (*Configuration) Validate added in v1.2.1

func (c *Configuration) Validate() error

Validate - validates the configuration

type CustomJSONMapping added in v1.4.1

type CustomJSONMapping struct {
	MappingName string      `json:"mappingName,omitempty"`
	Instance    interface{} `json:"instance,omitempty"`
	Variables   []string    `json:"variables,omitempty"`
}

CustomJSONMapping - a custom json mapping to be added

type HTTPTransportConfigExt added in v1.4.1

type HTTPTransportConfigExt struct {
	TransportExt
	timeline.HTTPTransportConfig
}

HTTPTransportConfigExt - an extension to the timeline.HTTPTransportConfig

type Instance added in v1.2.0

type Instance struct {
	// contains filtered or unexported fields
}

Instance - manages the configured number of timeline manager instances

func New

func New(configuration *Configuration) (*Instance, error)

New - creates a new instance

func (*Instance) AccumulateCustomHashN added in v1.2.0

func (tm *Instance) AccumulateCustomHashN(hash string) (bool, error)

AccumulateCustomHashN - calls the accumulate function using normal storage

func (*Instance) AccumulateHashedData added in v1.2.0

func (tm *Instance) AccumulateHashedData(stype StorageType, hash string) (bool, error)

AccumulateHashedData - accumulates a hashed data

func (*Instance) FlattenAvgN added in v1.2.0

func (tm *Instance) FlattenAvgN(caller string, value float64, metric string, tags ...interface{})

FlattenAvgN - calls the Flatten function using normal storage and average operation

func (*Instance) FlattenCountIncA added in v1.2.0

func (tm *Instance) FlattenCountIncA(caller string, metric string, tags ...interface{})

FlattenCountIncA - calls the Flatten function using archive storage and count operation (adds 1 to the value)

func (*Instance) FlattenCountIncN added in v1.2.0

func (tm *Instance) FlattenCountIncN(caller string, metric string, tags ...interface{})

FlattenCountIncN - calls the Flatten function using normal storage and count operation (adds 1 to the value)

func (*Instance) FlattenCountN added in v1.2.0

func (tm *Instance) FlattenCountN(caller string, value float64, metric string, tags ...interface{})

FlattenCountN - calls the Flatten function using normal storage and count operation

func (*Instance) FlattenMaxN added in v1.2.0

func (tm *Instance) FlattenMaxN(caller string, value float64, metric string, tags ...interface{})

FlattenMaxN - calls the Flatten function using normal storage and maximum operation

func (*Instance) FlattenMinN added in v1.2.0

func (tm *Instance) FlattenMinN(caller string, value float64, metric string, tags ...interface{})

FlattenMinN - calls the Flatten function using normal storage and minimum operation

func (*Instance) GetConfiguredDataTTL added in v1.2.0

func (tm *Instance) GetConfiguredDataTTL() time.Duration

GetConfiguredDataTTL - returns the configured data ttl

func (*Instance) Send added in v1.2.0

func (tm *Instance) Send(caller string, stype StorageType, op timeline.FlatOperation, value float64, metric string, tags ...interface{}) error

Send - send a point or do a flatten operation

func (*Instance) SendCustomJSON added in v1.4.1

func (tm *Instance) SendCustomJSON(caller string, stype StorageType, mappingName string, variables ...interface{}) error

SendCustomJSON - send a custom json point

func (*Instance) SendT added in v1.6.2

func (tm *Instance) SendT(caller string, stype StorageType, op timeline.FlatOperation, value float64, metric string, timestamp int64, tags ...interface{}) error

SendT - send a point or do a flatten operation with specific timestamp

func (*Instance) SendText added in v1.2.0

func (tm *Instance) SendText(caller string, stype StorageType, value, metric string, tags ...interface{}) error

SendText - send a text point

func (*Instance) SendTextT added in v1.6.2

func (tm *Instance) SendTextT(caller string, stype StorageType, value, metric string, timestamp int64, tags ...interface{}) error

SendTextT - send a text point with specific timestamp

func (*Instance) Shutdown added in v1.2.0

func (tm *Instance) Shutdown()

Shutdown - shuts down the timeline manager

func (*Instance) Start added in v1.2.0

func (tm *Instance) Start() error

Start - starts the timeline manager

func (*Instance) StoreCustomHashN added in v1.2.0

func (tm *Instance) StoreCustomHashN(hash string, metric string, tags ...interface{}) error

StoreCustomHashN - calls the store hash function using normal storage

func (*Instance) StoreDefaultTTLCustomHash added in v1.2.0

func (tm *Instance) StoreDefaultTTLCustomHash(storage StorageType, hash string, metric string, tags ...interface{}) error

StoreDefaultTTLCustomHash - stores with default configured ttl

func (*Instance) StoreHashedData added in v1.2.0

func (tm *Instance) StoreHashedData(stype StorageType, hash string, ttl time.Duration, metric string, tags ...interface{}) error

StoreHashedData - stores the hashed data

func (*Instance) StoreNoTTLCustomHashN added in v1.2.0

func (tm *Instance) StoreNoTTLCustomHashN(hash string, metric string, tags ...interface{}) error

StoreNoTTLCustomHashN - calls the store hash function using normal storage with no ttl

type OpenTSDBTransportConfigExt added in v1.5.0

type OpenTSDBTransportConfigExt struct {
	timeline.OpenTSDBTransportConfig
}

OpenTSDBTransportConfigExt - an extension to the timeline.OpenTSDBTransportConfig

type SerializerType added in v1.6.0

type SerializerType string

SerializerType - the serializer type constant

type StorageType

type StorageType string

StorageType - the storage type constant

type TransportExt added in v1.5.0

type TransportExt struct {
	Serializer   SerializerType      `json:"serializer,omitempty"`
	JSONMappings []CustomJSONMapping `json:"jsonMappings,omitempty"`
}

TransportExt - an transport extension

type TransportType added in v1.2.0

type TransportType string

TransportType - the transport type constant

type UDPTransportConfigExt added in v1.6.0

type UDPTransportConfigExt struct {
	TransportExt
	timeline.UDPTransportConfig
}

UDPTransportConfigExt - an extension to the timeline.UDPTransportConfig

Jump to

Keyboard shortcuts

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