metrics

package
v1.13.0-rc.4 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2022 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// OpenTelemetry is the app label for all otel resources.
	OpenTelemetry = "opentelemetry"

	// OtelAgentName is the name of the OpenTelemetry Agent.
	OtelAgentName = "otel-agent"

	// OtelCollectorName is the name of the OpenTelemetry Collector.
	OtelCollectorName = "otel-collector"

	// OtelCollectorGooglecloud is the name of the OpenTelemetry Collector ConfigMap that contains Googlecloud exporter.
	OtelCollectorGooglecloud = "otel-collector-googlecloud"

	// OtelCollectorCustomCM is the name of the custom OpenTelemetry Collector ConfigMap.
	OtelCollectorCustomCM = "otel-collector-custom"

	// MonitoringNamespace is the Namespace used for OpenTelemetry Collector deployment.
	MonitoringNamespace = "config-management-monitoring"

	// CollectorConfigGooglecloud is the OpenTelemetry Collector configuration with
	// the googlecloud exporter.
	CollectorConfigGooglecloud = `` /* 3737-byte string literal not displayed */

)

Variables

View Source
var (
	// APICallDuration metric measures the latency of API server calls.
	APICallDuration = stats.Float64(
		"api_duration_seconds",
		"The duration of API server calls in seconds",
		stats.UnitSeconds)

	// ReconcilerErrors metric measures the number of errors in the reconciler.
	ReconcilerErrors = stats.Int64(
		"reconciler_errors",
		"The number of errors in the reconciler",
		stats.UnitDimensionless)

	// PipelineError metric measures the error by components when syncing a commit
	PipelineError = stats.Int64(
		"pipeline_error_observed",
		"A boolean indicates if any error happens from different stages when syncing a commit",
		stats.UnitDimensionless)

	// ReconcileDuration metric measures the latency of reconcile events.
	ReconcileDuration = stats.Float64(
		"reconcile_duration_seconds",
		"The duration of reconcile events in seconds",
		stats.UnitSeconds)

	// ParserDuration metric measures the latency of the parse-apply-watch loop.
	ParserDuration = stats.Float64(
		"parser_duration_seconds",
		"The duration of the parse-apply-watch loop in seconds",
		stats.UnitSeconds)

	// LastSync metric measures the timestamp of the latest Git sync.
	LastSync = stats.Int64(
		"last_sync_timestamp",
		"The timestamp of the most recent sync from Git",
		stats.UnitDimensionless)

	// DeclaredResources metric measures the number of declared resources parsed from Git.
	DeclaredResources = stats.Int64(
		"declared_resources",
		"The number of declared resources parsed from Git",
		stats.UnitDimensionless)

	// ApplyOperations metric measures the number of applier apply events.
	ApplyOperations = stats.Int64(
		"apply_operations",
		"The number of operations that have been performed to sync resources to source of truth",
		stats.UnitDimensionless)

	// ApplyDuration metric measures the latency of applier apply events.
	ApplyDuration = stats.Float64(
		"apply_duration_seconds",
		"The duration of applier events in seconds",
		stats.UnitSeconds)

	// ResourceFights metric measures the number of resource fights.
	ResourceFights = stats.Int64(
		"resource_fights",
		"The number of resources that are being synced too frequently",
		stats.UnitDimensionless)

	// RemediateDuration metric measures the latency of remediator reconciliation events.
	RemediateDuration = stats.Float64(
		"remediate_duration_seconds",
		"The duration of remediator reconciliation events",
		stats.UnitSeconds)

	// LastApply metric measures the timestamp of the most recent applier apply event.
	LastApply = stats.Int64(
		"last_apply_timestamp",
		"The timestamp of the most recent applier event",
		stats.UnitDimensionless)

	// ResourceConflicts metric measures the number of resource conflicts.
	ResourceConflicts = stats.Int64(
		"resource_conflicts",
		"The number of resource conflicts resulting from a mismatch between the cached resources and cluster resources",
		stats.UnitDimensionless)

	// InternalErrors metric measures the number of unexpected internal errors triggered by defensive checks in Config Sync.
	InternalErrors = stats.Int64(
		"internal_errors",
		"The number of internal errors triggered by Config Sync",
		stats.UnitDimensionless)

	// RenderingCount metrics measures the number of renderings are performed.
	RenderingCount = stats.Int64(
		"rendering_count",
		"The number of renderings that are performed",
		stats.UnitDimensionless)

	// SkipRenderingCount metrics measures the number of renderings are skipped.
	SkipRenderingCount = stats.Int64(
		"skip_rendering_count",
		"The number of renderings that are skipped",
		stats.UnitDimensionless)

	// ResourceOverrideCount metric measures the number of RootSync/RepoSync objects including the `spec.override.resources` field.
	ResourceOverrideCount = stats.Int64(
		"resource_override_count",
		"The number of RootSync/RepoSync objects including the `spec.override.resources` field",
		stats.UnitDimensionless)

	// GitSyncDepthOverrideCount metric measures the number of RootSync/RepoSync objects including the `spec.override.gitSyncDepth` field.
	GitSyncDepthOverrideCount = stats.Int64(
		"git_sync_depth_override_count",
		"The number of RootSync/RepoSync objects including the `spec.override.gitSyncDepth` field",
		stats.UnitDimensionless)

	// NoSSLVerifyCount metric measures the number of RootSync/RepoSync objects whose `spec.git.noSSLVerify` field is set to `true`.
	NoSSLVerifyCount = stats.Int64(
		"no_ssl_verify_count",
		"The number of RootSync/RepoSync objects whose `spec.git.noSSLVerify` field is set to `true`",
		stats.UnitDimensionless)
)
View Source
var (
	// KeyName groups metrics by the reconciler name. Possible values: root-reconciler, ns-reconciler-<namespace>
	// TODO b/208316928 remove this key from pipeline_error_observed metric once same metric in Resource Group Controller has this tag removed
	KeyName, _ = tag.NewKey("name")

	// KeyReconcilerType groups metrics by the reconciler type. Possible values: root, namespace.
	KeyReconcilerType, _ = tag.NewKey("reconciler")

	// KeyOperation groups metrics by their operation. Possible values: create, patch, update, delete.
	KeyOperation, _ = tag.NewKey("operation")

	// KeyComponent groups metrics by their component. Possible values: parsing, source, sync, rendering, readiness(from Resource Group Controller).
	KeyComponent, _ = tag.NewKey("component")

	// KeyErrorClass groups metrics by their error code.
	KeyErrorClass, _ = tag.NewKey("errorclass")

	// KeyStatus groups metrics by their status. Possible values: success, error.
	KeyStatus, _ = tag.NewKey("status")

	// KeyType groups metrics by their resource GVK.
	KeyType, _ = tag.NewKey("type")

	// KeyInternalErrorSource groups the InternalError metrics by their source. Possible values: parser, differ, remediator.
	KeyInternalErrorSource, _ = tag.NewKey("source")

	// KeyParserSource groups the metrics for the parser by their source. Possible values: read, parse, update.
	KeyParserSource, _ = tag.NewKey("source")

	// KeyTrigger groups metrics by their trigger. Possible values: retry, watchUpdate, managementConflict, resync, reimport.
	KeyTrigger, _ = tag.NewKey("trigger")

	// KeyCommit groups metrics by their git commit. Even though this tag has a high cardinality,
	// it is only used by the `last_sync_timestamp` and `last_apply_timestamp` metrics.
	// These are both aggregated as LastValue metrics so the number of recorded values will always be
	// at most 1 per git commit.
	KeyCommit, _ = tag.NewKey("commit")

	// KeyContainer groups metrics by their container names. Possible values: reconciler, git-sync.
	KeyContainer, _ = tag.NewKey("container")

	// KeyResourceType groups metris by their resource types. Possible values: cpu, memory.
	KeyResourceType, _ = tag.NewKey("resource")
)
View Source
var (
	// APICallDurationView aggregates the APICallDuration metric measurements.
	APICallDurationView = &view.View{
		Name:        APICallDuration.Name(),
		Measure:     APICallDuration,
		Description: "The latency distribution of API server calls",
		TagKeys:     []tag.Key{KeyOperation, KeyStatus},
		Aggregation: view.Distribution(distributionBounds...),
	}

	// ReconcilerErrorsView aggregates the ReconcilerErrors metric measurements.
	ReconcilerErrorsView = &view.View{
		Name:        ReconcilerErrors.Name(),
		Measure:     ReconcilerErrors,
		Description: "The current number of errors in the RootSync and RepoSync reconcilers",
		TagKeys:     []tag.Key{KeyComponent, KeyErrorClass},
		Aggregation: view.LastValue(),
	}

	// PipelineErrorView aggregates the PipelineError metric measurements
	PipelineErrorView = &view.View{
		Name:        PipelineError.Name(),
		Measure:     PipelineError,
		Description: "A boolean indicates if any error happens from different stages when syncing a commit",
		TagKeys:     []tag.Key{KeyName, KeyReconcilerType, KeyComponent},
		Aggregation: view.LastValue(),
	}

	// ReconcileDurationView aggregates the ReconcileDuration metric measurements.
	ReconcileDurationView = &view.View{
		Name:        ReconcileDuration.Name(),
		Measure:     ReconcileDuration,
		Description: "The latency distribution of RootSync and RepoSync reconcile events",
		TagKeys:     []tag.Key{KeyStatus},
		Aggregation: view.Distribution(distributionBounds...),
	}

	// ParserDurationView aggregates the ParserDuration metric measurements.
	ParserDurationView = &view.View{
		Name:        ParserDuration.Name(),
		Measure:     ParserDuration,
		Description: "The latency distribution of the parse-apply-watch loop",
		TagKeys:     []tag.Key{KeyStatus, KeyTrigger, KeyParserSource},
		Aggregation: view.Distribution(distributionBounds...),
	}

	// LastSyncTimestampView aggregates the LastSyncTimestamp metric measurements.
	LastSyncTimestampView = &view.View{
		Name:        LastSync.Name(),
		Measure:     LastSync,
		Description: "The timestamp of the most recent sync from Git",
		Aggregation: view.LastValue(),
	}

	// DeclaredResourcesView aggregates the DeclaredResources metric measurements.
	DeclaredResourcesView = &view.View{
		Name:        DeclaredResources.Name(),
		Measure:     DeclaredResources,
		Description: "The current number of declared resources parsed from Git",
		Aggregation: view.LastValue(),
	}

	// ApplyOperationsView aggregates the ApplyOps metric measurements.
	ApplyOperationsView = &view.View{
		Name:        ApplyOperations.Name() + "_total",
		Measure:     ApplyOperations,
		Description: "The total number of operations that have been performed to sync resources to source of truth",
		TagKeys:     []tag.Key{KeyOperation, KeyStatus},
		Aggregation: view.Count(),
	}

	// ApplyDurationView aggregates the ApplyDuration metric measurements.
	ApplyDurationView = &view.View{
		Name:        ApplyDuration.Name(),
		Measure:     ApplyDuration,
		Description: "The latency distribution of applier resource sync events",
		TagKeys:     []tag.Key{KeyStatus},
		Aggregation: view.Distribution(distributionBounds...),
	}

	// LastApplyTimestampView aggregates the LastApplyTimestamp metric measurements.
	LastApplyTimestampView = &view.View{
		Name:        LastApply.Name(),
		Measure:     LastApply,
		Description: "The timestamp of the most recent applier resource sync event",
		TagKeys:     []tag.Key{KeyStatus, KeyCommit},
		Aggregation: view.LastValue(),
	}

	// ResourceFightsView aggregates the ResourceFights metric measurements.
	ResourceFightsView = &view.View{
		Name:        ResourceFights.Name() + "_total",
		Measure:     ResourceFights,
		Description: "The total number of resources that are being synced too frequently",
		Aggregation: view.Count(),
	}

	// RemediateDurationView aggregates the RemediateDuration metric measurements.
	RemediateDurationView = &view.View{
		Name:        RemediateDuration.Name(),
		Measure:     RemediateDuration,
		Description: "The latency distribution of remediator reconciliation events",
		TagKeys:     []tag.Key{KeyStatus},
		Aggregation: view.Distribution(distributionBounds...),
	}

	// ResourceConflictsView aggregates the ResourceConflicts metric measurements.
	ResourceConflictsView = &view.View{
		Name:        ResourceConflicts.Name() + "_total",
		Measure:     ResourceConflicts,
		Description: "The total number of resource conflicts resulting from a mismatch between the cached resources and cluster resources",
		Aggregation: view.Count(),
	}

	// InternalErrorsView aggregates the InternalErrors metric measurements.
	InternalErrorsView = &view.View{
		Name:        InternalErrors.Name() + "_total",
		Measure:     InternalErrors,
		Description: "The total number of internal errors triggered by Config Sync",
		TagKeys:     []tag.Key{KeyInternalErrorSource},
		Aggregation: view.Count(),
	}

	// RenderingCountView aggregates the RenderingCount metric measurements.
	RenderingCountView = &view.View{
		Name:        RenderingCount.Name() + "_total",
		Measure:     RenderingCount,
		Description: "The total number of renderings that are performed",
		Aggregation: view.Count(),
	}

	// SkipRenderingCountView aggregates the SkipRenderingCount metric measurements.
	SkipRenderingCountView = &view.View{
		Name:        SkipRenderingCount.Name() + "_total",
		Measure:     SkipRenderingCount,
		Description: "The total number of renderings that are skipped",
		Aggregation: view.Count(),
	}

	// ResourceOverrideCountView aggregates the ResourceOverrideCount metric measurements.
	ResourceOverrideCountView = &view.View{
		Name:        ResourceOverrideCount.Name() + "_total",
		Measure:     ResourceOverrideCount,
		Description: "The total number of RootSync/RepoSync objects including the `spec.override.resources` field",
		TagKeys:     []tag.Key{KeyContainer, KeyResourceType},
		Aggregation: view.Count(),
	}

	// GitSyncDepthOverrideCountView aggregates the GitSyncDepthOverrideCount metric measurements.
	GitSyncDepthOverrideCountView = &view.View{
		Name:        GitSyncDepthOverrideCount.Name() + "_total",
		Measure:     GitSyncDepthOverrideCount,
		Description: "The total number of RootSync/RepoSync objects including the `spec.override.gitSyncDepth` field",
		Aggregation: view.Count(),
	}

	// NoSSLVerifyCountView aggregates the NoSSLVerifyCount metric measurements.
	NoSSLVerifyCountView = &view.View{
		Name:        NoSSLVerifyCount.Name() + "_total",
		Measure:     NoSSLVerifyCount,
		Description: "The number of RootSync/RepoSync objects whose `spec.git.noSSLVerify` field is set to `true`",
		Aggregation: view.Count(),
	}
)

