metrics

package
v0.0.0-...-4efcaec Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// NsReconcilerPrefix is the prefix used for all Namespace reconcilers.
	NsReconcilerPrefix = "ns-reconciler"
	// RootReconcilerPrefix is the prefix usef for all Root reconcilers.
	RootReconcilerPrefix = "root-reconciler"
	// RepoSyncName is the expected name of any RepoSync CR.
	RepoSyncName = "repo-sync"
	// RootSyncName is the expected name of any RootSync CR.
	RootSyncName = "root-sync"

	//nolint:gosec // ignore the false-positive alert for G101: Potential hardcoded credentials
	// CMSNamespace is the name of the Config Sync controller's namespace
	CMSNamespace = "config-management-system"
)

Variables

View Source
var (
	// ReconcileDuration tracks the time duration in seconds of reconciling
	// a ResourceGroup CR by the ResourceGroup controller.
	// label `reason`: the `Reason` field of the `Stalled` condition in a ResourceGroup CR.
	// reason can be: StartReconciling, FinishReconciling, ComponentFailed, ExceedTimeout.
	// This metric should be updated in the ResourceGroup controller.
	ReconcileDuration = stats.Float64(
		"rg_reconcile_duration_seconds",
		"Time duration in seconds of reconciling a ResourceGroup CR by the ResourceGroup controller",
		stats.UnitSeconds)

	// ResourceGroupTotal tracks the total number of ResourceGroup CRs in a cluster.
	// This metric should be updated in the Root controller.
	ResourceGroupTotal = stats.Int64(
		"resource_group_total",
		"Total number of ResourceGroup CRs in a cluster",
		stats.UnitDimensionless)

	// ResourceCount tracks the number of resources in a ResourceGroup CR.
	// This metric should be updated in the Root controller.
	ResourceCount = stats.Int64(
		"resource_count",
		"The number of resources in a ResourceGroup CR",
		stats.UnitDimensionless)

	// ReadyResourceCount tracks the number of resources with Current status in a ResourceGroup CR.
	// This metric should be updated in the ResourceGroup controller.
	ReadyResourceCount = stats.Int64(
		"ready_resource_count",
		"The number of resources with Current status in a ResourceGroup CR",
		stats.UnitDimensionless)

	// KCCResourceCount tracks the number of KCC resources in a ResourceGroup CR.
	// This metric should be updated in the ResourceGroup controller.
	KCCResourceCount = stats.Int64(
		"kcc_resource_count",
		"The number of KCC resources in a ResourceGroup CR",
		stats.UnitDimensionless)

	// NamespaceCount tracks the number of resource namespaces in a ResourceGroup CR.
	// This metric should be updated in the Root controller.
	NamespaceCount = stats.Int64(
		"resource_ns_count",
		"The number of resource namespaces in a ResourceGroup CR",
		stats.UnitDimensionless)

	// ClusterScopedResourceCount tracks the number of cluster-scoped resources in a ResourceGroup CR.
	// This metric should be updated in the Root controller.
	ClusterScopedResourceCount = stats.Int64(
		"cluster_scoped_resource_count",
		"The number of cluster-scoped resources in a ResourceGroup CR",
		stats.UnitDimensionless)

	// CRDCount tracks the number of CRDs in a ResourceGroup CR.
	// This metric should be updated in the Root controller.
	CRDCount = stats.Int64(
		"crd_count",
		"The number of CRDs in a ResourceGroup CR",
		stats.UnitDimensionless)

	// PipelineError tracks the error that happened when syncing a commit
	PipelineError = stats.Int64(
		"pipeline_error_observed",
		"A boolean value indicates if error happened at readiness stage when syncing a commit",
		stats.UnitDimensionless)
)
View Source
var (
	// KeyStallReason groups metrics by the stall condition reason field
	KeyStallReason, _ = tag.NewKey("stallreason")

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

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

	// KeyType groups metrics by their resource reconciler type. Possible values: root-sync, repo-sync
	KeyType, _ = tag.NewKey("reconciler")

	// KeyResourceGroup groups metrics by their resource group
	KeyResourceGroup, _ = tag.NewKey("resourcegroup")

	// KeyName groups metrics by their name of reconciler.
	KeyName, _ = tag.NewKey("name")

	// KeyComponent groups metrics by their component. Possible value: readiness
	KeyComponent, _ = tag.NewKey("component")

	// ResourceKeyDeploymentName groups metrics by k8s deployment name.
	// This metric tag is populated from the k8s.deployment.name resource
	// attribute for Prometheus using the resource_to_telemetry_conversion feature.
	ResourceKeyDeploymentName, _ = tag.NewKey("k8s_deployment_name")
)
View Source
var (
	// ReconcileDurationView aggregates the ReconcileDuration metric measurements.
	ReconcileDurationView = &view.View{
		Name:        ReconcileDuration.Name(),
		Measure:     ReconcileDuration,
		Description: "The distribution of time taken to reconcile a ResourceGroup CR",
		TagKeys:     []tag.Key{KeyStallReason},
		Aggregation: view.Distribution(0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10),
	}

	// ResourceGroupTotalView aggregates the ResourceGroupTotal metric measurements.
	ResourceGroupTotalView = &view.View{
		Name:        ResourceGroupTotal.Name(),
		Measure:     ResourceGroupTotal,
		Description: "The current number of ResourceGroup CRs",
		Aggregation: view.LastValue(),
	}

	// ResourceCountView aggregates the ResourceCount metric measurements.
	ResourceCountView = &view.View{
		Name:        ResourceCount.Name(),
		Measure:     ResourceCount,
		Description: "The total number of resources tracked by a ResourceGroup",
		TagKeys:     []tag.Key{KeyResourceGroup},
		Aggregation: view.LastValue(),
	}

	// ReadyResourceCountView aggregates the resources ready in a ResourceGroup
	ReadyResourceCountView = &view.View{
		Name:        ReadyResourceCount.Name(),
		Measure:     ReadyResourceCount,
		Description: "The total number of ready resources in a ResourceGroup",
		TagKeys:     []tag.Key{KeyResourceGroup},
		Aggregation: view.LastValue(),
	}

	// NamespaceCountView counts number of namespaces in a ResourceGroup
	NamespaceCountView = &view.View{
		Name:        NamespaceCount.Name(),
		Measure:     NamespaceCount,
		Description: "The number of namespaces used by resources in a ResourceGroup",
		TagKeys:     []tag.Key{KeyResourceGroup},
		Aggregation: view.LastValue(),
	}

	// ClusterScopedResourceCountView counts number of namespaces in a ResourceGroup
	ClusterScopedResourceCountView = &view.View{
		Name:        ClusterScopedResourceCount.Name(),
		Measure:     ClusterScopedResourceCount,
		Description: "The number of cluster scoped resources in a ResourceGroup",
		TagKeys:     []tag.Key{KeyResourceGroup},
		Aggregation: view.LastValue(),
	}

	// CRDCountView counts number of namespaces in a ResourceGroup
	CRDCountView = &view.View{
		Name:        CRDCount.Name(),
		Measure:     CRDCount,
		Description: "The number of CRDs in a ResourceGroup",
		TagKeys:     []tag.Key{KeyResourceGroup},
		Aggregation: view.LastValue(),
	}

	// KCCResourceCountView aggregates the KCC resources in a ResourceGroup
	KCCResourceCountView = &view.View{
		Name:        KCCResourceCount.Name(),
		Measure:     KCCResourceCount,
		Description: "The total number of KCC resources in a ResourceGroup",
		TagKeys:     []tag.Key{KeyResourceGroup},
		Aggregation: view.LastValue(),
	}

	// PipelineErrorView aggregates the PipelineError by components
	// TODO: add link to same metric in Config Sync under pkg/metrics/views.go
	PipelineErrorView = &view.View{
		Name:        PipelineError.Name(),
		Measure:     PipelineError,
		Description: "A boolean value indicates if error happened from different stages when syncing a commit",
		TagKeys:     []tag.Key{KeyName, KeyComponent, KeyType},
		Aggregation: view.LastValue(),
	}
)

