github.com/cilium/cilium@v1.16.2/operator/identitygc/metrics.go (about) 1 // SPDX-License-Identifier: Apache-2.0 2 // Copyright Authors of Cilium 3 4 package identitygc 5 6 import ( 7 "github.com/cilium/cilium/pkg/metrics" 8 "github.com/cilium/cilium/pkg/metrics/metric" 9 ) 10 11 const ( 12 // LabelStatus marks the status of a resource or completed task 13 LabelStatus = "status" 14 15 // LabelOutcome indicates whether the outcome of the operation was successful or not 16 LabelOutcome = "outcome" 17 18 // Label values 19 20 // LabelValueOutcomeSuccess is used as a successful outcome of an operation 21 LabelValueOutcomeSuccess = "success" 22 23 // LabelValueOutcomeFail is used as an unsuccessful outcome of an operation 24 LabelValueOutcomeFail = "fail" 25 26 // LabelValueOutcomeAlive is used as outcome of alive identity entries 27 LabelValueOutcomeAlive = "alive" 28 29 // LabelValueOutcomeDeleted is used as outcome of deleted identity entries 30 LabelValueOutcomeDeleted = "deleted" 31 ) 32 33 func NewMetrics() *Metrics { 34 return &Metrics{ 35 IdentityGCSize: metric.NewGaugeVec(metric.GaugeOpts{ 36 Namespace: metrics.CiliumOperatorNamespace, 37 Name: "identity_gc_entries", 38 Help: "The number of alive and deleted identities at the end of a garbage collector run", 39 }, []string{LabelStatus}), 40 41 IdentityGCRuns: metric.NewGaugeVec(metric.GaugeOpts{ 42 Namespace: metrics.CiliumOperatorNamespace, 43 Name: "identity_gc_runs", 44 Help: "The number of times identity garbage collector has run", 45 }, []string{LabelOutcome}), 46 } 47 } 48 49 type Metrics struct { 50 // IdentityGCSize records the identity GC results 51 IdentityGCSize metric.Vec[metric.Gauge] 52 53 // IdentityGCRuns records how many times identity GC has run 54 IdentityGCRuns metric.Vec[metric.Gauge] 55 }