monitoring

package
v0.5.0-alpha Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2023 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Label     Usage = "label"
	Gauge           = "gauge"
	Counter         = "counter"
	Histogram       = "histogram"
)
View Source
const WORKER_COUNT = 3

Variables

This section is empty.

Functions

func GetDefaultDSN

func GetDefaultDSN(log logr.Logger) *url.URL

Return the DSN as specified by the DATA_SOURCE* env vars, reading the appropriate configmap files for username and password

func StartExporting

func StartExporting(log logr.Logger, reg *prometheus.Registry, db DBFactory, configFiles []string, extraLabels map[string]string)

func StartExportingContainerMetrics

func StartExportingContainerMetrics(log logr.Logger, reg *prometheus.Registry, volumes []VolumeInfo, extraLabels map[string]string) error

StartExportingContainerMetrics starts an metric exporter for cgroup and disk stats. If you want to export these metrics on an existing '/metrics' endpoint instead register the NewDBContainerMonitor directly to your prometheus registry.

Types

type DBContainerMonitor

type DBContainerMonitor struct {
	// usage of memory in bytes
	MemoryUsage prometheus.Gauge
	// memory used for cache
	MemoryCacheUsage prometheus.Gauge
	// contains filtered or unexported fields
}

DBContainerMonitor metrics followed http://google3/configs/monitoring/cloud_pulse_monarch/kubernetes/metrics_def_core this is a workaround if a platform does not provide system metrics(container CPU/memory, volumes) to DB users.

func NewDBContainerMonitor

func NewDBContainerMonitor(log logr.Logger, volumes []VolumeInfo) *DBContainerMonitor

NewDBContainerMonitor prepares a monitor that can be passed to prometheus as a Collector to collect container system(memory/CPU) metrics

func (*DBContainerMonitor) Collect

func (m *DBContainerMonitor) Collect(ch chan<- prometheus.Metric)

func (*DBContainerMonitor) Describe

func (m *DBContainerMonitor) Describe(ch chan<- *prometheus.Desc)

Describe intentionally left blank as we will dynamically be generating metrics.

type DBFactory

type DBFactory interface {
	Open() (*sql.DB, error)
}

Allow users to pass in the driver specific db connector without this code needing a direct dependency to potential C code.

type Metric

type Metric struct {
	Name  string `yaml:"name"`
	Desc  string `yaml:"desc"`
	Usage Usage  `yaml:"usage"`

	// Only for Histograms, defines buckets of the histogram
	Buckets map[string]float64 `yaml:"buckets,omitempty"`
	// contains filtered or unexported fields
}

Specifies a metric within the MetricSet, its Name (which is also the column name that will provide its value), the Usage determines what kind of Metric this portion of the query represents

When specifying a histogram metric the defined column name will be used as the base name of buckets+2 columns that must be in the MetricSet's query. `Column_key` for each bucket key and `Column_count`,`Column_sum` for the total event count and total sum of events.

type MetricSet

type MetricSet struct {
	Name      string   `yaml:"name"`
	Namespace string   `yaml:"namespace"`
	Query     string   `yaml:"query"`
	Metrics   []Metric `yaml:"metrics"`
}

A set of metrics that will be reported to prometheus Metrics/labels are derived from the columns of the query. The set of metrics reported will be Namespace_Name_Metric.Name for every non-label Metric in the MetricSet.

You must use ReadConfig or StartMonitoring to fill out this struct correctly.

func ReadConfig

func ReadConfig(config []byte) ([]MetricSet, error)

ReadConfig all agents should use ReadConfig or StartExporting which uses this function to ensure their MetricSet is parsed correctly and validated.

type Monitor

type Monitor struct {
	DBFactory  DBFactory
	MetricSets []MetricSet
	// contains filtered or unexported fields
}

func NewMonitor

func NewMonitor(log logr.Logger, db DBFactory, ms []MetricSet) *Monitor

NewMonitor prepares a monitor that can be passed to prometheus as a Collector. Alternately you can use StartExporting to handle creation of the monitor and setting up promtheus.

func (*Monitor) Collect

func (m *Monitor) Collect(ch chan<- prometheus.Metric)

Collect for prometheus.Collector interface, called when we should report metrics. TODO thread contexts.

func (*Monitor) Describe

func (m *Monitor) Describe(ch chan<- *prometheus.Desc)

Describe intentionally left blank as we will dynamically be generating metrics.

type Usage

type Usage string

How a column value should be used. It will either be a label value applied to the entire MetricSet or a metric value.

type VolumeInfo

type VolumeInfo struct {
	Mount string
	Name  string
}

VolumeInfo provides required information to expose pod volume metrics

type VolumeMetrics

type VolumeMetrics struct {
	// usage of volume in bytes
	Usage prometheus.Gauge
	// total available space of volume in bytes
	Total prometheus.Gauge
}

VolumeMetrics specifies a pod volume metrics

Jump to

Keyboard shortcuts

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