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 ¶
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.
const Default_SurfacerConf_MetricsBufferSize int64 = 10000
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:
- Metric name -> PromMetric data structure dict.
- 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"` // 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) 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