types

package
v0.0.0-...-7ded55f Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LabelName = "__name__"

	// ReservedLabelPrefix is a prefix which is not legal in user-supplied label names.
	ReservedLabelPrefix = "__"
	// Label starting with "__" are dropped after collections and are only accessible
	// internally (e.g. not present on /metrics, on Bleemeo Cloud or in the local store),
	// they are dropped by the metric registry.
	// They can be used to know the origin of a metric. Unlike label which don't start by "__",
	// they can only be set by Glouton itself because it's not a valid user defined label.
	LabelMetaContainerName          = "__meta_container_name"
	LabelMetaContainerID            = "__meta_container_id"
	LabelMetaServiceName            = "__meta_service_name"
	LabelMetaServiceInstance        = "__meta_service_instance"
	LabelMetaGloutonFQDN            = "__meta__fqdn"
	LabelMetaGloutonPort            = "__meta_glouton_port"
	LabelMetaBleemeoItem            = "__meta_bleemeo_item"
	LabelMetaServicePort            = "__meta_service_port"
	LabelMetaStatusOf               = "__meta_status_of"
	LabelMetaPort                   = "__meta_port"
	LabelMetaScrapeInstance         = "__meta_scrape_instance"
	LabelMetaScrapeJob              = "__meta_scrape_job"
	LabelMetaSNMPTarget             = "__meta_snmp_target"
	LabelMetaKubernetesCluster      = "__meta_kubernetes_cluster"
	LabelMetaVSphere                = "__meta_vsphere"
	LabelMetaVSphereMOID            = "__meta_vsphere_moid"
	LabelMetaBleemeoTargetAgent     = "__meta_bleemeo_target_agent"
	LabelMetaBleemeoTargetAgentUUID = "__meta_bleemeo_target_agent_uuid"
	LabelMetaBleemeoUUID            = "__meta_bleemeo_uuid"
	LabelMetaProbeServiceUUID       = "__meta_probe_service_uuid"
	LabelMetaProbeScraperName       = "__meta_probe_scraper_name"
	LabelMetaSendScraperUUID        = "__meta_probe_send_agent_uuid"
	LabelMetaCurrentStatus          = "__meta_current_status"
	LabelMetaCurrentDescription     = "__meta_current_description"
	LabelK8SPODName                 = "kubernetes_pod_name"
	LabelK8SNamespace               = "kubernetes_namespace"
	LabelInstanceUUID               = "instance_uuid"
	LabelItem                       = "item"
	LabelScraperUUID                = "scraper_uuid"
	LabelScraper                    = "scraper"
	LabelSNMPTarget                 = "snmp_target"
	LabelInstance                   = "instance"
	LabelContainerName              = "container_name"
	LabelScrapeJob                  = "scrape_job"
	LabelScrapeInstance             = "scrape_instance"
	LabelService                    = "service"
	LabelServiceInstance            = "service_instance"
	LabelDevice                     = "device"
	LabelModel                      = "model"
	LabelUPSName                    = "ups_name"
	// Kubernetes pods labels.
	LabelState     = "state"
	LabelOwnerKind = "owner_kind"
	LabelOwnerName = "owner_name"
	LabelPodName   = "pod_name"
	LabelNamespace = "namespace"
)

List of label names that some part of Glouton will assume to be named as such. Using constant here allow to change their name only here. LabelName constants is duplicated in JavaScript file.

View Source
const (
	MetricServiceStatus = "service_status"
)
View Source
const MissingContainerID = "missing-container-id"

MissingContainerID is the container ID annotation set on metrics that belong to a container when the container is not known yet.

Variables

This section is empty.

Functions

func DiffMetricFamilies

func DiffMetricFamilies(want []*dto.MetricFamily, got []*dto.MetricFamily, approximate bool, ignoreFamilyOrder bool) string

DiffMetricFamilies return a diff between want and got. Mostly useful in tests.

func DiffMetricPoints

func DiffMetricPoints(want []MetricPoint, got []MetricPoint, approximate bool) string

DiffMetricPoints return a diff between want and got. Mostly useful in tests. Points are sorted before being compared. If approximate is true, float are compared with a approximation (compare only 3 first digits).

func LabelsToText

func LabelsToText(labels map[string]string) string

LabelsToText return a text version of a labels set The text representation has a one-to-one relation with labels set. It does because: * labels are sorted by label name * labels values are quoted

Result looks like __name__="node_cpu_seconds_total",cpu="0",mode="idle".

func NewHTTPTransport

func NewHTTPTransport(tlsConfig *tls.Config, options *CustomTransportOptions) http.RoundTripper

NewHTTPTransport returns a default Transport with a modified TLSClientConfig. If options are provided, both UserAgentHeader and RequestCounter must be defined.

func TextToLabels

func TextToLabels(text string) map[string]string

TextToLabels is the reverse of LabelsToText.

Types

type ArchiveWriter

type ArchiveWriter interface {
	Create(filename string) (io.Writer, error)
	CurrentFileName() string
}

type CustomTransportOptions

type CustomTransportOptions struct {
	// UserAgentHeader will be used as the User-Agent for each HTTP request.
	UserAgentHeader string
	// RequestCounter will be incremented for each HTTP transaction.
	RequestCounter *atomic.Uint32
	EnableLogger   bool
}

type DiagnosticFile

type DiagnosticFile interface {
	Filename() string
	Reader() (ReaderWithLen, error)
	MarkUploaded() error
}

