metrics

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2020 License: Apache-2.0 Imports: 9 Imported by: 1

Documentation

Overview

Package metrics provides methods tracking metrics in Prometheus

Index

Constants

View Source
const (

	// PrometheusEnv is a boolean env var to
	// enable/disable Prometheus. Values true or false
	PrometheusEnv = "PROMETHEUS"
	// PrometheusDefault is the default value for PrometheusEnv
	PrometheusDefault = false
)
View Source
const (
	// RxBytes is vector name for "rx_bytes"
	RxBytes = "rx_bytes"
	// TxBytes is vector name for "tx_bytes"
	TxBytes = "tx_bytes"
	// RxPackets is vector name for "rx_packets"
	RxPackets = "rx_packets"
	// TxPackets is vector name for "tx_packets"
	TxPackets = "tx_packets"
	// RxErrorPackets is vector name for "rx_error_packets"
	RxErrorPackets = "rx_error_packets"
	// TxErrorPackets is vector name for "tx_error_packets"
	TxErrorPackets = "tx_error_packets"

	// SrcPodKey is vector label for source pod
	SrcPodKey = "src_pod"
	// SrcNamespaceKey is vector label for source pod namespace
	SrcNamespaceKey = "src_namespace"
	// DstPodKey is vector label for dest pod
	DstPodKey = "dst_pod"
	// DstNamespaceKey is vector label for dest pod namespace
	DstNamespaceKey = "dst_namespace"
)

Variables

This section is empty.

Functions

func CollectAllMetrics

func CollectAllMetrics(ctx PrometheusMetricsContext, prometheusMetrics []PrometheusMetric, metrics *crossconnect.Metrics)

CollectAllMetrics collects metrcis from the crossconnect.Metrics data, and based on the given context (i.e. src and destination connection the metrics are for) tracks that data in the corresponding vectors

func GetMetricsIdentifiers

func GetMetricsIdentifiers(crossConnect *crossconnect.CrossConnect) (map[string]string, error)

GetMetricsIdentifiers returns source and destination of the metrics specified with `pod` name and `namespace`

func GetPrometheusMetricsServer

func GetPrometheusMetricsServer(prometheusAddress ...string) *http.Server

GetPrometheusMetricsServer creates a http server to expose the metrics to. Prometheus is going to collect the data from that server

func RunPrometheusMetricsServer

func RunPrometheusMetricsServer()

RunPrometheusMetricsServer is running Prometheus to handle traffic metrics Stop is deferred in the client implementation

Types

type PrometheusMetric

type PrometheusMetric struct {
	Name  string
	Vec   *prometheus.GaugeVec
	Value string
}

PrometheusMetric contains vector name and prometheus.GaugeVec reference

func BuildPrometheusMetrics

func BuildPrometheusMetrics() []PrometheusMetric

BuildPrometheusMetrics builds prometheus Gauge vectiors for rx_bytes, tx_bytes, rx_packets, tx_packets, rx_error_packets and tx_error_packets

type PrometheusMetricsContext

type PrometheusMetricsContext struct {
	// SrcPodName is the name of the source pod in a connection
	SrcPodName string
	// DstPodName is the name of the dest pod in a connection
	DstPodName string
	// SrcNamespace is the namespace of the source pod in a connection
	SrcNamespace string
	// DstNamespace is the namespace of the dest pod in a connection
	DstNamespace string
	// Metrics is the metrics data for the connection
	Metrics map[string]string
}

PrometheusMetricsContext is metrics context, containing source and destination pods (and their namespaces)

func BuildPrometheusMetricsContext

func BuildPrometheusMetricsContext(srcPodName, srcNamespace, dstPodName, dstNamespace string) PrometheusMetricsContext

BuildPrometheusMetricsContext builds single metrics context, i.e. source and destination pods (and their namespaces) whose connection the metrics are going to describe

Jump to

Keyboard shortcuts

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