metric

package
v2.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MetricTypeNone       = "none"
	MetricTypeString     = "string"
	MetricTypeCounter    = "counter"
	MetricTypeGauge      = "gauge"
	MetricTypeGaugeFloat = "gauge_float"
	MetricTypeBinary     = "binary"
	MetricTypeGEO        = "geo" // Geo Coordinates or GPS
)

Metric types

View Source
const (
	FieldValue     = "value"
	FieldLatitude  = "latitude"
	FieldLongitude = "longitude"
	FieldAltitude  = "altitude"
)

Fields

View Source
const (
	QueryKeyName       = "name"
	QueryKeyMetricType = "metric_type"
	QueryKeyStart      = "start"
	QueryKeyStop       = "stop"
	QueryKeyWindow     = "window"
	QueryKeyTags       = "tags"
	QueryKeyFunctions  = "functions"
)

Metric query input parameters

View Source
const (
	UnitNone       = ""
	UnitCelsius    = "°C"
	UnitFahrenheit = "°F"
	UnitPercent    = "%"
	UnitVoltage    = "V"
	UnitAmpere     = "A"
)

units used across providers

Variables

This section is empty.

Functions

func GetMetricLogger

func GetMetricLogger() *zap.Logger

returns a logger with environment values

func WithContext

func WithContext(ctx context.Context, metric Plugin) context.Context

Types

type InputData

type InputData struct {
	MetricType string                 `json:"metricType"`
	Time       time.Time              `json:"timestamp"`
	Tags       map[string]string      `json:"tags"`
	Fields     map[string]interface{} `json:"fields"`
}

InputData to write

type Plugin

type Plugin interface {
	Name() string
	Close() error
	Ping() error
	Write(data *InputData) error
	WriteBlocking(data *InputData) error
	Query(queryConfig *QueryConfig) (map[string][]ResponseData, error)
}

Plugin interface

func FromContext

func FromContext(ctx context.Context) (Plugin, error)

type Query

type Query struct {
	Name       string            `json:"name"`
	MetricType string            `json:"metricType"`
	Start      string            `json:"start"`
	Stop       string            `json:"stop"`
	Window     string            `json:"window"`
	Tags       map[string]string `json:"tags"`
	Functions  []string          `json:"functions"`
}

Query paramaters

func (*Query) Clone

func (q *Query) Clone() Query

Clone a query

func (*Query) Merge

func (q *Query) Merge(new *Query)

Merge data from another query

type QueryConfig

type QueryConfig struct {
	Global     Query   `json:"global"`
	Individual []Query `json:"individual"`
}

QueryConfig parameters

type ResponseData

type ResponseData struct {
	Time       time.Time              `json:"timestamp"`
	MetricType string                 `json:"metricType"`
	Metric     map[string]interface{} `json:"metric"`
}

ResponseData struct

Jump to

Keyboard shortcuts

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