metrics

package
v1.8.3 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2022 License: Apache-2.0 Imports: 33 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ListClient added in v1.8.1

func ListClient[T any](recorder Recorder, inner controllerutils.ListClient[T]) controllerutils.ListClient[T]

func Logger added in v1.7.0

func Logger() logr.Logger

func NewOTLPGRPCConfig added in v1.8.0

func NewOTLPGRPCConfig(
	endpoint string,
	certs string,
	kubeClient kubernetes.Interface,
	log logr.Logger,
) (*controller.Controller, error)

func NewPrometheusConfig added in v1.8.0

func NewPrometheusConfig(
	log logr.Logger,
) (*http.ServeMux, error)

func ObjectClient added in v1.8.1

func ObjectClient[T metav1.Object](recorder Recorder, inner controllerutils.ObjectClient[T],
) controllerutils.ObjectClient[T]

func ShutDownController added in v1.8.0

func ShutDownController(ctx context.Context, pusher *controller.Controller)

func StatusClient added in v1.8.1

func StatusClient[T metav1.Object](recorder Recorder, inner controllerutils.StatusClient[T]) controllerutils.StatusClient[T]

Types

type ClientQueryOperation added in v1.8.0

type ClientQueryOperation string
const (
	ClientCreate           ClientQueryOperation = "create"
	ClientGet              ClientQueryOperation = "get"
	ClientList             ClientQueryOperation = "list"
	ClientUpdate           ClientQueryOperation = "update"
	ClientUpdateStatus     ClientQueryOperation = "update_status"
	ClientDelete           ClientQueryOperation = "delete"
	ClientDeleteCollection ClientQueryOperation = "delete_collection"
	ClientWatch            ClientQueryOperation = "watch"
	ClientPatch            ClientQueryOperation = "patch"
)

type ClientType added in v1.8.0

type ClientType string
const (
	KubeDynamicClient  ClientType = "dynamic"
	KubeClient         ClientType = "kubeclient"
	KyvernoClient      ClientType = "kyverno"
	PolicyReportClient ClientType = "policyreport"
)

type MetricsConfig added in v1.8.0

type MetricsConfig struct {

	// config
	Config *kconfig.MetricsConfigData
	Log    logr.Logger
	// contains filtered or unexported fields
}

func InitMetrics added in v1.8.0

func InitMetrics(
	disableMetricsExport bool,
	otel string,
	metricsAddr string,
	otelCollector string,
	metricsConfigData *config.MetricsConfigData,
	transportCreds string,
	kubeClient kubernetes.Interface,
	log logr.Logger,
) (*MetricsConfig, *http.ServeMux, *controller.Controller, error)

func NewFakeMetricsConfig added in v1.8.0

func NewFakeMetricsConfig(client kubernetes.Interface) *MetricsConfig

func (*MetricsConfig) RecordAdmissionRequests added in v1.8.0

func (m *MetricsConfig) RecordAdmissionRequests(resourceKind string, resourceNamespace string, resourceRequestOperation ResourceRequestOperation)

func (*MetricsConfig) RecordAdmissionReviewDuration added in v1.8.0

func (m *MetricsConfig) RecordAdmissionReviewDuration(resourceKind string, resourceNamespace string, resourceRequestOperation string, admissionRequestLatency float64)

func (*MetricsConfig) RecordClientQueries added in v1.8.0

func (m *MetricsConfig) RecordClientQueries(clientQueryOperation ClientQueryOperation, clientType ClientType, resourceKind string, resourceNamespace string)

func (*MetricsConfig) RecordPolicyChanges added in v1.8.0

func (m *MetricsConfig) RecordPolicyChanges(policyValidationMode PolicyValidationMode, policyType PolicyType, policyBackgroundMode PolicyBackgroundMode, policyNamespace string, policyName string, policyChangeType string)

func (*MetricsConfig) RecordPolicyExecutionDuration added in v1.8.0

func (m *MetricsConfig) RecordPolicyExecutionDuration(policyValidationMode PolicyValidationMode, policyType PolicyType, policyBackgroundMode PolicyBackgroundMode, policyNamespace string, policyName string,
	ruleName string, ruleResult RuleResult, ruleType RuleType, ruleExecutionCause RuleExecutionCause, ruleExecutionLatency float64,
)

func (*MetricsConfig) RecordPolicyResults added in v1.8.0

func (m *MetricsConfig) RecordPolicyResults(policyValidationMode PolicyValidationMode, policyType PolicyType, policyBackgroundMode PolicyBackgroundMode, policyNamespace string, policyName string,
	resourceKind string, resourceNamespace string, resourceRequestOperation ResourceRequestOperation, ruleName string, ruleResult RuleResult, ruleType RuleType,
	ruleExecutionCause RuleExecutionCause,
)