Functions

func RecordAPICallDuration

func RecordAPICallDuration(ctx context.Context, operation, status string, gvk schema.GroupVersionKind, startTime time.Time)

RecordAPICallDuration produces a measurement for the APICallDuration view.

func RecordApplyDuration

func RecordApplyDuration(ctx context.Context, status, commit string, startTime time.Time)

RecordApplyDuration produces measurements for the ApplyDuration and LastApplyTimestamp views.

func RecordApplyOperation

func RecordApplyOperation(ctx context.Context, operation, status string, gvk schema.GroupVersionKind)

RecordApplyOperation produces a measurement for the ApplyOperations view.

func RecordDeclaredResources

func RecordDeclaredResources(ctx context.Context, numResources int)

RecordDeclaredResources produces a measurement for the DeclaredResources view.

func RecordGitSyncDepthOverrideCount

func RecordGitSyncDepthOverrideCount(ctx context.Context)

RecordGitSyncDepthOverrideCount produces measurements for the GitSyncDepthOverrideCount view.

func RecordInternalError

func RecordInternalError(ctx context.Context, source string)

RecordInternalError produces measurements for the InternalErrors view.

func RecordLastSync

func RecordLastSync(ctx context.Context, commit string, timestamp time.Time)

RecordLastSync produces a measurement for the LastSync view.

