metrics

package
v0.0.0-...-75da391 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2019 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

Package metrics provides Knative utilities for exporting metrics to Stackdriver backend or Prometheus backend based on config-observability settings.

Index

Constants

View Source
const (
	DomainEnv        = "METRICS_DOMAIN"
	ConfigMapNameEnv = "CONFIG_OBSERVABILITY_NAME"
)
View Source
const (
	// The following keys are used to configure metrics reporting.
	// See https://github.com/knative/serving/blob/master/config/config-observability.yaml
	// for details.
	AllowStackdriverCustomMetricsKey = "metrics.allow-stackdriver-custom-metrics"
	BackendDestinationKey            = "metrics.backend-destination"
	ReportingPeriodKey               = "metrics.reporting-period-seconds"
	StackdriverProjectIDKey          = "metrics.stackdriver-project-id"

	// Stackdriver is used for Stackdriver backend
	Stackdriver metricsBackend = "stackdriver"
	// Prometheus is used for Prometheus backend
	Prometheus metricsBackend = "prometheus"
)

Variables

This section is empty.

Functions

func Buckets125

func Buckets125(low, high float64) []float64

Buckets125 generates an array of buckets with approximate powers-of-two buckets that also aligns with powers of 10 on every 3rd step. This can be used to create a view.Distribution.

func ConfigMapName

func ConfigMapName() string

ConfigMapName gets the name of the metrics ConfigMap

func Domain

func Domain() string

Domain holds the metrics domain to use for surfacing metrics.

func FlushExporter

func FlushExporter() bool

FlushExporter waits for exported data to be uploaded. This should be called before the process shuts down or exporter is replaced. Return value indicates whether the exporter is flushable or not.

func GetKnativeBrokerMonitoredResource

func GetKnativeBrokerMonitoredResource(
	v *view.View, tags []tag.Tag, gm *gcpMetadata) ([]tag.Tag, monitoredresource.Interface)

func GetKnativeImporterMonitoredResource

func GetKnativeImporterMonitoredResource(
	v *view.View, tags []tag.Tag, gm *gcpMetadata) ([]tag.Tag, monitoredresource.Interface)

func GetKnativeRevisionMonitoredResource

func GetKnativeRevisionMonitoredResource(
	v *view.View, tags []tag.Tag, gm *gcpMetadata) ([]tag.Tag, monitoredresource.Interface)

func GetKnativeTriggerMonitoredResource

func GetKnativeTriggerMonitoredResource(
	v *view.View, tags []tag.Tag, gm *gcpMetadata) ([]tag.Tag, monitoredresource.Interface)

func Record

func Record(ctx context.Context, ms stats.Measurement)

Record decides whether to record one measurement via OpenCensus based on the following conditions:

  1. No package level metrics config. In this case it just proxies to OpenCensus based on the assumption that users expect the metrics to be recorded when they call this function. Users must ensure metrics config are set before using this function to get expected behavior.
  2. The backend is not Stackdriver.
  3. The backend is Stackdriver and it is allowed to use custom metrics.
  4. The backend is Stackdriver and the metric is one of the built-in metrics: "knative_revision", "knative_broker", "knative_trigger", "knative_importer".

func UpdateExporter

func UpdateExporter(ops ExporterOptions, logger *zap.SugaredLogger) error

UpdateExporter updates the exporter based on the given ExporterOptions.

func UpdateExporterFromConfigMap

func UpdateExporterFromConfigMap(component string, logger *zap.SugaredLogger) func(configMap *corev1.ConfigMap)

UpdateExporterFromConfigMap returns a helper func that can be used to update the exporter when a config map is updated.

Types

type ExporterOptions

type ExporterOptions struct {
	// Domain is the metrics domain. e.g. "knative.dev". Must be present.
	Domain string

	// Component is the name of the component that emits the metrics. e.g.
	// "activator", "queue_proxy". Should only contains alphabets and underscore.
	// Must be present.
	Component string

	// PrometheusPort is the port to expose metrics if metrics backend is Prometheus.
	// It should be between maxPrometheusPort and maxPrometheusPort. 0 value means
	// using the default 9090 value. If is ignored if metrics backend is not
	// Prometheus.
	PrometheusPort int

	// ConfigMap is the data from config map config-observability. Must be present.
	// See https://github.com/knative/serving/blob/master/config/config-observability.yaml
	// for details.
	ConfigMap map[string]string
}

ExporterOptions contains options for configuring the exporter.

type Global

type Global struct{}

func (*Global) MonitoredResource

func (g *Global) MonitoredResource() (resType string, labels map[string]string)

type KnativeBroker

type KnativeBroker struct {
	Project       string
	Location      string
	ClusterName   string
	NamespaceName string
	BrokerName    string
}

func (*KnativeBroker) MonitoredResource

func (kb *KnativeBroker) MonitoredResource() (resType string, labels map[string]string)

type KnativeImporter

type KnativeImporter struct {
	Project               string
	Location              string
	ClusterName           string
	NamespaceName         string
	ImporterName          string
	ImporterResourceGroup string
}

func (*KnativeImporter) MonitoredResource

func (ki *KnativeImporter) MonitoredResource() (resType string, labels map[string]string)

type KnativeRevision

type KnativeRevision struct {
	Project           string
	Location          string
	ClusterName       string
	NamespaceName     string
	ServiceName       string
	ConfigurationName string
	RevisionName      string
}

func (*KnativeRevision) MonitoredResource

func (kr *KnativeRevision) MonitoredResource() (resType string, labels map[string]string)

type KnativeTrigger

type KnativeTrigger struct {
	Project               string
	Location              string
	ClusterName           string
	NamespaceName         string
	TriggerName           string
	BrokerName            string
	TypeFilterAttribute   string
	SourceFilterAttribute string
}

func (*KnativeTrigger) MonitoredResource

func (kt *KnativeTrigger) MonitoredResource() (resType string, labels map[string]string)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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