func (*MetricsConfig) RecordPolicyRuleInfo added in v1.8.0

func (m *MetricsConfig) RecordPolicyRuleInfo(policyValidationMode PolicyValidationMode, policyType PolicyType, policyBackgroundMode PolicyBackgroundMode, policyNamespace string, policyName string,
	ruleName string, ruleType RuleType, status string, metricValue float64,
)

type MetricsConfigManager added in v1.8.0

type MetricsConfigManager interface {
	RecordPolicyResults(policyValidationMode PolicyValidationMode, policyType PolicyType, policyBackgroundMode PolicyBackgroundMode, policyNamespace string, policyName string, resourceKind string, resourceNamespace string, resourceRequestOperation ResourceRequestOperation, ruleName string, ruleResult RuleResult, ruleType RuleType, ruleExecutionCause RuleExecutionCause)
	RecordPolicyChanges(policyValidationMode PolicyValidationMode, policyType PolicyType, policyBackgroundMode PolicyBackgroundMode, policyNamespace string, policyName string, policyChangeType string)
	RecordPolicyRuleInfo(policyValidationMode PolicyValidationMode, policyType PolicyType, policyBackgroundMode PolicyBackgroundMode, policyNamespace string, policyName string, ruleName string, ruleType RuleType, status string, metricValue float64)
	RecordAdmissionRequests(resourceKind string, resourceNamespace string, resourceRequestOperation ResourceRequestOperation)
	RecordPolicyExecutionDuration(policyValidationMode PolicyValidationMode, policyType PolicyType, policyBackgroundMode PolicyBackgroundMode, policyNamespace string, policyName string, ruleName string, ruleResult RuleResult, ruleType RuleType, ruleExecutionCause RuleExecutionCause, ruleExecutionLatency float64)
	RecordAdmissionReviewDuration(resourceKind string, resourceNamespace string, resourceRequestOperation string, admissionRequestLatency float64)
	RecordClientQueries(clientQueryOperation ClientQueryOperation, clientType ClientType, resourceKind string, resourceNamespace string)
}

type PolicyBackgroundMode

type PolicyBackgroundMode string
const (
	BackgroundTrue  PolicyBackgroundMode = "true"
	BackgroundFalse PolicyBackgroundMode = "false"
)

func ParsePolicyBackgroundMode

func ParsePolicyBackgroundMode(policy kyvernov1.PolicyInterface) PolicyBackgroundMode

type PolicyType

type PolicyType string
const (
	Cluster    PolicyType = "cluster"
	Namespaced PolicyType = "namespaced"
)

type PolicyValidationMode

type PolicyValidationMode string
const (
	Enforce PolicyValidationMode = "enforce"
	Audit   PolicyValidationMode = "audit"
)

func ParsePolicyValidationMode

func ParsePolicyValidationMode(validationFailureAction kyvernov1.ValidationFailureAction) (PolicyValidationMode, error)

type Recorder added in v1.8.1

type Recorder interface {
	Record(clientQueryOperation ClientQueryOperation)
}

func ClusteredClientQueryRecorder added in v1.8.1

func ClusteredClientQueryRecorder(m MetricsConfigManager, kind string, client ClientType) Recorder

func NamespacedClientQueryRecorder added in v1.8.1

func NamespacedClientQueryRecorder(m MetricsConfigManager, ns, kind string, client ClientType) Recorder

type ResourceRequestOperation

type ResourceRequestOperation string
const (
	ResourceCreated   ResourceRequestOperation = "create"
	ResourceUpdated   ResourceRequestOperation = "update"
	ResourceDeleted   ResourceRequestOperation = "delete"
	ResourceConnected ResourceRequestOperation = "connect"
)

func ParseResourceRequestOperation added in v1.7.0

func ParseResourceRequestOperation(requestOperationStr string) (ResourceRequestOperation, error)

type RuleExecutionCause

type RuleExecutionCause string
const (
	AdmissionRequest RuleExecutionCause = "admission_request"
	BackgroundScan   RuleExecutionCause = "background_scan"
)

type RuleResult

type RuleResult string
const (
	Pass  RuleResult = "pass"
	Fail  RuleResult = "fail"
	Warn  RuleResult = "warn"
	Error RuleResult = "error"
	Skip  RuleResult = "skip"
)

type RuleType

type RuleType string
const (
	Validate      RuleType = "validate"
	Mutate        RuleType = "mutate"
	Generate      RuleType = "generate"
	ImageVerify   RuleType = "imageVerify"
	EmptyRuleType RuleType = "-"
)

func ParseRuleType

func ParseRuleType(rule kyvernov1.Rule) RuleType

func ParseRuleTypeFromEngineRuleResponse added in v1.7.0

func ParseRuleTypeFromEngineRuleResponse(rule response.RuleResponse) RuleType

Jump to

Keyboard shortcuts

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