metrics

package
v0.2012.6 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2021 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Overview

Package metrics implements a prometheus metrics service.

Index

Constants

View Source
const (
	MetricCPUUTimeSeconds = "oasis_node_cpu_utime_seconds"
	MetricCPUSTimeSeconds = "oasis_node_cpu_stime_seconds"

	// getconf CLK_TCK
	ClockTicks = 100
)
View Source
const (
	MetricDiskUsageBytes   = "oasis_node_disk_usage_bytes"
	MetricDiskReadBytes    = "oasis_node_disk_read_bytes"
	MetricDiskWrittenBytes = "oasis_node_disk_written_bytes"
)
View Source
const (
	MetricMemVmSizeBytes   = "oasis_node_mem_vm_size_bytes" // nolint: golint
	MetricMemRssAnonBytes  = "oasis_node_mem_rss_anon_bytes"
	MetricMemRssFileBytes  = "oasis_node_mem_rss_file_bytes"
	MetricMemRssShmemBytes = "oasis_node_mem_rss_shmem_bytes"
)
View Source
const (
	CfgMetricsMode     = "metrics.mode"
	CfgMetricsAddr     = "metrics.address"
	CfgMetricsLabels   = "metrics.labels"
	CfgMetricsJobName  = "metrics.job_name"
	CfgMetricsInterval = "metrics.interval"

	MetricUp = "oasis_up"

	MetricsJobTestRunner = "oasis-test-runner"

	MetricsLabelGitBranch       = "git_branch"
	MetricsLabelInstance        = "instance"
	MetricsLabelRun             = "run"
	MetricsLabelSoftwareVersion = "software_version"
	MetricsLabelScenario        = "scenario"

	MetricsModeNone = "none"
	MetricsModePull = "pull"
	MetricsModePush = "push"
)
View Source
const (
	MetricNetReceiveBytesTotal    = "oasis_node_net_receive_bytes_total"
	MetricNetReceivePacketsTotal  = "oasis_node_net_receive_packets_total"
	MetricNetTransmitBytesTotal   = "oasis_node_net_transmit_bytes_total"
	MetricNetTransmitPacketsTotal = "oasis_node_net_transmit_packets_total"
)

Variables

View Source
var (
	Flags = flag.NewFlagSet("", flag.ContinueOnError)

	UpGauge = prometheus.NewGauge(
		prometheus.GaugeOpts{
			Name: MetricUp,
			Help: "Is oasis-test-runner active for specific scenario.",
		},
	)
)

Flags has the flags used by the metrics service.

Functions

func Enabled

func Enabled() bool

Enabled returns if metrics are enabled.

func EscapeLabelCharacters

func EscapeLabelCharacters(l string) string

EscapeLabelCharacters replaces invalid prometheus label name characters with "_".

func GetDefaultPushLabels

func GetDefaultPushLabels(ti *env.ScenarioInstanceInfo) map[string]string

GetDefaultPushLabels generates standard Prometheus push labels based on test current test instance info.

func New

New constructs a new metrics service.

Types

type ResourceCollector

type ResourceCollector interface {
	// Name returns the resource collector name.
	Name() string

	// Update updates corresponding resource metrics.
	Update() error
}

ResourceCollector is interface for monitoring resources (cpu, mem, disk, net).

func NewCPUCollector

func NewCPUCollector() ResourceCollector

NewCPUCollector constructs a new CPU usage collector.

This service will regularly read CPU spent time info from process Stat file.

func NewDiskService

func NewDiskService() ResourceCollector

NewDiskService constructs a new disk usage and I/O service.

This service will regularly compute the size of datadir folder and read I/O info of the process.

func NewMemService

func NewMemService() ResourceCollector

NewMemService constructs a new memory usage service.

This service will regularly read memory info from process Status file.

func NewNetService

func NewNetService() ResourceCollector

NewNetService constructs a new network statistics service.

This service will regularly read info from /proc/net/dev file.

Jump to

Keyboard shortcuts

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