Documentation
¶
Index ¶
- Constants
- Variables
- func DiffMetricFamilies(want []*dto.MetricFamily, got []*dto.MetricFamily, approximate bool, ...) string
- func DiffMetricPoints(want []MetricPoint, got []MetricPoint, approximate bool) string
- func LabelsToText(labels map[string]string) string
- func LabelsToTextNicer(labels map[string]string) string
- func NewHTTPTransport(tlsConfig *tls.Config, options *CustomTransportOptions) http.RoundTripper
- func TextToLabels(text string) map[string]string
- type ArchiveWriter
- type CustomTransportOptions
- type DiagnosticFile
- type LabelsAndAnnotation
- type MQTTReloadState
- type Matcher
- type MatcherRegexp
- type Message
- type Metric
- type MetricAnnotations
- type MetricPoint
- type Monitor
- type MultiErrors
- type Point
- type PointPusher
- type ProcIter
- type ReaderWithLen
- type Registration
- type ScheduleOption
- type SimpleRule
- type Status
- type StatusDescription
Constants ¶
const ( LabelName = "__name__" // ReservedLabelPrefix is a prefix which is not legal in user-supplied label names. ReservedLabelPrefix = "__" //nolint: godoclint // 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" LabelMetaInstanceUseContainerName = "__meta_instance_use_container_name" // Used to indicate that instance label should use the container name LabelMetaContainerID = "__meta_container_id" LabelMetaServiceName = "__meta_service_name" LabelMetaServiceInstance = "__meta_service_instance" LabelMetaServiceUUID = "__meta_service_uuid" LabelMetaGloutonFQDN = "__meta__fqdn" LabelMetaGloutonPort = "__meta_glouton_port" LabelMetaBleemeoRelabelHookOk = "__meta_bleemeo_hook_ok" 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" LabelMetaAgentTypes = "__meta_agent_types" 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" LabelServiceUUID = "service_uuid" LabelDevice = "device" LabelModel = "model" LabelUPSName = "ups_name" //nolint: godoclint // 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.
const MaxMQTTPayloadSize = 1024 * 1024 // 1MiB
const (
MetricServiceStatus = "service_status"
)
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.
const PrometheusValidationScheme = model.LegacyValidation
Variables ¶
var ErrBackPressureSignal = errors.New("back-pressure signal")
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 ¶
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 LabelsToTextNicer ¶
LabelsToTextNicer convert to nicer format. It close to LabelsToText but __name__ is present as classical PromQL selector, e.g.
`node_cpu_seconds_total{cpu="0",model="idle"}`
When only __name__ is present, result don't include braket (e.g. `cpu_used`).
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 ¶
TextToLabels is the reverse of LabelsToText.
Types ¶
type ArchiveWriter ¶
type CustomTransportOptions ¶
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 MatcherRegexp ¶
MatcherRegexp allow to match value and could return a deny regexp.
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 {
ContainerID string
ServiceName string
ServiceInstance string
StatusOf string
SNMPTarget string
// store the agent for which we want to emit the metric, only set when we don't emit for main agent
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 ¶
func (a MetricAnnotations) Merge(other MetricAnnotations) MetricAnnotations
Merge merge two annotations. Annotations from other when set win.
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 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 Registration ¶
type ScheduleOption ¶
type SimpleRule ¶
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).
Possible values for the StatusValue enum.
func FromNagios ¶
FromNagios return a Status from a Nagios status code.
func FromString ¶
func (Status) NagiosCode ¶
NagiosCode return the Nagios value for a Status.
type StatusDescription ¶
StatusDescription store a service/metric status with an optional description.