prometheus

package
v0.0.0-...-eff70b3 Latest Latest
Warning

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

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

Documentation

Overview

Package prometheus is a generated protocol buffer package.

It is generated from these files:

github.com/google/cloudprober/surfacers/prometheus/config.proto

It has these top-level messages:

SurfacerConf

Package prometheus provides a prometheus surfacer for Cloudprober. Prometheus surfacer exports incoming metrics over a web interface in a format that prometheus understands (http://prometheus.io).

This surfacer processes each incoming EventMetrics and holds the latest value and timestamp for each metric in memory. These metrics are made available through a web URL (default: /metrics), which Prometheus scrapes at a regular interval.

Example /metrics page: #TYPE sent counter sent{ptype="dns",probe="vm-to-public-dns",dst="8.8.8.8"} 181299 1497330037000 sent{ptype="ping",probe="vm-to-public-dns",dst="8.8.4.4"} 362600 1497330037000 #TYPE rcvd counter rcvd{ptype="dns",probe="vm-to-public-dns",dst="8.8.8.8"} 181234 1497330037000 rcvd{ptype="ping",probe="vm-to-public-dns",dst="8.8.4.4"} 362600 1497330037000

Index

Constants

View Source
const (
	ValidMetricNameRegex = "^[a-zA-Z_:]([a-zA-Z0-9_:])*$"
	ValidLabelNameRegex  = "^[a-zA-Z_]([a-zA-Z0-9_])*$"
)

Prometheus metric and label names should match the following regular expressions. Since, "-" is commonly used in metric and label names, we replace it by "_". If a name still doesn't match the regular expression, we ignore it with a warning log message.

View Source
const Default_SurfacerConf_IncludeTimestamp bool = true
View Source
const Default_SurfacerConf_MetricsBufferSize int64 = 10000
View Source
const Default_SurfacerConf_MetricsUrl string = "/metrics"

Variables

This section is empty.

Functions

This section is empty.

Types

type PromSurfacer

type PromSurfacer struct {
	// contains filtered or unexported fields
}

PromSurfacer implements a prometheus surfacer for Cloudprober. PromSurfacer organizes metrics into a two-level data structure:

  1. Metric name -> PromMetric data structure dict.
  2. A PromMetric organizes data associated with a metric in a Data key -> Data point map, where data point consists of a value and timestamp.

Data key represents a unique combination of metric name and labels.

func New

func New(config *SurfacerConf, l *logger.Logger) (*PromSurfacer, error)

New returns a prometheus surfacer based on the config provided. It sets up a goroutine to process both the incoming EventMetrics and the web requests for the URL handler /metrics.

func (*PromSurfacer) Write

func (ps *PromSurfacer) Write(ctxIn context.Context, em *metrics.EventMetrics)

Write simply queues the EventMetrics for later processing.

type SurfacerConf

type SurfacerConf struct {
	// How many metrics entries (EventMetrics) to buffer. Incoming metrics
	// processing is paused while serving data to prometheus. This buffer is to
	// make writes to prometheus surfacer non-blocking.
	MetricsBufferSize *int64 `protobuf:"varint,1,opt,name=metrics_buffer_size,json=metricsBufferSize,def=10000" json:"metrics_buffer_size,omitempty"`
	// Whether to include timestamps in metrics. If enabled (default) each metric
	// string includes the metric timestamp as recorded in the EventMetric.
	// Prometheus associates the scraped values with this timestamp. If disabled,
	// i.e. timestamps are not exported, prometheus associates scraped values with
	// scrape timestamp.
	IncludeTimestamp *bool `protobuf:"varint,2,opt,name=include_timestamp,json=includeTimestamp,def=1" json:"include_timestamp,omitempty"`
	// URL that prometheus scrapes metrics from.
	MetricsUrl       *string `protobuf:"bytes,3,opt,name=metrics_url,json=metricsUrl,def=/metrics" json:"metrics_url,omitempty"`
	XXX_unrecognized []byte  `json:"-"`
}

func (*SurfacerConf) Descriptor

func (*SurfacerConf) Descriptor() ([]byte, []int)

func (*SurfacerConf) GetIncludeTimestamp

func (m *SurfacerConf) GetIncludeTimestamp() bool

func (*SurfacerConf) GetMetricsBufferSize

func (m *SurfacerConf) GetMetricsBufferSize() int64

func (*SurfacerConf) GetMetricsUrl

func (m *SurfacerConf) GetMetricsUrl() string

func (*SurfacerConf) ProtoMessage

func (*SurfacerConf) ProtoMessage()

func (*SurfacerConf) Reset

func (m *SurfacerConf) Reset()

func (*SurfacerConf) String

func (m *SurfacerConf) String() string

Jump to

Keyboard shortcuts

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