metrics

package
v0.0.0-...-12ff3c0 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2022 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddMetricsHandler

func AddMetricsHandler(handler http.HandlerFunc, prometheusQuery PrometheusQueryFetcher) http.HandlerFunc

AddMetricsHandler wraps a http.HandlerFunc with Prometheus metrics

func PrometheusHandler

func PrometheusHandler() http.Handler

PrometheusHandler Bootstraps prometheus for metrics collection

func RegisterExporter

func RegisterExporter(exporter *Exporter)

RegisterExporter registers with Prometheus for tracking

Types

type Exporter

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

Exporter is a prometheus exporter

func NewExporter

func NewExporter(options MetricOptions, credentials *auth.BasicAuthCredentials) *Exporter

NewExporter creates a new exporter for the OpenFaaS gateway metrics

func (*Exporter) Collect

func (e *Exporter) Collect(ch chan<- prometheus.Metric)

Collect collects data to be consumed by prometheus

func (*Exporter) Describe

func (e *Exporter) Describe(ch chan<- *prometheus.Desc)

Describe is to describe the metrics for Prometheus

func (*Exporter) StartServiceWatcher

func (e *Exporter) StartServiceWatcher(endpointURL url.URL, metricsOptions MetricOptions, label string, interval time.Duration)

StartServiceWatcher starts a ticker and collects service replica counts to expose to prometheus

type MetricOptions

type MetricOptions struct {
	GatewayFunctionInvocation *prometheus.CounterVec
	GatewayFunctionsHistogram *prometheus.HistogramVec
	ServiceReplicasGauge      *prometheus.GaugeVec
	ServiceMetrics            *ServiceMetricOptions
}

MetricOptions to be used by web handlers

func BuildMetricsOptions

func BuildMetricsOptions() MetricOptions

BuildMetricsOptions builds metrics for tracking functions in the API gateway

type PrometheusQuery

type PrometheusQuery struct {
	Port   int
	Host   string
	Client *http.Client
}

PrometheusQuery represents parameters for querying Prometheus

func NewPrometheusQuery

func NewPrometheusQuery(host string, port int, client *http.Client) PrometheusQuery

NewPrometheusQuery create a NewPrometheusQuery

func (PrometheusQuery) Fetch

func (q PrometheusQuery) Fetch(query string) (*VectorQueryResponse, error)

Fetch queries aggregated stats

type PrometheusQueryFetcher

type PrometheusQueryFetcher interface {
	Fetch(query string) (*VectorQueryResponse, error)
}

type ServiceMetricOptions

type ServiceMetricOptions struct {
	Histogram *prometheus.HistogramVec
	Counter   *prometheus.CounterVec
}

ServiceMetricOptions provides RED metrics

type VectorQueryResponse

type VectorQueryResponse struct {
	Data struct {
		Result []struct {
			Metric struct {
				Code         string `json:"code"`
				FunctionName string `json:"function_name"`
			}
			Value []interface{} `json:"value"`
		}
	}
}

Jump to

Keyboard shortcuts

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