promaggr

package module
v0.0.0-...-0a2e708 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2021 License: Apache-2.0 Imports: 10 Imported by: 0

README

promaggr

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddLabels

func AddLabels(mfs []*dto.MetricFamily, labels model.LabelSet)

AddLabels adds the given label set to all metrics in the given MetricFamily's.

func MergeMetricFamily

func MergeMetricFamily(mfs1, mfs2 []*dto.MetricFamily, opts ...MergeOption) []*dto.MetricFamily

MergeMetricFamily returns the result of merging the slices of two MetricFamily's. Be careful not to have metric with the same name and the same label when merging. To avoid metric conflicts, you can use the built-in AddIdentifierLabel option.

func MetricFamilyToDesc

func MetricFamilyToDesc(f *dto.MetricFamily) *prometheus.Desc

MetricFamilyToDesc generates prometheus.Desc from MetricFamily.

func MetricFamilyToMetrics

func MetricFamilyToMetrics(f *dto.MetricFamily) []prometheus.Metric

MetricFamilyToMetrics generates slice of prometheus.Metric slice from MetricFamily.

Types

type Collector

type Collector struct {
	//
	Scrapers []*Scraper

	// Logger is a logger that implements the logr.Logger interface.
	// If it is not specified, nothing will be logged.
	Logger logr.Logger
	// contains filtered or unexported fields
}

Collector implements the prometheus.Collector interface.

func NewCollector

func NewCollector(scrapers []*Scraper, opts ...CollectorOption) *Collector

NewCollector will create and return a new Collector.

func (*Collector) Collect

func (c *Collector) Collect(ch chan<- prometheus.Metric)

Collect implements the prometheus.Collector interface. Collect and register metrics.

func (*Collector) Describe

func (c *Collector) Describe(ch chan<- *prometheus.Desc)

Describe implements the prometheus.Collector interface. Register prometheus.Desc. It is called at registration time and is used to avoid duplicate registration of metrics.

type CollectorOption

type CollectorOption func(*Collector)

CollectorOption is a functional option used by the NewCollector.

func Logger

func Logger(logger logr.Logger) CollectorOption

Logger is an option available for NewCollector. You can set a logger that implements the logr.Logger interface. If a logger is set, an error will be output to the log. If the logger is not set, nothing will be output.

type MergeOption

type MergeOption func(mfs1, mfs2 []*dto.MetricFamily)

MergeOption is a functional option used by the MergeMetricFamily.

func AddIdentifierLabel

func AddIdentifierLabel(mfs1, mfs2 []*dto.MetricFamily, label model.LabelName, mfs1Identifier, mfs2Identifier model.LabelValue) MergeOption

AddIdentifierLabel is an option available for MergeMetricFamily. Add labels for identifiers to avoid metric conflicts when merging.

type Scraper

type Scraper struct {
	// URL is the URL of the scraping target.
	URL string

	// Labels is a set of labels to be added to the scraped metrics.
	// If not specified, nothing will be added.
	Labels model.LabelSet

	// HTTPClient is the http.Client to be used for the request. If not specified, the http.DefaultClient will be used.
	HTTPClient *http.Client
}

Scraper will scrape metrics from prometheus exporter.

func NewScraper

func NewScraper(url string, opts ...ScraperOption) *Scraper

NewScraper creates and returns a new Scraper.

func (*Scraper) Scrape

func (s *Scraper) Scrape(ctx context.Context) ([]*dto.MetricFamily, error)

Scrape.

type ScraperOption

type ScraperOption func(*Scraper)

ScraperOption is a functional option used by the NewScraper.

func HTTPClient

func HTTPClient(client *http.Client) ScraperOption

HTTPClient is an option available for NewScraper. Override the http.DefaultClient.

func Labels

func Labels(labelSets model.LabelSet) ScraperOption

Labels is an option available for NewScraper. This will be used to add labels to the scraped metrics.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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