prometheus_client

package
v0.0.0-...-5864974 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2019 License: MIT Imports: 18 Imported by: 0

README

Prometheus Client Service Output Plugin

This plugin starts a Prometheus Client, it exposes all metrics on /metrics (default) to be polled by a Prometheus server.

Configuration

# Publish all metrics to /metrics for Prometheus to scrape
[[outputs.prometheus_client]]
  ## Address to listen on.
  listen = ":9273"

  ## Use HTTP Basic Authentication.
  # basic_username = "Foo"
  # basic_password = "Bar"

  ## If set, the IP Ranges which are allowed to access metrics.
  ##   ex: ip_range = ["192.168.0.0/24", "192.168.1.0/30"]
  # ip_range = []

  ## Path to publish the metrics on.
  # path = "/metrics"

  ## Expiration interval for each metric. 0 == no expiration
  # expiration_interval = "60s"

  ## Collectors to enable, valid entries are "gocollector" and "process".
  ## If unset, both are enabled.
  # collectors_exclude = ["gocollector", "process"]

  ## Send string metrics as Prometheus labels.
  ## Unless set to false all string metrics will be sent as labels.
  # string_as_label = true

  ## If set, enable TLS with the given certificate.
  # tls_cert = "/etc/ssl/telegraf.crt"
  # tls_key = "/etc/ssl/telegraf.key"

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MetricFamily

type MetricFamily struct {
	// Samples are the Sample belonging to this MetricFamily.
	Samples map[SampleID]*Sample
	// Need the telegraf ValueType because there isn't a Prometheus ValueType
	// representing Histogram or Summary
	TelegrafValueType telegraf.ValueType
	// LabelSet is the label counts for all Samples.
	LabelSet map[string]int
}

MetricFamily contains the data required to build valid prometheus Metrics.

type PrometheusClient

type PrometheusClient struct {
	Listen             string
	TLSCert            string            `toml:"tls_cert"`
	TLSKey             string            `toml:"tls_key"`
	BasicUsername      string            `toml:"basic_username"`
	BasicPassword      string            `toml:"basic_password"`
	IPRange            []string          `toml:"ip_range"`
	ExpirationInterval internal.Duration `toml:"expiration_interval"`
	Path               string            `toml:"path"`
	CollectorsExclude  []string          `toml:"collectors_exclude"`
	StringAsLabel      bool              `toml:"string_as_label"`

	sync.Mutex
	// contains filtered or unexported fields
}

func (*PrometheusClient) Close

func (p *PrometheusClient) Close() error

func (*PrometheusClient) Collect

func (p *PrometheusClient) Collect(ch chan<- prometheus.Metric)

Collect implements prometheus.Collector

func (*PrometheusClient) Connect

func (p *PrometheusClient) Connect() error

func (*PrometheusClient) Describe

func (p *PrometheusClient) Describe(ch chan<- *prometheus.Desc)

Implements prometheus.Collector

func (*PrometheusClient) Description

func (p *PrometheusClient) Description() string

func (*PrometheusClient) Expire

func (p *PrometheusClient) Expire()

Expire removes Samples that have expired.

func (*PrometheusClient) SampleConfig

func (p *PrometheusClient) SampleConfig() string

func (*PrometheusClient) Start

func (p *PrometheusClient) Start() error

func (*PrometheusClient) Stop

func (p *PrometheusClient) Stop()

func (*PrometheusClient) Write

func (p *PrometheusClient) Write(metrics []telegraf.Metric) error

type Sample

type Sample struct {
	// Labels are the Prometheus labels.
	Labels map[string]string
	// Value is the value in the Prometheus output. Only one of these will populated.
	Value          float64
	HistogramValue map[float64]uint64
	SummaryValue   map[float64]float64
	// Histograms and Summaries need a count and a sum
	Count uint64
	Sum   float64
	// Expiration is the deadline that this Sample is valid until.
	Expiration time.Time
}

Sample represents the current value of a series.

type SampleID

type SampleID string

SampleID uniquely identifies a Sample

func CreateSampleID

func CreateSampleID(tags map[string]string) SampleID

CreateSampleID creates a SampleID based on the tags of a telegraf.Metric.

Jump to

Keyboard shortcuts

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