func RecordNoSSLVerifyCount

func RecordNoSSLVerifyCount(ctx context.Context)

RecordNoSSLVerifyCount produces measurements for the NoSSLVerifyCount view.

func RecordParserDuration

func RecordParserDuration(ctx context.Context, trigger, source, status string, startTime time.Time)

RecordParserDuration produces a measurement for the ParserDuration view.

func RecordPipelineError

func RecordPipelineError(ctx context.Context, reconcilerType, component string, errLen int)

RecordPipelineError produces a measurement for the PipelineError view

func RecordReconcileDuration

func RecordReconcileDuration(ctx context.Context, status string, startTime time.Time)

RecordReconcileDuration produces a measurement for the ReconcileDuration view.

func RecordReconcilerErrors

func RecordReconcilerErrors(ctx context.Context, component string, errs []v1beta1.ConfigSyncError)

RecordReconcilerErrors produces a measurement for the ReconcilerErrors view.

func RecordRemediateDuration

func RecordRemediateDuration(ctx context.Context, status string, gvk schema.GroupVersionKind, startTime time.Time)

RecordRemediateDuration produces measurements for the RemediateDuration view.

func RecordRenderingCount

func RecordRenderingCount(ctx context.Context)

RecordRenderingCount produces measurements for the RenderingCount view.

