metricsscraper

package
v1.6.1-0...-f207c0f Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2025 License: Apache-2.0 Imports: 38 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// KongMetricTagK8sName is the tag set on Kong Services in the Admin API
	// configuration to indicate the name of the Kubernetes Service associated
	// with the Kong Service.
	KongMetricTagK8sName = "k8s-name"
	// KongMetricTagK8sNamespace is the tag set on Kong Services in the Admin API
	// configuration to indicate the namespace of the Kubernetes Service associated
	// with the Kong Service.
	KongMetricTagK8sNamespace = "k8s-namespace"
)
View Source
const (
	// KongMetricNameKongUpstreamLatencyMs is the name of the kong_upstream_latency_ms metric.
	KongMetricNameKongUpstreamLatencyMs = "kong_upstream_latency_ms"
)

Variables

View Source
var KongUpstreamLatencyMsHistogram = &HistogramCollector{
	Name:    KongMetricNameKongUpstreamLatencyMs,
	Help:    "Provides kong_upstream_latency_ms histogram enriched with dataplane metadata",
	Metrics: make(map[adminAPIEndpointURL]prometheus.Metric),
}

KongUpstreamLatencyMsHistogram is a prometheus.Collector that collects kong_upstream_latency_ms histograms.

Functions

func NewAdminAPIAddressProvider

func NewAdminAPIAddressProvider(cl client.Client) *adminAPIAddressProvider

NewAdminAPIAddressProvider creates a new AdminAPIAddressProvider.

func NewEnricher

func NewEnricher(
	logger logr.Logger,
	dataplane *operatorv1beta1.DataPlane,
	cl client.Client,
	certs certs,
	adminAPIAddressProvider AdminAPIAddressProvider,
) (metricsEnricher, error)

NewEnricher creates a new MetricsEnricher.

Types

type AdminAPIAddressProvider

type AdminAPIAddressProvider interface {
	AdminAddressesForDP(ctx context.Context, dataplane *operatorv1beta1.DataPlane) ([]string, error)
}

AdminAPIAddressProvider is an interface for providing the admin API addresses for a DataPlane.

type DiscoveredAdminAPI

type DiscoveredAdminAPI struct {
	// Address is the Admin API's URL reachable from within the cluster.
	Address string
}

DiscoveredAdminAPI represents an Admin API discovered from a Kubernetes Service.

type HistogramCollector

type HistogramCollector struct {
	Name string
	Help string

	Metrics map[adminAPIEndpointURL]prometheus.Metric
	// contains filtered or unexported fields
}

HistogramCollector is a prometheus.Collector that collects histograms.

func (*HistogramCollector) Collect

func (m *HistogramCollector) Collect(ch chan<- prometheus.Metric)

Collect implements prometheus.Collector.

func (*HistogramCollector) Describe

func (m *HistogramCollector) Describe(ch chan<- *prometheus.Desc)

Describe implements prometheus.Collector.

func (*HistogramCollector) Observe

func (m *HistogramCollector) Observe(metric *dto.Metric, dataplaneURL adminAPIEndpointURL)

Observe observes a metric for a given dataplaneURL.

type HistogramPassthroughMetric

type HistogramPassthroughMetric struct {
	Name   string
	Help   string
	Metric *dto.Metric
}

HistogramPassthroughMetric is a prometheus.Metric that passes through a dto.Metric. It allows observing whole histograms and not observing individual data points like it's done with prometheus.HistogramVec.

func (*HistogramPassthroughMetric) Desc

Desc implements prometheus.Metric.

func (*HistogramPassthroughMetric) Write

Write implements prometheus.Write. Passed parameter dm is an output for metrics (target of write).

type Manager

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

Manager is a manager for metrics scrapers.

func NewManager

func NewManager(
	logger logr.Logger,
	interval time.Duration,
	cl client.Client,
	caSecretNN types.NamespacedName,
	clusterCAKeyConfig secrets.KeyConfig,
) *Manager

NewManager creates new MetricsScrapeManager.

func (*Manager) Add

func (msm *Manager) Add(cp *gwtypes.ControlPlane, pipeline MetricsScrapePipeline) bool

Add adds a scraper to the manager for the given ControlPlane. If a scraper already exists for the given DataPlane UID, it is replaced. User is responsible for ensuring that the scraper is configured for DataPlane that is associated with the given ControlPlane. It returns true if the scraper was added.

func (*Manager) NotifyAdd

func (msm *Manager) NotifyAdd(ctx context.Context, cp *gwtypes.ControlPlane)

NotifyAdd notifies the manager that a new ControlPlane has been added.

func (*Manager) NotifyRemove

func (msm *Manager) NotifyRemove(ctx context.Context, cp types.NamespacedName)

NotifyRemove notifies the manager that a ControlPlane has been removed. It uses the ControlPlane's NamespacedName to identify the ControlPlane because the ControlPlane object is already deleted when this method is called.

func (*Manager) RemoveForControlPlaneNN

func (msm *Manager) RemoveForControlPlaneNN(cpNN types.NamespacedName)

RemoveForControlPlaneNN removes a scraper from the manager for the given ControlPlane.

func (*Manager) Start

func (msm *Manager) Start(ctx context.Context) error

Start starts the metrics scraping loop. It spawns a goroutine that periodically scrapes metrics from the enabled scrapers. This satisfies the Manager interface and can be used with controller-runtime Manager.

type Metrics

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

Metrics represents a collection of metrics scraped from a DataPlane.

type MetricsConsumer

type MetricsConsumer interface {
	Consume(context.Context, Metrics) error
}

MetricsConsumer is an interface for consumers of metrics scraped by a MetricsScraper.

type MetricsEnricher

type MetricsEnricher interface {
	Consume(context.Context, Metrics) error
}

MetricsEnricher consumes Metrics and enriches them with Kubernetes metadata.

type MetricsScrapePipeline

type MetricsScrapePipeline interface {
	MetricsScraper
	MetricsEnricher
}

MetricsScrapePipeline is a pipeline for scraping and enriching metrics.

type MetricsScraper

type MetricsScraper interface {
	Scrape(ctx context.Context) (Metrics, error)
	DataPlaneUID() types.UID
}

MetricsScraper is an interface for a scraper that scrapes metrics from a DataPlane.

func NewPrometheusMetricsScraper

func NewPrometheusMetricsScraper(
	logger logr.Logger, dp *operatorv1beta1.DataPlane, httpClient *http.Client, adminAPIAddrProvider AdminAPIAddressProvider,
) MetricsScraper

NewPrometheusMetricsScraper creates a new PrometheusMetricsScraper that scrapes metrics from the Admin API endpoints of the provided DataPlane.

type PrometheusMetricsScraper

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

PrometheusMetricsScraper is a MetricsScraper that scrapes Prometheus metrics from the Admin API endpoint of provided DataPlane.

func (*PrometheusMetricsScraper) DataPlaneUID

func (p *PrometheusMetricsScraper) DataPlaneUID() types.UID

DataPlaneUID returns the UID of the DataPlane this scraper is scraping metrics for.

func (*PrometheusMetricsScraper) Scrape

Scrape scrapes metrics from the Admin API endpoints of the configured DataPlane.

Jump to

Keyboard shortcuts

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