Functions

func ComputeReconcilerNameType

func ComputeReconcilerNameType(nn types.NamespacedName) (reconcilerName, reconcilerType string)

ComputeReconcilerNameType computes the reconciler name from the ResourceGroup CR name

func RecordCRDCount

func RecordCRDCount(ctx context.Context, nn types.NamespacedName, count int64)

RecordCRDCount produces a measurement for RecordCRDCount view

func RecordClusterScopedResourceCount

func RecordClusterScopedResourceCount(ctx context.Context, nn types.NamespacedName, count int64)

RecordClusterScopedResourceCount produces a measurement for ClusterScopedResourceCount view

func RecordKCCResourceCount

func RecordKCCResourceCount(ctx context.Context, nn types.NamespacedName, count int64)

RecordKCCResourceCount produces a measurement for the KCCResourceCount view.

func RecordNamespaceCount

func RecordNamespaceCount(ctx context.Context, nn types.NamespacedName, count int64)

RecordNamespaceCount produces a measurement for the NamespaceCount view.

func RecordPipelineError

func RecordPipelineError(ctx context.Context, nn types.NamespacedName, component string, hasErr bool)

RecordPipelineError produces a measurement for PipelineErrorView

func RecordReadyResourceCount

func RecordReadyResourceCount(ctx context.Context, nn types.NamespacedName, count int64)

RecordReadyResourceCount produces a measurement for the ReadyResourceCount view.

func RecordReconcileDuration

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

RecordReconcileDuration produces a measurement for the ReconcileDuration view.

func RecordResourceCount

func RecordResourceCount(ctx context.Context, nn types.NamespacedName, count int64)

RecordResourceCount produces a measurement for the ResourceCount view.

func RecordResourceGroupTotal

func RecordResourceGroupTotal(ctx context.Context, count int64)

RecordResourceGroupTotal produces a measurement for the ResourceGroupTotalView

func RegisterOCAgentExporter

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

RegisterOCAgentExporter creates the OC Agent metrics exporter.

func RegisterReconcilerMetricsViews

func RegisterReconcilerMetricsViews() error

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

Types

This section is empty.

Jump to

Keyboard shortcuts

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