func RecordResourceConflict

func RecordResourceConflict(ctx context.Context, gvk schema.GroupVersionKind)

RecordResourceConflict produces measurements for the ResourceConflicts view.

func RecordResourceFight

func RecordResourceFight(ctx context.Context, operation string, gvk schema.GroupVersionKind)

RecordResourceFight produces measurements for the ResourceFights view.

func RecordResourceOverrideCount

func RecordResourceOverrideCount(ctx context.Context, reconcilerType, containerName, resourceType string)

RecordResourceOverrideCount produces measurements for the ResourceOverrideCount view.

func RecordSkipRenderingCount

func RecordSkipRenderingCount(ctx context.Context)

RecordSkipRenderingCount produces measurements for the SkipRenderingCount view.

func RegisterOCAgentExporter

func RegisterOCAgentExporter() (*ocagent.Exporter, error)

RegisterOCAgentExporter creates the OC Agent metrics exporter.

func RegisterReconcilerManagerMetricsViews

func RegisterReconcilerManagerMetricsViews() error

RegisterReconcilerManagerMetricsViews registers the views so that recorded metrics can be exported in the reconciler manager.

func RegisterReconcilerMetricsViews

func RegisterReconcilerMetricsViews() error

RegisterReconcilerMetricsViews registers the views so that recorded metrics can be exported in the reconcilers.

func StatusTagKey

func StatusTagKey(err error) string

StatusTagKey returns a string representation of the error, if it exists, otherwise success.

Types

This section is empty.

Jump to

Keyboard shortcuts

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