circonus

package
v0.3.5 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2023 License: BSD-3-Clause Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MetricTypeInt32 reconnoiter.
	MetricTypeInt32 = "i"

	// MetricTypeUint32 reconnoiter.
	MetricTypeUint32 = "I"

	// MetricTypeInt64 reconnoiter.
	MetricTypeInt64 = "l"

	// MetricTypeUint64 reconnoiter.
	MetricTypeUint64 = "L"

	// MetricTypeFloat64 reconnoiter.
	MetricTypeFloat64 = "n"

	// MetricTypeString reconnoiter.
	MetricTypeString = "s"

	// MaxTags reconnoiter will accept in stream tagged metric name.
	MaxTags = 256 // sync w/MAX_TAGS https://github.com/circonus-labs/reconnoiter/blob/master/src/noit_metric.h#L41

	// MaxMetricNameLen reconnoiter will accept (name+stream tags).
	MaxMetricNameLen = 4096 // sync w/MAX_METRIC_TAGGED_NAME https://github.com/circonus-labs/reconnoiter/blob/master/src/noit_metric.h#L40
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Check

type Check struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Check defines a Circonus check for a circonus-cloud-agent service.

func NewCheck

func NewCheck(svcID string, cfg *Config) (*Check, error)

NewCheck creates a new Circonus check instance based on the Config options passed to initialize the Circonus API, check and broker.

func (*Check) BrokerTLSConfig

func (c *Check) BrokerTLSConfig() (*tls.Config, error)

BrokerTLSConfig returns the broker tls configuration for metric submissions or nil if tls config not needed (e.g. public trap broker).

func (*Check) EncodeMetricStreamTags

func (c *Check) EncodeMetricStreamTags(tags Tags) string

EncodeMetricStreamTags encodes Tags into a string suitable for use with stream tags. Tags directly embedded into metric names using the `metric_name|ST[<tags>]` syntax. Note: legacy tags support bare values, stream tags require a cateogry and a value. Additionally, all spaces are removed from stream tag categories and values.

func (*Check) EncodeMetricTags

func (c *Check) EncodeMetricTags(tags Tags) []string

EncodeMetricTags encodes Tags into an array of strings. The format check_bundle.metircs.metric.tags needs. This helper is intended to work with legacy check bundle metrics.

func (*Check) MetricNameWithStreamTags

func (c *Check) MetricNameWithStreamTags(metric string, tags Tags) string

MetricNameWithStreamTags will encode tags as stream tags into supplied metric name. Note: if metric name already has stream tags it is assumed the metric name and embedded stream tags are being managed manually and calling this method will nave no effect.

func (*Check) RefreshCheck

func (c *Check) RefreshCheck() error

RefreshCheck fetches a new copy of the check bundle and broker from Circonus API. Primary use-case is when a check is moved from one broker to another, metric submits will fail. Refreshing the check bundle will obtain the new submission url, and reconfigure the broker tls config (if needed).

func (*Check) ReportError

func (c *Check) ReportError(err error)

ReportError to Circonus check.

func (*Check) SubmitMetrics

func (c *Check) SubmitMetrics(metricSrc io.Reader) error

SubmitMetrics to Circonus check.

func (*Check) WriteMetricSample

func (c *Check) WriteMetricSample(metricDest io.Writer, metricName, metricType string, value interface{}, timestamp *time.Time) error

WriteMetricSample to queue for submission.

type Config

type Config struct {
	ID            string         // a unique identifier, used to search for a check bundle
	CheckBundleID string         // a specific check bundle cid to use
	BrokerCID     string         // broker cid to use (default circonus public broker)
	BrokerCAFile  string         // broker ca file
	DisplayName   string         // display name to use for check bundle (when searching or creating)
	Tags          string         // tags to add to a check when creating
	APIKey        string         // Circonus API Token key
	APIApp        string         // Circonus API Token app
	APIURL        string         // Circonus API URL
	APICAFile     string         // api ca file
	Logger        zerolog.Logger // logging instance to use
	Debug         bool           // turn on debugging messages
	TraceMetrics  bool           // output each metric as it is sent
}

Config options for a Circonus Check passed to New method.

type ServiceConfig

type ServiceConfig struct {
	CID          string `json:"cid" toml:"cid" yaml:"cid"`                               // OPTIONAL, cid of specific check bundle to use
	BrokerCID    string `json:"broker_cid" toml:"broker_cid" yaml:"broker_cid"`          // OPTIONAL, default public trap broker
	App          string `json:"app" toml:"app" yaml:"app"`                               // REQUIRED
	Key          string `json:"key" toml:"key" yaml:"key"`                               // REQUIRED
	URL          string `json:"url" toml:"url" yaml:"url"`                               // DEFAULT 'https://api.circonus.com/v2/'
	CAFile       string `json:"ca_file" toml:"ca_file" yaml:"ca_file"`                   // DEFAULT api.circonus.com uses a public certificate
	Debug        bool   `json:"debug" toml:"debug" yaml:"debug"`                         // DEFAULT false - this is separate so that the global debug does not inundate logs with cgm debug messages from each cloud service metric collection client
	TraceMetrics bool   `json:"trace_metrics" toml:"trace_metrics" yaml:"trace_metrics"` // DEFAULT false - output each metric as it is sent
}

ServiceConfig defines the Circonus configuration for a cloud service to include.

type Tag

type Tag struct {
	Category string
	Value    string
}

Tag defines an individual tag.

type Tags

type Tags []Tag

Tags defines a list of tags.

Jump to

Keyboard shortcuts

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