Documentation
¶
Index ¶
- func CachedHandlerFor(reg prometheus.Gatherer, opts promhttp.HandlerOpts, ...) http.Handler
- func FindHistogramWithNameAndLabels(metrics MetricFamilyMap, name string, labelNamesAndValues ...string) (*dto.Histogram, error)
- func FindMetricsInFamilyMatchingLabels(mf *dto.MetricFamily, labelNamesAndValues ...string) []*dto.Metric
- func MatchesLabels(m *dto.Metric, labelNamesAndValues ...string) bool
- func WithSkipZeroValueMetrics(options *metricOptions)
- type HistogramData
- type HistogramDataCollector
- type MetricFamiliesPerTenant
- func (d MetricFamiliesPerTenant) GetSumOfCounters(counter string) float64
- func (d MetricFamiliesPerTenant) GetSumOfGauges(gauge string) float64
- func (d MetricFamiliesPerTenant) SendMaxOfGauges(out chan<- prometheus.Metric, desc *prometheus.Desc, gauge string)
- func (d MetricFamiliesPerTenant) SendMaxOfGaugesPerTenant(out chan<- prometheus.Metric, desc *prometheus.Desc, gauge string)
- func (d MetricFamiliesPerTenant) SendMinOfGauges(out chan<- prometheus.Metric, desc *prometheus.Desc, gauge string)
- func (d MetricFamiliesPerTenant) SendSumOfCounters(out chan<- prometheus.Metric, desc *prometheus.Desc, counter string)
- func (d MetricFamiliesPerTenant) SendSumOfCountersPerTenant(out chan<- prometheus.Metric, desc *prometheus.Desc, metric string, ...)
- func (d MetricFamiliesPerTenant) SendSumOfCountersWithLabels(out chan<- prometheus.Metric, desc *prometheus.Desc, counter string, ...)
- func (d MetricFamiliesPerTenant) SendSumOfGauges(out chan<- prometheus.Metric, desc *prometheus.Desc, gauge string)
- func (d MetricFamiliesPerTenant) SendSumOfGaugesPerTenant(out chan<- prometheus.Metric, desc *prometheus.Desc, metric string, ...)
- func (d MetricFamiliesPerTenant) SendSumOfGaugesPerTenantWithLabels(out chan<- prometheus.Metric, desc *prometheus.Desc, metric string, ...)deprecated
- func (d MetricFamiliesPerTenant) SendSumOfGaugesWithLabels(out chan<- prometheus.Metric, desc *prometheus.Desc, gauge string, ...)
- func (d MetricFamiliesPerTenant) SendSumOfHistograms(out chan<- prometheus.Metric, desc *prometheus.Desc, histogramName string)
- func (d MetricFamiliesPerTenant) SendSumOfHistogramsWithLabels(out chan<- prometheus.Metric, desc *prometheus.Desc, histogramName string, ...)
- func (d MetricFamiliesPerTenant) SendSumOfSummaries(out chan<- prometheus.Metric, desc *prometheus.Desc, summaryName string)
- func (d MetricFamiliesPerTenant) SendSumOfSummariesPerTenant(out chan<- prometheus.Metric, desc *prometheus.Desc, summaryName string)
- func (d MetricFamiliesPerTenant) SendSumOfSummariesWithLabels(out chan<- prometheus.Metric, desc *prometheus.Desc, summaryName string, ...)
- type MetricFamilyMap
- func (mfm MetricFamilyMap) MaxGauges(name string) float64
- func (mfm MetricFamilyMap) MinGauges(name string) float64
- func (mfm MetricFamilyMap) SumCounters(name string) float64
- func (mfm MetricFamilyMap) SumGauges(name string) float64
- func (mfm MetricFamilyMap) SumHistograms(name string) HistogramData
- func (mfm MetricFamilyMap) SumHistogramsTo(name string, output *HistogramData)
- func (mfm MetricFamilyMap) SumSummaries(name string) SummaryData
- func (mfm MetricFamilyMap) SumSummariesTo(name string, output *SummaryData)
- type MetricOption
- type SummaryData
- type TenantRegistries
- func (r *TenantRegistries) AddTenantRegistry(tenant string, reg *prometheus.Registry)
- func (r *TenantRegistries) BuildMetricFamiliesPerTenant() MetricFamiliesPerTenant
- func (r *TenantRegistries) GetRegistryForTenant(tenant string) *prometheus.Registry
- func (r *TenantRegistries) Registries() []TenantRegistry
- func (r *TenantRegistries) RemoveTenantRegistry(tenant string, hard bool)
- type TenantRegistry
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CachedHandlerFor ¶
func CachedHandlerFor(reg prometheus.Gatherer, opts promhttp.HandlerOpts, cacheDuration time.Duration) http.Handler
CachedHandlerFor is promhttp.HandlerFor with an in-memory response cache. A non-positive cacheDuration disables caching. Successful GET responses are cached for at most cacheDuration from the start of collection, independently for up to eight Accept/Accept-Encoding combinations. Full and name[]-filtered GETs share one cached Gather result; filtered responses are encoded per request. Other query parameters and methods bypass both caches. Cached metrics can lag behind live values by cacheDuration; consider scrape intervals and alerts. With caching enabled, overlapping collections are always coalesced across variants and bypassed requests, regardless of opts.CoalesceGather.
func FindHistogramWithNameAndLabels ¶
func FindHistogramWithNameAndLabels(metrics MetricFamilyMap, name string, labelNamesAndValues ...string) (*dto.Histogram, error)
FindHistogramWithNameAndLabels returns the histogram in metrics with name that matches the labels in labelNamesAndValues. If no histogram with name is present in metrics, if labelNamesAndValues matches anything other than exactly one metric, or if the matching metric is not a histogram, an error is returned.
func FindMetricsInFamilyMatchingLabels ¶
func FindMetricsInFamilyMatchingLabels(mf *dto.MetricFamily, labelNamesAndValues ...string) []*dto.Metric
FindMetricsInFamilyMatchingLabels returns all the metrics in mf that match the labels in labelNamesAndValues.
func MatchesLabels ¶
MatchesLabels returns true if m has all the labels in l.
func WithSkipZeroValueMetrics ¶
func WithSkipZeroValueMetrics(options *metricOptions)
WithSkipZeroValueMetrics controls whether metrics aggregation should skip zero value metrics.
Types ¶
type HistogramData ¶
type HistogramData struct {
// contains filtered or unexported fields
}
HistogramData keeps data required to build histogram Metric.
func (*HistogramData) AddHistogram ¶
func (d *HistogramData) AddHistogram(histo *dto.Histogram)
AddHistogram adds histogram from gathered metrics to this histogram data. Do not call this function after Metric() has been invoked, because histogram created by Metric is using the buckets map (doesn't make a copy), and it's not allowed to change the buckets after they've been passed to a prometheus.Metric.
func (*HistogramData) AddHistogramData ¶
func (d *HistogramData) AddHistogramData(histo HistogramData)
AddHistogramData merges another histogram data into this one. Do not call this function after Metric() has been invoked, because histogram created by Metric is using the buckets map (doesn't make a copy), and it's not allowed to change the buckets after they've been passed to a prometheus.Metric.
func (*HistogramData) Copy ¶
func (d *HistogramData) Copy() *HistogramData
Copy returns a copy of this histogram data.
func (HistogramData) Count ¶
func (d HistogramData) Count() uint64
Count returns the histogram count value.
func (*HistogramData) Metric ¶
func (d *HistogramData) Metric(desc *prometheus.Desc, labelValues ...string) prometheus.Metric
Metric returns prometheus metric from this histogram data.
Note that returned metric shares bucket with this HistogramData, so avoid doing more modifications to this HistogramData after calling Metric.
type HistogramDataCollector ¶
type HistogramDataCollector struct {
// contains filtered or unexported fields
}
HistogramDataCollector combines histogram data, with prometheus descriptor. It can be registered into prometheus to report histogram with stored data. Data can be updated via Add method.
func NewHistogramDataCollector ¶
func NewHistogramDataCollector(desc *prometheus.Desc) *HistogramDataCollector
NewHistogramDataCollector creates new histogram data collector.
func (*HistogramDataCollector) Add ¶
func (h *HistogramDataCollector) Add(hd HistogramData)
func (*HistogramDataCollector) Collect ¶
func (h *HistogramDataCollector) Collect(out chan<- prometheus.Metric)
func (*HistogramDataCollector) Describe ¶
func (h *HistogramDataCollector) Describe(out chan<- *prometheus.Desc)
type MetricFamiliesPerTenant ¶
type MetricFamiliesPerTenant []struct {
// contains filtered or unexported fields
}
MetricFamiliesPerTenant is a collection of metrics gathered via calling Gatherer.Gather() method on different gatherers, one per tenant.
func (MetricFamiliesPerTenant) GetSumOfCounters ¶
func (d MetricFamiliesPerTenant) GetSumOfCounters(counter string) float64
func (MetricFamiliesPerTenant) GetSumOfGauges ¶
func (d MetricFamiliesPerTenant) GetSumOfGauges(gauge string) float64
func (MetricFamiliesPerTenant) SendMaxOfGauges ¶
func (d MetricFamiliesPerTenant) SendMaxOfGauges(out chan<- prometheus.Metric, desc *prometheus.Desc, gauge string)
func (MetricFamiliesPerTenant) SendMaxOfGaugesPerTenant ¶
func (d MetricFamiliesPerTenant) SendMaxOfGaugesPerTenant(out chan<- prometheus.Metric, desc *prometheus.Desc, gauge string)
func (MetricFamiliesPerTenant) SendMinOfGauges ¶
func (d MetricFamiliesPerTenant) SendMinOfGauges(out chan<- prometheus.Metric, desc *prometheus.Desc, gauge string)
func (MetricFamiliesPerTenant) SendSumOfCounters ¶
func (d MetricFamiliesPerTenant) SendSumOfCounters(out chan<- prometheus.Metric, desc *prometheus.Desc, counter string)
func (MetricFamiliesPerTenant) SendSumOfCountersPerTenant ¶
func (d MetricFamiliesPerTenant) SendSumOfCountersPerTenant(out chan<- prometheus.Metric, desc *prometheus.Desc, metric string, options ...MetricOption)
SendSumOfCountersPerTenant provides metrics on a per-tenant basis, with additional and optional label names. This function assumes that `tenant` is the first label on the provided metric Desc.
func (MetricFamiliesPerTenant) SendSumOfCountersWithLabels ¶
func (d MetricFamiliesPerTenant) SendSumOfCountersWithLabels(out chan<- prometheus.Metric, desc *prometheus.Desc, counter string, labelNames ...string)
func (MetricFamiliesPerTenant) SendSumOfGauges ¶
func (d MetricFamiliesPerTenant) SendSumOfGauges(out chan<- prometheus.Metric, desc *prometheus.Desc, gauge string)
func (MetricFamiliesPerTenant) SendSumOfGaugesPerTenant ¶
func (d MetricFamiliesPerTenant) SendSumOfGaugesPerTenant(out chan<- prometheus.Metric, desc *prometheus.Desc, metric string, options ...MetricOption)
SendSumOfGaugesPerTenant provides metrics on a per-tenant basis. This function assumes that `tenant` is the first label on the provided metric Desc.
func (MetricFamiliesPerTenant) SendSumOfGaugesPerTenantWithLabels
deprecated
func (d MetricFamiliesPerTenant) SendSumOfGaugesPerTenantWithLabels(out chan<- prometheus.Metric, desc *prometheus.Desc, metric string, labelNames ...string)
SendSumOfGaugesPerTenantWithLabels provides metrics with the provided label names on a per-tenant basis. This function assumes that `tenant` is the first label on the provided metric Desc
Deprecated: use SendSumOfGaugesPerTenant with WithLabels option instead.
func (MetricFamiliesPerTenant) SendSumOfGaugesWithLabels ¶
func (d MetricFamiliesPerTenant) SendSumOfGaugesWithLabels(out chan<- prometheus.Metric, desc *prometheus.Desc, gauge string, labelNames ...string)
func (MetricFamiliesPerTenant) SendSumOfHistograms ¶
func (d MetricFamiliesPerTenant) SendSumOfHistograms(out chan<- prometheus.Metric, desc *prometheus.Desc, histogramName string)
func (MetricFamiliesPerTenant) SendSumOfHistogramsWithLabels ¶
func (d MetricFamiliesPerTenant) SendSumOfHistogramsWithLabels(out chan<- prometheus.Metric, desc *prometheus.Desc, histogramName string, labelNames ...string)
func (MetricFamiliesPerTenant) SendSumOfSummaries ¶
func (d MetricFamiliesPerTenant) SendSumOfSummaries(out chan<- prometheus.Metric, desc *prometheus.Desc, summaryName string)
func (MetricFamiliesPerTenant) SendSumOfSummariesPerTenant ¶
func (d MetricFamiliesPerTenant) SendSumOfSummariesPerTenant(out chan<- prometheus.Metric, desc *prometheus.Desc, summaryName string)
func (MetricFamiliesPerTenant) SendSumOfSummariesWithLabels ¶
func (d MetricFamiliesPerTenant) SendSumOfSummariesWithLabels(out chan<- prometheus.Metric, desc *prometheus.Desc, summaryName string, labelNames ...string)
type MetricFamilyMap ¶
type MetricFamilyMap map[string]*dto.MetricFamily
MetricFamilyMap is a map of metric names to their family (metrics with same name, but different labels) Keeping map of metric name to its family makes it easier to do searches later.
func NewMetricFamilyMap ¶
func NewMetricFamilyMap(metrics []*dto.MetricFamily) (MetricFamilyMap, error)
NewMetricFamilyMap sorts output from Gatherer.Gather method into a map. Gatherer.Gather specifies that there metric families are uniquely named, and we use that fact here. If they are not, this method returns error.
func NewMetricFamilyMapFromGatherer ¶
func NewMetricFamilyMapFromGatherer(gatherer prometheus.Gatherer) (MetricFamilyMap, error)
NewMetricFamilyMapFromGatherer is like NewMetricFamilyMap but gets metrics directly from a prometheus.Gatherer instance.
func (MetricFamilyMap) MaxGauges ¶
func (mfm MetricFamilyMap) MaxGauges(name string) float64
MaxGauges returns max of gauges or NaN, if no gauge was found.
func (MetricFamilyMap) MinGauges ¶
func (mfm MetricFamilyMap) MinGauges(name string) float64
MinGauges returns minimum of gauges or NaN if no gauge was found.
func (MetricFamilyMap) SumCounters ¶
func (mfm MetricFamilyMap) SumCounters(name string) float64
SumCounters returns sum of counters or 0, if no counter was found.
func (MetricFamilyMap) SumGauges ¶
func (mfm MetricFamilyMap) SumGauges(name string) float64
SumGauges returns sum of gauges or 0, if no gauge was found.
func (MetricFamilyMap) SumHistograms ¶
func (mfm MetricFamilyMap) SumHistograms(name string) HistogramData
func (MetricFamilyMap) SumHistogramsTo ¶
func (mfm MetricFamilyMap) SumHistogramsTo(name string, output *HistogramData)
func (MetricFamilyMap) SumSummaries ¶
func (mfm MetricFamilyMap) SumSummaries(name string) SummaryData
func (MetricFamilyMap) SumSummariesTo ¶
func (mfm MetricFamilyMap) SumSummariesTo(name string, output *SummaryData)
type MetricOption ¶
type MetricOption func(options *metricOptions)
MetricOption defines a functional-style option for metrics aggregation.
func WithLabels ¶
func WithLabels(labelNames ...string) MetricOption
WithLabels set labels to use for aggregations.
type SummaryData ¶
type SummaryData struct {
// contains filtered or unexported fields
}
SummaryData keeps all data needed to create summary metric
func (*SummaryData) AddSummary ¶
func (s *SummaryData) AddSummary(sum *dto.Summary)
func (*SummaryData) Metric ¶
func (s *SummaryData) Metric(desc *prometheus.Desc, labelValues ...string) prometheus.Metric
type TenantRegistries ¶
type TenantRegistries struct {
// contains filtered or unexported fields
}
TenantRegistries holds Prometheus registries for multiple tenants, guaranteeing multi-thread safety and stable ordering.
func NewTenantRegistries ¶
func NewTenantRegistries(logger log.Logger) *TenantRegistries
NewTenantRegistries makes new TenantRegistries.
func (*TenantRegistries) AddTenantRegistry ¶
func (r *TenantRegistries) AddTenantRegistry(tenant string, reg *prometheus.Registry)
AddTenantRegistry adds a tenant registry. If tenant already has a registry, previous registry is removed, but latest metric values are preserved in order to avoid counter resets.
func (*TenantRegistries) BuildMetricFamiliesPerTenant ¶
func (r *TenantRegistries) BuildMetricFamiliesPerTenant() MetricFamiliesPerTenant
func (*TenantRegistries) GetRegistryForTenant ¶
func (r *TenantRegistries) GetRegistryForTenant(tenant string) *prometheus.Registry
GetRegistryForTenant returns currently active registry for given tenant, or nil, if there is no such registry.
func (*TenantRegistries) Registries ¶
func (r *TenantRegistries) Registries() []TenantRegistry
Registries returns a copy of the tenant registries list.
func (*TenantRegistries) RemoveTenantRegistry ¶
func (r *TenantRegistries) RemoveTenantRegistry(tenant string, hard bool)
RemoveTenantRegistry removes all Prometheus registries for a given tenant. If hard is true, registry is removed completely. If hard is false, the latest registry values are preserved in an "archive" registry.
type TenantRegistry ¶
type TenantRegistry struct {
// contains filtered or unexported fields
}
TenantRegistry holds a Prometheus registry associated to a specific tenant.