type LabelsAndAnnotation

type LabelsAndAnnotation struct {
	Labels      map[string]string
	Annotations MetricAnnotations
}

type MQTTReloadState

type MQTTReloadState interface {
	Client() paho.Client
	SetClient(cli paho.Client)
	OnConnectionLost(cli paho.Client, err error)
	ConnectionLostChannel() <-chan error
	Close()
	AddPendingMessage(ctx context.Context, m Message, shouldWait bool) bool
	PendingMessage(ctx context.Context) (Message, bool)
	PendingMessagesCount() int
}

MQTTReloadState is the state kept between reloads for MQTT.

type Matcher

type Matcher interface {
	Match(item string) bool
}

Matcher allow to match value.

type MatcherRegexp

type MatcherRegexp interface {
	Matcher
	AsDenyRegexp() string
}

MatcherRegexp allow to match value and could return a deny regexp.

type Message

type Message struct {
	Token   paho.Token
	Retry   bool
	Topic   string
	Payload []byte
}

Message contains all information to send a message to MQTT.

type Metric

type Metric interface {
	// Labels returns labels of the metric. A metric is identified by its labels.
	// The returned map must not be modified, copy it if you need mutation.
	Labels() map[string]string

	// Annotations of this metric. A annotation is similar to a label but do not participate
	// in the metric identification and may change.
	Annotations() MetricAnnotations

	// Points returns points between the two given time range (boundary are included).
	Points(start, end time.Time) ([]Point, error)

	// LastPointReceivedAt return the last time a point was received
	LastPointReceivedAt() time.Time
}

Metric represent a metric object.

type MetricAnnotations

type MetricAnnotations struct {
	BleemeoItem     string
	ContainerID     string
	ServiceName     string
	ServiceInstance string
	StatusOf        string
	SNMPTarget      string
	// store the agent for which we want to emit the metric
	BleemeoAgentID string
	Status         StatusDescription
}

MetricAnnotations contains additional information about a metrics.

func (MetricAnnotations) Changed

func (a MetricAnnotations) Changed(other MetricAnnotations) bool

Changed tells whether two annotation are different or not. Status isn't considered when comparing the annotations.

func (MetricAnnotations) Merge

Merge merge two annotations. Annotations from other when set win.

type MetricFormat

type MetricFormat int

MetricFormat specify the metric format used.

const (
	MetricFormatUnknown MetricFormat = iota
	MetricFormatBleemeo
	MetricFormatPrometheus
)

List of known metrics format. Currently only Bleemeo and Prometheus are supported. The Bleemeo format is the initial format supported. It provide fewer metrics which are usually directly queryable (e.g. disk_used_perc instead of a free bytes and total bytes) The Prometheus format use same format as node_exporter and try to be as close as Prometheus way.

func StringToMetricFormat

func StringToMetricFormat(input string) MetricFormat

StringToMetricFormat convert a string to a MetricFormat. Return MetricFormatUnknown if input is invalid.

func (MetricFormat) String

func (f MetricFormat) String() string

type MetricPoint

type MetricPoint struct {
	Point
	Labels      map[string]string
	Annotations MetricAnnotations
}

MetricPoint is one point for one metrics (identified by labels) with its annotation at the time of emission.

type Monitor

type Monitor struct {
	ID                      string
	MetricMonitorResolution time.Duration
	CreationDate            time.Time
	URL                     string
	BleemeoAgentID          string
	ExpectedContent         string
	ExpectedResponseCode    int
	ForbiddenContent        string
	CAFile                  string
	Headers                 map[string]string
}

Monitor represents a monitor instance.

type MultiErrors

type MultiErrors []error

MultiErrors is a type containing multiple errors. It implements the error interface.

func (MultiErrors) Error

func (errs MultiErrors) Error() string

func (MultiErrors) Is

func (errs MultiErrors) Is(target error) bool

type Point

type Point struct {
	Time  time.Time
	Value float64
}

Point is the value of one metric at a given time.

type PointPusher

type PointPusher interface {
	PushPoints(ctx context.Context, points []MetricPoint)
}

PointPusher push new points. Points must not be mutated after call.

type ReaderWithLen

type ReaderWithLen interface {
	io.ReadCloser
	Len() int
}

type SimpleRule

type SimpleRule struct {
	TargetName  string
	PromQLQuery string
}

SimpleRule is a PromQL run on output from the Gatherer. It's similar to a recording rule, but it's not able to use historical data and can only works on latest point (so no rate, avg_over_time, ...).

type Status

type Status uint8

Status is an enumeration of status (ok, warning, critical, unknown).

const (
	StatusUnset Status = iota
	StatusOk
	StatusWarning
	StatusCritical
	StatusUnknown
)

Possible values for the StatusValue enum.

func FromNagios

func FromNagios(value int) Status

FromNagios return a Status from a Nagios status code.

func FromString

func FromString(s string) Status

func (Status) IsSet

func (s Status) IsSet() bool

IsSet return true if the status is set.

func (Status) NagiosCode

func (s Status) NagiosCode() int

NagiosCode return the Nagios value for a Status.

func (Status) String

func (s Status) String() string

type StatusDescription

type StatusDescription struct {
	CurrentStatus     Status
	StatusDescription string
}

StatusDescription store a service/metric status with an optional description.

Jump to

Keyboard shortcuts

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