Documentation ¶
Overview ¶
Package metrics contains a type for aggregating and propagating metrics to various services based on configuration.
Index ¶
- Constants
- Variables
- func Descriptions() string
- func OptSetLogger(log log.Modular) func(Type)
- func SanitiseConfig(conf Config) (interface{}, error)
- func WalkConstructors(fn func(ConstructorFunc, docs.ComponentSpec))
- type Blacklist
- func (h *Blacklist) Close() error
- func (h *Blacklist) GetCounter(path string) StatCounter
- func (h *Blacklist) GetCounterVec(path string, n []string) StatCounterVec
- func (h *Blacklist) GetGauge(path string) StatGauge
- func (h *Blacklist) GetGaugeVec(path string, n []string) StatGaugeVec
- func (h *Blacklist) GetTimer(path string) StatTimer
- func (h *Blacklist) GetTimerVec(path string, n []string) StatTimerVec
- func (h *Blacklist) HandlerFunc() http.HandlerFunc
- func (h *Blacklist) SetLogger(log log.Modular)
- type BlacklistConfig
- type CloudWatch
- func (c *CloudWatch) Close() error
- func (c *CloudWatch) GetCounter(path string) StatCounter
- func (c *CloudWatch) GetCounterVec(path string, n []string) StatCounterVec
- func (c *CloudWatch) GetGauge(path string) StatGauge
- func (c *CloudWatch) GetGaugeVec(path string, n []string) StatGaugeVec
- func (c *CloudWatch) GetTimer(path string) StatTimer
- func (c *CloudWatch) GetTimerVec(path string, n []string) StatTimerVec
- func (c *CloudWatch) SetLogger(log log.Modular)
- type CloudWatchConfig
- type Config
- type ConstructorFunc
- type DudStat
- type DudType
- func (d DudType) Close() error
- func (d DudType) GetCounter(path string) StatCounter
- func (d DudType) GetCounterVec(path string, n []string) StatCounterVec
- func (d DudType) GetGauge(path string) StatGauge
- func (d DudType) GetGaugeVec(path string, n []string) StatGaugeVec
- func (d DudType) GetTimer(path string) StatTimer
- func (d DudType) GetTimerVec(path string, n []string) StatTimerVec
- func (d DudType) SetLogger(log log.Modular)
- type Flat
- type HTTP
- func (h *HTTP) Close() error
- func (h *HTTP) GetCounter(path string) StatCounter
- func (h *HTTP) GetCounterVec(path string, n []string) StatCounterVec
- func (h *HTTP) GetGauge(path string) StatGauge
- func (h *HTTP) GetGaugeVec(path string, n []string) StatGaugeVec
- func (h *HTTP) GetTimer(path string) StatTimer
- func (h *HTTP) GetTimerVec(path string, n []string) StatTimerVec
- func (h *HTTP) HandlerFunc() http.HandlerFunc
- func (h *HTTP) SetLogger(log log.Modular)
- type HTTPConfig
- type InfluxDB
- func (i *InfluxDB) Close() error
- func (i *InfluxDB) GetCounter(path string) StatCounter
- func (i *InfluxDB) GetCounterVec(path string, n []string) StatCounterVec
- func (i *InfluxDB) GetGauge(path string) StatGauge
- func (i *InfluxDB) GetGaugeVec(path string, n []string) StatGaugeVec
- func (i *InfluxDB) GetTimer(path string) StatTimer
- func (i *InfluxDB) GetTimerVec(path string, n []string) StatTimerVec
- func (i *InfluxDB) SetLogger(log log.Modular)
- type InfluxDBConfig
- type InfluxDBInclude
- type Local
- func (l *Local) Close() error
- func (l *Local) FlushCounters() map[string]int64
- func (l *Local) FlushTimings() map[string]int64
- func (l *Local) GetCounter(path string) StatCounter
- func (l *Local) GetCounterVec(path string, k []string) StatCounterVec
- func (l *Local) GetCounters() map[string]int64
- func (l *Local) GetCountersWithLabels() map[string]LocalStat
- func (l *Local) GetGauge(path string) StatGauge
- func (l *Local) GetGaugeVec(path string, k []string) StatGaugeVec
- func (l *Local) GetTimer(path string) StatTimer
- func (l *Local) GetTimerVec(path string, k []string) StatTimerVec
- func (l *Local) GetTimings() map[string]int64
- func (l *Local) GetTimingsWithLabels() map[string]LocalStat
- func (l *Local) SetLogger(logger log.Modular)
- type LocalStat
- type PromCounter
- type PromCounterVec
- type PromGauge
- type PromGaugeVec
- type PromTiming
- type PromTimingHistVec
- type PromTimingVec
- type Prometheus
- func (p *Prometheus) Close() error
- func (p *Prometheus) GetCounter(path string) StatCounter
- func (p *Prometheus) GetCounterVec(path string, labelNames []string) StatCounterVec
- func (p *Prometheus) GetGauge(path string) StatGauge
- func (p *Prometheus) GetGaugeVec(path string, labelNames []string) StatGaugeVec
- func (p *Prometheus) GetTimer(path string) StatTimer
- func (p *Prometheus) GetTimerVec(path string, labelNames []string) StatTimerVec
- func (p *Prometheus) HandlerFunc() http.HandlerFunc
- func (p *Prometheus) SetLogger(log log.Modular)
- type PrometheusConfig
- type PrometheusPushBasicAuthConfig
- type Rename
- func (r *Rename) Close() error
- func (r *Rename) GetCounter(path string) StatCounter
- func (r *Rename) GetCounterVec(path string, n []string) StatCounterVec
- func (r *Rename) GetGauge(path string) StatGauge
- func (r *Rename) GetGaugeVec(path string, n []string) StatGaugeVec
- func (r *Rename) GetTimer(path string) StatTimer
- func (r *Rename) GetTimerVec(path string, n []string) StatTimerVec
- func (r *Rename) HandlerFunc() http.HandlerFunc
- func (r *Rename) SetLogger(log log.Modular)
- type RenameByRegexpConfig
- type RenameConfig
- type StatCounter
- type StatCounterVec
- type StatGauge
- type StatGaugeVec
- type StatTimer
- type StatTimerVec
- type Statsd
- func (h *Statsd) Close() error
- func (h *Statsd) GetCounter(path string) StatCounter
- func (h *Statsd) GetCounterVec(path string, n []string) StatCounterVec
- func (h *Statsd) GetGauge(path string) StatGauge
- func (h *Statsd) GetGaugeVec(path string, n []string) StatGaugeVec
- func (h *Statsd) GetTimer(path string) StatTimer
- func (h *Statsd) GetTimerVec(path string, n []string) StatTimerVec
- func (h *Statsd) SetLogger(log log.Modular)
- type StatsdConfig
- type StatsdLegacy
- func (h *StatsdLegacy) Close() error
- func (h *StatsdLegacy) GetCounter(path string) StatCounter
- func (h *StatsdLegacy) GetCounterVec(path string, n []string) StatCounterVec
- func (h *StatsdLegacy) GetGauge(path string) StatGauge
- func (h *StatsdLegacy) GetGaugeVec(path string, n []string) StatGaugeVec
- func (h *StatsdLegacy) GetTimer(path string) StatTimer
- func (h *StatsdLegacy) GetTimerVec(path string, n []string) StatTimerVec
- func (h *StatsdLegacy) SetLogger(log log.Modular)
- type StatsdLegacyStat
- type StatsdStat
- type Stdout
- func (s *Stdout) Close() error
- func (s *Stdout) GetCounter(path string) StatCounter
- func (s *Stdout) GetCounterVec(path string, n []string) StatCounterVec
- func (s *Stdout) GetGauge(path string) StatGauge
- func (s *Stdout) GetGaugeVec(path string, n []string) StatGaugeVec
- func (s *Stdout) GetTimer(path string) StatTimer
- func (s *Stdout) GetTimerVec(path string, n []string) StatTimerVec
- func (s *Stdout) SetLogger(log log.Modular)
- type StdoutConfig
- type Type
- func Combine(t1, t2 Type) Type
- func Namespaced(t Type, ns string) Type
- func New(conf Config, opts ...func(Type)) (Type, error)
- func NewAWSCloudWatch(config Config, opts ...func(Type)) (Type, error)
- func NewBlacklist(config Config, opts ...func(Type)) (Type, error)
- func NewCloudWatch(config Config, opts ...func(Type)) (Type, error)
- func NewHTTP(config Config, opts ...func(Type)) (Type, error)
- func NewInfluxDB(config Config, opts ...func(Type)) (Type, error)
- func NewPrometheus(config Config, opts ...func(Type)) (Type, error)
- func NewRename(config Config, opts ...func(Type)) (Type, error)
- func NewStatsd(config Config, opts ...func(Type)) (Type, error)
- func NewStatsdLegacy(config Config, opts ...func(Type)) (Type, error)
- func NewStdout(config Config, opts ...func(Type)) (Type, error)
- func NewWhitelist(config Config, opts ...func(Type)) (Type, error)
- func WrapFlat(f Flat) Type
- type TypeSpec
- type Whitelist
- func (h *Whitelist) Close() error
- func (h *Whitelist) GetCounter(path string) StatCounter
- func (h *Whitelist) GetCounterVec(path string, n []string) StatCounterVec
- func (h *Whitelist) GetGauge(path string) StatGauge
- func (h *Whitelist) GetGaugeVec(path string, n []string) StatGaugeVec
- func (h *Whitelist) GetTimer(path string) StatTimer
- func (h *Whitelist) GetTimerVec(path string, n []string) StatTimerVec
- func (h *Whitelist) HandlerFunc() http.HandlerFunc
- func (h *Whitelist) SetLogger(log log.Modular)
- type WhitelistConfig
- type WithHandlerFunc
Constants ¶
const ( TypeAWSCloudWatch = "aws_cloudwatch" TypeBlackList = "blacklist" TypeCloudWatch = "cloudwatch" TypeHTTPServer = "http_server" TypeInfluxDB = "influxdb" TypeNone = "none" TypePrometheus = "prometheus" TypeRename = "rename" TypeStatsd = "statsd" TypeStdout = "stdout" TypeWhiteList = "whitelist" )
String constants representing each metric type.
const ( TagFormatNone = "none" TagFormatDatadog = "datadog" TagFormatInfluxDB = "influxdb" TagFormatLegacy = "legacy" )
Tag formats supported by the statsd metric type.
Variables ¶
var Constructors = map[string]TypeSpec{}
Constructors is a map of all metrics types with their specs.
var (
ErrInvalidMetricOutputType = errors.New("invalid metrics output type")
)
Errors for the metrics package.
var (
ErrTimedOut = errors.New("timed out")
)
Errors for the HTTP type.
Functions ¶
func Descriptions ¶
func Descriptions() string
Descriptions returns a formatted string of collated descriptions of each type.
func OptSetLogger ¶
OptSetLogger sets the logging output to be used by the metrics clients.
func SanitiseConfig ¶
SanitiseConfig returns a sanitised version of the Config, meaning sections that aren't relevant to behaviour are removed.
func WalkConstructors ¶ added in v3.43.0
func WalkConstructors(fn func(ConstructorFunc, docs.ComponentSpec))
WalkConstructors iterates each component constructor.
Types ¶
type Blacklist ¶
type Blacklist struct {
// contains filtered or unexported fields
}
Blacklist is a statistics object that wraps a separate statistics object and only permits statistics that pass through the Blacklist to be recorded.
func (*Blacklist) Close ¶
Close stops the Statsd object from aggregating metrics and cleans up resources.
func (*Blacklist) GetCounter ¶
func (h *Blacklist) GetCounter(path string) StatCounter
GetCounter returns a stat counter object for a path.
func (*Blacklist) GetCounterVec ¶
func (h *Blacklist) GetCounterVec(path string, n []string) StatCounterVec
GetCounterVec returns a stat counter object for a path with the labels discarded.
func (*Blacklist) GetGaugeVec ¶
func (h *Blacklist) GetGaugeVec(path string, n []string) StatGaugeVec
GetGaugeVec returns a stat timer object for a path with the labels discarded.
func (*Blacklist) GetTimerVec ¶
func (h *Blacklist) GetTimerVec(path string, n []string) StatTimerVec
GetTimerVec returns a stat timer object for a path with the labels discarded.
func (*Blacklist) HandlerFunc ¶
func (h *Blacklist) HandlerFunc() http.HandlerFunc
HandlerFunc returns an http.HandlerFunc for accessing metrics for appropriate child types
type BlacklistConfig ¶
type BlacklistConfig struct { Paths []string `json:"paths" yaml:"paths"` Patterns []string `json:"patterns" yaml:"patterns"` Child *Config `json:"child" yaml:"child"` }
BlacklistConfig allows for the placement of filtering rules to only allow metrics that are not matched to be displayed or retrieved. It has a set of prefixes (direct string comparison) that are checked as well as a set of regular expressions for more precise control over metrics. It also has a metrics configuration that is wrapped by the Blacklist.
func NewBlacklistConfig ¶
func NewBlacklistConfig() BlacklistConfig
NewBlacklistConfig returns the default configuration for a Blacklist
func (BlacklistConfig) MarshalJSON ¶
func (w BlacklistConfig) MarshalJSON() ([]byte, error)
MarshalJSON prints an empty object instead of nil.
func (BlacklistConfig) MarshalYAML ¶
func (w BlacklistConfig) MarshalYAML() (interface{}, error)
MarshalYAML prints an empty object instead of nil.
type CloudWatch ¶ added in v3.9.0
type CloudWatch struct {
// contains filtered or unexported fields
}
CloudWatch is a stats object with capability to hold internal stats as a JSON endpoint.
func (*CloudWatch) Close ¶ added in v3.9.0
func (c *CloudWatch) Close() error
Close stops the CloudWatch object from aggregating metrics and cleans up resources.
func (*CloudWatch) GetCounter ¶ added in v3.9.0
func (c *CloudWatch) GetCounter(path string) StatCounter
GetCounter returns a stat counter object for a path.
func (*CloudWatch) GetCounterVec ¶ added in v3.9.0
func (c *CloudWatch) GetCounterVec(path string, n []string) StatCounterVec
GetCounterVec returns a stat counter object for a path with the labels
func (*CloudWatch) GetGauge ¶ added in v3.9.0
func (c *CloudWatch) GetGauge(path string) StatGauge
GetGauge returns a stat gauge object for a path.
func (*CloudWatch) GetGaugeVec ¶ added in v3.9.0
func (c *CloudWatch) GetGaugeVec(path string, n []string) StatGaugeVec
GetGaugeVec returns a stat timer object for a path with the labels
func (*CloudWatch) GetTimer ¶ added in v3.9.0
func (c *CloudWatch) GetTimer(path string) StatTimer
GetTimer returns a stat timer object for a path.
func (*CloudWatch) GetTimerVec ¶ added in v3.9.0
func (c *CloudWatch) GetTimerVec(path string, n []string) StatTimerVec
GetTimerVec returns a stat timer object for a path with the labels
func (*CloudWatch) SetLogger ¶ added in v3.9.0
func (c *CloudWatch) SetLogger(log log.Modular)
SetLogger sets the logger used to print connection errors.
type CloudWatchConfig ¶ added in v3.9.0
type CloudWatchConfig struct { session.Config `json:",inline" yaml:",inline"` Namespace string `json:"namespace" yaml:"namespace"` FlushPeriod string `json:"flush_period" yaml:"flush_period"` PathMapping string `json:"path_mapping" yaml:"path_mapping"` }
CloudWatchConfig contains config fields for the CloudWatch metrics type.
func NewCloudWatchConfig ¶ added in v3.9.0
func NewCloudWatchConfig() CloudWatchConfig
NewCloudWatchConfig creates an CloudWatchConfig struct with default values.
type Config ¶
type Config struct { Type string `json:"type" yaml:"type"` AWSCloudWatch CloudWatchConfig `json:"aws_cloudwatch" yaml:"aws_cloudwatch"` Blacklist BlacklistConfig `json:"blacklist" yaml:"blacklist"` CloudWatch CloudWatchConfig `json:"cloudwatch" yaml:"cloudwatch"` HTTP HTTPConfig `json:"http_server" yaml:"http_server"` InfluxDB InfluxDBConfig `json:"influxdb" yaml:"influxdb"` None struct{} `json:"none" yaml:"none"` Prometheus PrometheusConfig `json:"prometheus" yaml:"prometheus"` Rename RenameConfig `json:"rename" yaml:"rename"` Statsd StatsdConfig `json:"statsd" yaml:"statsd"` Stdout StdoutConfig `json:"stdout" yaml:"stdout"` Whitelist WhitelistConfig `json:"whitelist" yaml:"whitelist"` }
Config is the all encompassing configuration struct for all metric output types.
func NewConfig ¶
func NewConfig() Config
NewConfig returns a configuration struct fully populated with default values.
func (Config) Sanitised ¶ added in v3.24.0
Sanitised returns a sanitised version of the config, meaning sections that aren't relevant to behaviour are removed. Also optionally removes deprecated fields.
func (*Config) UnmarshalJSON ¶
UnmarshalJSON ensures that when parsing configs that are in a map or slice the default values are still applied.
func (*Config) UnmarshalYAML ¶
UnmarshalYAML ensures that when parsing configs that are in a map or slice the default values are still applied.
type ConstructorFunc ¶ added in v3.43.0
ConstructorFunc is a func signature able to construct a metrics output.
type DudStat ¶
type DudStat struct{}
DudStat implements the Stat interface but doesn't actual do anything.
type DudType ¶
type DudType struct {
ID int
}
DudType implements the Type interface but doesn't actual do anything.
func (DudType) GetCounter ¶
func (d DudType) GetCounter(path string) StatCounter
GetCounter returns a DudStat.
func (DudType) GetCounterVec ¶
func (d DudType) GetCounterVec(path string, n []string) StatCounterVec
GetCounterVec returns a DudStat.
func (DudType) GetGaugeVec ¶
func (d DudType) GetGaugeVec(path string, n []string) StatGaugeVec
GetGaugeVec returns a DudStat.
func (DudType) GetTimerVec ¶
func (d DudType) GetTimerVec(path string, n []string) StatTimerVec
GetTimerVec returns a DudStat.
type Flat ¶
type Flat interface { // Flat is an interface for setting metrics via flat paths. // Incr increments a metric by an amount. Incr(path string, count int64) error // Decr decrements a metric by an amount. Decr(path string, count int64) error // Timing sets a timing metric. Timing(path string, delta int64) error // Gauge sets a gauge metric. Gauge(path string, value int64) error // Close stops aggregating stats and cleans up resources. Close() error }
Flat is an interface for setting metrics via flat paths.
type HTTP ¶
type HTTP struct {
// contains filtered or unexported fields
}
HTTP is an object with capability to hold internal stats as a JSON endpoint.
func (*HTTP) GetCounter ¶
func (h *HTTP) GetCounter(path string) StatCounter
GetCounter returns a stat counter object for a path.
func (*HTTP) GetCounterVec ¶
func (h *HTTP) GetCounterVec(path string, n []string) StatCounterVec
GetCounterVec returns a stat counter object for a path with the labels discarded.
func (*HTTP) GetGaugeVec ¶
func (h *HTTP) GetGaugeVec(path string, n []string) StatGaugeVec
GetGaugeVec returns a stat timer object for a path with the labels discarded.
func (*HTTP) GetTimerVec ¶
func (h *HTTP) GetTimerVec(path string, n []string) StatTimerVec
GetTimerVec returns a stat timer object for a path with the labels discarded.
func (*HTTP) HandlerFunc ¶
func (h *HTTP) HandlerFunc() http.HandlerFunc
HandlerFunc returns an http.HandlerFunc for accessing metrics as a JSON blob.
type HTTPConfig ¶
type HTTPConfig struct { Prefix string `json:"prefix" yaml:"prefix"` PathMapping string `json:"path_mapping" yaml:"path_mapping"` }
HTTPConfig contains configuration parameters for the HTTP metrics aggregator.
func NewHTTPConfig ¶
func NewHTTPConfig() HTTPConfig
NewHTTPConfig returns a new HTTPConfig with default values.
type InfluxDB ¶ added in v3.36.0
type InfluxDB struct {
// contains filtered or unexported fields
}
InfluxDB is the stats and client holder
func (*InfluxDB) Close ¶ added in v3.36.0
Close reports metrics one last time and stops the InfluxDB object and closes the underlying client connection
func (*InfluxDB) GetCounter ¶ added in v3.36.0
func (i *InfluxDB) GetCounter(path string) StatCounter
GetCounter returns a stat counter object for a path.
func (*InfluxDB) GetCounterVec ¶ added in v3.36.0
func (i *InfluxDB) GetCounterVec(path string, n []string) StatCounterVec
GetCounterVec returns a stat counter object for a path with the labels
func (*InfluxDB) GetGaugeVec ¶ added in v3.36.0
func (i *InfluxDB) GetGaugeVec(path string, n []string) StatGaugeVec
GetGaugeVec returns a stat timer object for a path with the labels
func (*InfluxDB) GetTimerVec ¶ added in v3.36.0
func (i *InfluxDB) GetTimerVec(path string, n []string) StatTimerVec
GetTimerVec returns a stat timer object for a path with the labels
type InfluxDBConfig ¶ added in v3.36.0
type InfluxDBConfig struct { URL string `json:"url" yaml:"url"` DB string `json:"db" yaml:"db"` TLS btls.Config `json:"tls" yaml:"tls"` Interval string `json:"interval" yaml:"interval"` Password string `json:"password" yaml:"password"` PingInterval string `json:"ping_interval" yaml:"ping_interval"` Precision string `json:"precision" yaml:"precision"` Timeout string `json:"timeout" yaml:"timeout"` Username string `json:"username" yaml:"username"` RetentionPolicy string `json:"retention_policy" yaml:"retention_policy"` WriteConsistency string `json:"write_consistency" yaml:"write_consistency"` Include InfluxDBInclude `json:"include" yaml:"include"` PathMapping string `json:"path_mapping" yaml:"path_mapping"` Tags map[string]string `json:"tags" yaml:"tags"` }
InfluxDBConfig is config for the influx metrics type.
func NewInfluxDBConfig ¶ added in v3.36.0
func NewInfluxDBConfig() InfluxDBConfig
NewInfluxDBConfig creates an InfluxDBConfig struct with default values.
type InfluxDBInclude ¶ added in v3.36.0
type InfluxDBInclude struct { Runtime string `json:"runtime" yaml:"runtime"` DebugGC string `json:"debug_gc" yaml:"debug_gc"` }
InfluxDBInclude contains configuration parameters for optional metrics to include.
type Local ¶
type Local struct {
// contains filtered or unexported fields
}
Local is a metrics aggregator that stores metrics locally.
func (*Local) Close ¶
Close stops the Local object from aggregating metrics and cleans up resources.
func (*Local) FlushCounters ¶ added in v3.3.0
FlushCounters returns a map of the current state of the metrics paths to counters and then resets the counters to 0
func (*Local) FlushTimings ¶ added in v3.3.0
FlushTimings returns a map of the current state of the metrics paths to counters and then resets the counters to 0
func (*Local) GetCounter ¶
func (l *Local) GetCounter(path string) StatCounter
GetCounter returns a stat counter object for a path.
func (*Local) GetCounterVec ¶
func (l *Local) GetCounterVec(path string, k []string) StatCounterVec
GetCounterVec returns a stat counter object for a path and records the labels and values.
func (*Local) GetCounters ¶
GetCounters returns a map of metric paths to counters.
func (*Local) GetCountersWithLabels ¶ added in v3.1.0
GetCountersWithLabels returns a map of metric paths to counters including labels and values.
func (*Local) GetGaugeVec ¶
func (l *Local) GetGaugeVec(path string, k []string) StatGaugeVec
GetGaugeVec returns a stat timer object for a path with the labels discarded.
func (*Local) GetTimerVec ¶
func (l *Local) GetTimerVec(path string, k []string) StatTimerVec
GetTimerVec returns a stat timer object for a path with the labels and values.
func (*Local) GetTimings ¶
GetTimings returns a map of metric paths to timers.
func (*Local) GetTimingsWithLabels ¶ added in v3.1.0
GetTimingsWithLabels returns a map of metric paths to timers, including labels and values.
type LocalStat ¶
type LocalStat struct { Value *int64 // contains filtered or unexported fields }
LocalStat is a representation of a single metric stat. Interactions with this stat are thread safe.
func (*LocalStat) HasLabelWithValue ¶ added in v3.1.0
HasLabelWithValue takes a label/value pair and returns true if that combination has been recorded, or false otherwise.
This is mostly useful in tests for custom processors.
type PromCounter ¶
type PromCounter struct {
// contains filtered or unexported fields
}
PromCounter is a representation of a single metric stat. Interactions with this stat are thread safe.
func (*PromCounter) Incr ¶
func (p *PromCounter) Incr(count int64) error
Incr increments a metric by an amount.
type PromCounterVec ¶
type PromCounterVec struct {
// contains filtered or unexported fields
}
PromCounterVec creates StatCounters with dynamic labels.
func (*PromCounterVec) With ¶
func (p *PromCounterVec) With(labelValues ...string) StatCounter
With returns a StatCounter with a set of label values.
type PromGauge ¶
type PromGauge struct {
// contains filtered or unexported fields
}
PromGauge is a representation of a single metric stat. Interactions with this stat are thread safe.
type PromGaugeVec ¶
type PromGaugeVec struct {
// contains filtered or unexported fields
}
PromGaugeVec creates StatGauges with dynamic labels.
func (*PromGaugeVec) With ¶
func (p *PromGaugeVec) With(labelValues ...string) StatGauge
With returns a StatGauge with a set of label values.
type PromTiming ¶
type PromTiming struct {
// contains filtered or unexported fields
}
PromTiming is a representation of a single metric stat. Interactions with this stat are thread safe.
func (*PromTiming) Timing ¶
func (p *PromTiming) Timing(val int64) error
Timing sets a timing metric.
type PromTimingHistVec ¶ added in v3.63.0
type PromTimingHistVec struct {
// contains filtered or unexported fields
}
PromTimingHistVec creates StatTimers with dynamic labels.
func (*PromTimingHistVec) With ¶ added in v3.63.0
func (p *PromTimingHistVec) With(labelValues ...string) StatTimer
With returns a StatTimer with a set of label values.
type PromTimingVec ¶
type PromTimingVec struct {
// contains filtered or unexported fields
}
PromTimingVec creates StatTimers with dynamic labels.
func (*PromTimingVec) With ¶
func (p *PromTimingVec) With(labelValues ...string) StatTimer
With returns a StatTimer with a set of label values.
type Prometheus ¶
type Prometheus struct {
// contains filtered or unexported fields
}
Prometheus is a stats object with capability to hold internal stats as a JSON endpoint.
func (*Prometheus) Close ¶
func (p *Prometheus) Close() error
Close stops the Prometheus object from aggregating metrics and cleans up resources.
func (*Prometheus) GetCounter ¶
func (p *Prometheus) GetCounter(path string) StatCounter
GetCounter returns a stat counter object for a path.
func (*Prometheus) GetCounterVec ¶
func (p *Prometheus) GetCounterVec(path string, labelNames []string) StatCounterVec
GetCounterVec returns an editable counter stat for a given path with labels, these labels must be consistent with any other metrics registered on the same path.
func (*Prometheus) GetGauge ¶
func (p *Prometheus) GetGauge(path string) StatGauge
GetGauge returns a stat gauge object for a path.
func (*Prometheus) GetGaugeVec ¶
func (p *Prometheus) GetGaugeVec(path string, labelNames []string) StatGaugeVec
GetGaugeVec returns an editable gauge stat for a given path with labels, these labels must be consistent with any other metrics registered on the same path.
func (*Prometheus) GetTimer ¶
func (p *Prometheus) GetTimer(path string) StatTimer
GetTimer returns a stat timer object for a path.
func (*Prometheus) GetTimerVec ¶
func (p *Prometheus) GetTimerVec(path string, labelNames []string) StatTimerVec
GetTimerVec returns an editable timer stat for a given path with labels, these labels must be consistent with any other metrics registered on the same path.
func (*Prometheus) HandlerFunc ¶
func (p *Prometheus) HandlerFunc() http.HandlerFunc
HandlerFunc returns an http.HandlerFunc for scraping metrics.
func (*Prometheus) SetLogger ¶
func (p *Prometheus) SetLogger(log log.Modular)
SetLogger does nothing.
type PrometheusConfig ¶
type PrometheusConfig struct { Prefix string `json:"prefix" yaml:"prefix"` PathMapping string `json:"path_mapping" yaml:"path_mapping"` UseHistogramTiming bool `json:"use_histogram_timing" yaml:"use_histogram_timing"` HistogramBuckets []float64 `json:"histogram_buckets" yaml:"histogram_buckets"` PushURL string `json:"push_url" yaml:"push_url"` PushBasicAuth PrometheusPushBasicAuthConfig `json:"push_basic_auth" yaml:"push_basic_auth"` PushInterval string `json:"push_interval" yaml:"push_interval"` PushJobName string `json:"push_job_name" yaml:"push_job_name"` }
PrometheusConfig is config for the Prometheus metrics type.
func NewPrometheusConfig ¶
func NewPrometheusConfig() PrometheusConfig
NewPrometheusConfig creates an PrometheusConfig struct with default values.
type PrometheusPushBasicAuthConfig ¶ added in v3.35.0
type PrometheusPushBasicAuthConfig struct { Username string `json:"username" yaml:"username"` Password string `json:"password" yaml:"password"` }
PrometheusPushBasicAuthConfig contains parameters for establishing basic authentication against a push service.
func NewPrometheusPushBasicAuthConfig ¶ added in v3.35.0
func NewPrometheusPushBasicAuthConfig() PrometheusPushBasicAuthConfig
NewPrometheusPushBasicAuthConfig creates a new NewPrometheusPushBasicAuthConfig with default values.
type Rename ¶
type Rename struct {
// contains filtered or unexported fields
}
Rename is a statistics object that wraps a separate statistics object and only permits statistics that pass through the whitelist to be recorded.
func (*Rename) Close ¶
Close stops the Statsd object from aggregating metrics and cleans up resources.
func (*Rename) GetCounter ¶
func (r *Rename) GetCounter(path string) StatCounter
GetCounter returns a stat counter object for a path.
func (*Rename) GetCounterVec ¶
func (r *Rename) GetCounterVec(path string, n []string) StatCounterVec
GetCounterVec returns a stat counter object for a path with the labels and values.
func (*Rename) GetGaugeVec ¶
func (r *Rename) GetGaugeVec(path string, n []string) StatGaugeVec
GetGaugeVec returns a stat timer object for a path with the labels discarded.
func (*Rename) GetTimerVec ¶
func (r *Rename) GetTimerVec(path string, n []string) StatTimerVec
GetTimerVec returns a stat timer object for a path with the labels and values.
func (*Rename) HandlerFunc ¶
func (r *Rename) HandlerFunc() http.HandlerFunc
HandlerFunc returns an http.HandlerFunc for accessing metrics for appropriate child types
type RenameByRegexpConfig ¶
type RenameByRegexpConfig struct { Pattern string `json:"pattern" yaml:"pattern"` Value string `json:"value" yaml:"value"` Labels map[string]string `json:"to_label" yaml:"to_label"` }
RenameByRegexpConfig contains config fields for a rename by regular expression pattern.
type RenameConfig ¶
type RenameConfig struct { ByRegexp []RenameByRegexpConfig `json:"by_regexp" yaml:"by_regexp"` Child *Config `json:"child" yaml:"child"` }
RenameConfig contains config fields for the Rename metric type.
func NewRenameConfig ¶
func NewRenameConfig() RenameConfig
NewRenameConfig returns a RenameConfig with default values.
func (RenameConfig) MarshalJSON ¶
func (w RenameConfig) MarshalJSON() ([]byte, error)
MarshalJSON prints an empty object instead of nil.
func (RenameConfig) MarshalYAML ¶
func (w RenameConfig) MarshalYAML() (interface{}, error)
MarshalYAML prints an empty object instead of nil.
type StatCounter ¶
StatCounter is a representation of a single counter metric stat. Interactions with this stat are thread safe.
type StatCounterVec ¶
type StatCounterVec interface { // With returns a StatCounter with a set of label values. With(labelValues ...string) StatCounter }
StatCounterVec creates StatCounters with dynamic labels.
type StatGauge ¶
type StatGauge interface { // Set sets the value of a gauge metric. Set(value int64) error // Incr increments a gauge by an amount. Incr(count int64) error // Decr decrements a gauge by an amount. Decr(count int64) error }
StatGauge is a representation of a single gauge metric stat. Interactions with this stat are thread safe.
type StatGaugeVec ¶
type StatGaugeVec interface { // With returns a StatGauge with a set of label values. With(labelValues ...string) StatGauge }
StatGaugeVec creates StatGauges with dynamic labels.
type StatTimer ¶
StatTimer is a representation of a single timer metric stat. Interactions with this stat are thread safe.
type StatTimerVec ¶
type StatTimerVec interface { // With returns a StatTimer with a set of label values. With(labelValues ...string) StatTimer }
StatTimerVec creates StatTimers with dynamic labels.
type Statsd ¶
type Statsd struct {
// contains filtered or unexported fields
}
Statsd is a stats object with capability to hold internal stats as a JSON endpoint.
func (*Statsd) Close ¶
Close stops the Statsd object from aggregating metrics and cleans up resources.
func (*Statsd) GetCounter ¶
func (h *Statsd) GetCounter(path string) StatCounter
GetCounter returns a stat counter object for a path.
func (*Statsd) GetCounterVec ¶
func (h *Statsd) GetCounterVec(path string, n []string) StatCounterVec
GetCounterVec returns a stat counter object for a path with the labels
func (*Statsd) GetGaugeVec ¶
func (h *Statsd) GetGaugeVec(path string, n []string) StatGaugeVec
GetGaugeVec returns a stat timer object for a path with the labels
func (*Statsd) GetTimerVec ¶
func (h *Statsd) GetTimerVec(path string, n []string) StatTimerVec
GetTimerVec returns a stat timer object for a path with the labels
type StatsdConfig ¶
type StatsdConfig struct { Prefix string `json:"prefix" yaml:"prefix"` PathMapping string `json:"path_mapping" yaml:"path_mapping"` Address string `json:"address" yaml:"address"` FlushPeriod string `json:"flush_period" yaml:"flush_period"` Network string `json:"network" yaml:"network"` TagFormat string `json:"tag_format" yaml:"tag_format"` }
StatsdConfig is config for the Statsd metrics type.
func NewStatsdConfig ¶
func NewStatsdConfig() StatsdConfig
NewStatsdConfig creates an StatsdConfig struct with default values.
type StatsdLegacy ¶ added in v3.7.0
type StatsdLegacy struct {
// contains filtered or unexported fields
}
StatsdLegacy is a stats object with capability to hold internal stats as a JSON endpoint.
func (*StatsdLegacy) Close ¶ added in v3.7.0
func (h *StatsdLegacy) Close() error
Close stops the StatsdLegacy object from aggregating metrics and cleans up resources.
func (*StatsdLegacy) GetCounter ¶ added in v3.7.0
func (h *StatsdLegacy) GetCounter(path string) StatCounter
GetCounter returns a stat counter object for a path.
func (*StatsdLegacy) GetCounterVec ¶ added in v3.7.0
func (h *StatsdLegacy) GetCounterVec(path string, n []string) StatCounterVec
GetCounterVec returns a stat counter object for a path with the labels discarded.
func (*StatsdLegacy) GetGauge ¶ added in v3.7.0
func (h *StatsdLegacy) GetGauge(path string) StatGauge
GetGauge returns a stat gauge object for a path.
func (*StatsdLegacy) GetGaugeVec ¶ added in v3.7.0
func (h *StatsdLegacy) GetGaugeVec(path string, n []string) StatGaugeVec
GetGaugeVec returns a stat timer object for a path with the labels discarded.
func (*StatsdLegacy) GetTimer ¶ added in v3.7.0
func (h *StatsdLegacy) GetTimer(path string) StatTimer
GetTimer returns a stat timer object for a path.
func (*StatsdLegacy) GetTimerVec ¶ added in v3.7.0
func (h *StatsdLegacy) GetTimerVec(path string, n []string) StatTimerVec
GetTimerVec returns a stat timer object for a path with the labels discarded.
func (*StatsdLegacy) SetLogger ¶ added in v3.7.0
func (h *StatsdLegacy) SetLogger(log log.Modular)
SetLogger sets the logger used to print connection errors.
type StatsdLegacyStat ¶ added in v3.7.0
type StatsdLegacyStat struct {
// contains filtered or unexported fields
}
StatsdLegacyStat is a representation of a single metric stat. Interactions with this stat are thread safe.
func (*StatsdLegacyStat) Decr ¶ added in v3.7.0
func (s *StatsdLegacyStat) Decr(count int64) error
Decr decrements a metric by an amount.
func (*StatsdLegacyStat) Incr ¶ added in v3.7.0
func (s *StatsdLegacyStat) Incr(count int64) error
Incr increments a metric by an amount.
func (*StatsdLegacyStat) Set ¶ added in v3.7.0
func (s *StatsdLegacyStat) Set(value int64) error
Set sets a gauge metric.
func (*StatsdLegacyStat) Timing ¶ added in v3.7.0
func (s *StatsdLegacyStat) Timing(delta int64) error
Timing sets a timing metric.
type StatsdStat ¶
type StatsdStat struct {
// contains filtered or unexported fields
}
StatsdStat is a representation of a single metric stat. Interactions with this stat are thread safe.
func (*StatsdStat) Decr ¶
func (s *StatsdStat) Decr(count int64) error
Decr decrements a metric by an amount.
func (*StatsdStat) Incr ¶
func (s *StatsdStat) Incr(count int64) error
Incr increments a metric by an amount.
func (*StatsdStat) Timing ¶
func (s *StatsdStat) Timing(delta int64) error
Timing sets a timing metric.
type Stdout ¶ added in v3.3.0
type Stdout struct {
// contains filtered or unexported fields
}
Stdout is an object with capability to hold internal stats and emit them as individual JSON objects via stdout.
func (*Stdout) Close ¶ added in v3.3.0
Close stops the Stdout object from aggregating metrics and does a publish (write to stdout) of metrics.
func (*Stdout) GetCounter ¶ added in v3.3.0
func (s *Stdout) GetCounter(path string) StatCounter
GetCounter returns a stat counter object for a path.
func (*Stdout) GetCounterVec ¶ added in v3.3.0
func (s *Stdout) GetCounterVec(path string, n []string) StatCounterVec
GetCounterVec returns a stat counter object for a path with the labels discarded.
func (*Stdout) GetGaugeVec ¶ added in v3.3.0
func (s *Stdout) GetGaugeVec(path string, n []string) StatGaugeVec
GetGaugeVec returns a stat timer object for a path with the labels discarded.
func (*Stdout) GetTimerVec ¶ added in v3.3.0
func (s *Stdout) GetTimerVec(path string, n []string) StatTimerVec
GetTimerVec returns a stat timer object for a path with the labels discarded.
type StdoutConfig ¶ added in v3.3.0
type StdoutConfig struct { PushInterval string `json:"push_interval" yaml:"push_interval"` StaticFields map[string]interface{} `json:"static_fields" yaml:"static_fields"` FlushMetrics bool `json:"flush_metrics" yaml:"flush_metrics"` PathMapping string `json:"path_mapping" yaml:"path_mapping"` }
StdoutConfig contains configuration parameters for the Stdout metrics aggregator.
func NewStdoutConfig ¶ added in v3.3.0
func NewStdoutConfig() StdoutConfig
NewStdoutConfig returns a new StdoutConfig with default values.
type Type ¶
type Type interface { // GetCounter returns an editable counter stat for a given path. GetCounter(path string) StatCounter // GetCounterVec returns an editable counter stat for a given path with // labels, these labels must be consistent with any other metrics registered // on the same path. GetCounterVec(path string, labelNames []string) StatCounterVec // GetTimer returns an editable timer stat for a given path. GetTimer(path string) StatTimer // GetTimerVec returns an editable timer stat for a given path with labels, // these labels must be consistent with any other metrics registered on the // same path. GetTimerVec(path string, labelNames []string) StatTimerVec // GetGauge returns an editable gauge stat for a given path. GetGauge(path string) StatGauge // GetGaugeVec returns an editable gauge stat for a given path with labels, // these labels must be consistent with any other metrics registered on the // same path. GetGaugeVec(path string, labelNames []string) StatGaugeVec // SetLogger sets the logging mechanism of the metrics type. SetLogger(log log.Modular) // Close stops aggregating stats and cleans up resources. Close() error }
Type is an interface for metrics aggregation.
func Combine ¶
Combine returns a Type implementation that feeds metrics into two underlying Type implementations.
func Namespaced ¶
Namespaced embeds an existing metrics aggregator under a new namespace. The prefix of the embedded aggregator is still the ultimate prefix of metrics.
func NewAWSCloudWatch ¶ added in v3.36.0
NewAWSCloudWatch creates and returns a new CloudWatch object.
func NewBlacklist ¶
NewBlacklist creates and returns a new Blacklist object
func NewCloudWatch ¶ added in v3.9.0
NewCloudWatch creates and returns a new CloudWatch object.
func NewInfluxDB ¶ added in v3.36.0
NewInfluxDB creates and returns a new InfluxDB object.
func NewPrometheus ¶
NewPrometheus creates and returns a new Prometheus object.
func NewStatsdLegacy ¶ added in v3.7.0
NewStatsdLegacy creates and returns a new StatsdLegacy object.
func NewWhitelist ¶
NewWhitelist creates and returns a new Whitelist object
type TypeSpec ¶
type TypeSpec struct { Status docs.Status Version string Summary string Description string Footnotes string FieldSpecs docs.FieldSpecs // contains filtered or unexported fields }
TypeSpec is a constructor and a usage description for each metric output type.
type Whitelist ¶
type Whitelist struct {
// contains filtered or unexported fields
}
Whitelist is a statistics object that wraps a separate statistics object and only permits statistics that pass through the whitelist to be recorded.
func (*Whitelist) Close ¶
Close stops the Statsd object from aggregating metrics and cleans up resources.
func (*Whitelist) GetCounter ¶
func (h *Whitelist) GetCounter(path string) StatCounter
GetCounter returns a stat counter object for a path.
func (*Whitelist) GetCounterVec ¶
func (h *Whitelist) GetCounterVec(path string, n []string) StatCounterVec
GetCounterVec returns a stat counter object for a path with the labels discarded.
func (*Whitelist) GetGaugeVec ¶
func (h *Whitelist) GetGaugeVec(path string, n []string) StatGaugeVec
GetGaugeVec returns a stat timer object for a path with the labels discarded.
func (*Whitelist) GetTimerVec ¶
func (h *Whitelist) GetTimerVec(path string, n []string) StatTimerVec
GetTimerVec returns a stat timer object for a path with the labels discarded.
func (*Whitelist) HandlerFunc ¶
func (h *Whitelist) HandlerFunc() http.HandlerFunc
HandlerFunc returns an http.HandlerFunc for accessing metrics for appropriate child types
type WhitelistConfig ¶
type WhitelistConfig struct { Paths []string `json:"paths" yaml:"paths"` Patterns []string `json:"patterns" yaml:"patterns"` Child *Config `json:"child" yaml:"child"` }
WhitelistConfig allows for the placement of filtering rules to only allow select metrics to be displayed or retrieved. It consists of a set of prefixes (direct string comparison) that are checked, and a standard metrics configuration that is wrapped by the whitelist.
func NewWhitelistConfig ¶
func NewWhitelistConfig() WhitelistConfig
NewWhitelistConfig returns the default configuration for a whitelist
func (WhitelistConfig) MarshalJSON ¶
func (w WhitelistConfig) MarshalJSON() ([]byte, error)
MarshalJSON prints an empty object instead of nil.
func (WhitelistConfig) MarshalYAML ¶
func (w WhitelistConfig) MarshalYAML() (interface{}, error)
MarshalYAML prints an empty object instead of nil.
type WithHandlerFunc ¶
type WithHandlerFunc interface {
HandlerFunc() http.HandlerFunc
}
WithHandlerFunc is an interface for metrics types that can expose their metrics through an HTTP HandlerFunc endpoint. If a Type can be cast into WithHandlerFunc then you should register its endpoint to the an HTTP server.