Documentation ¶
Overview ¶
Package metrics implements a prometheus metrics service.
Index ¶
Constants ¶
const ( MetricCPUUTimeSeconds = "oasis_node_cpu_utime_seconds" MetricCPUSTimeSeconds = "oasis_node_cpu_stime_seconds" // getconf CLK_TCK ClockTicks = 100 )
const ( MetricDiskUsageBytes = "oasis_node_disk_usage_bytes" MetricDiskReadBytes = "oasis_node_disk_read_bytes" MetricDiskWrittenBytes = "oasis_node_disk_written_bytes" )
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" )
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" )
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 ¶
var ( // Flags has the flags used by the metrics service. Flags = flag.NewFlagSet("", flag.ContinueOnError) UpGauge = prometheus.NewGauge( prometheus.GaugeOpts{ Name: MetricUp, Help: "Is oasis-test-runner active for specific scenario.", }, ) )
Functions ¶
func EscapeLabelCharacters ¶
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.
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.