github.com/cilium/cilium@v1.16.2/pkg/clustermesh/common/metrics.go (about) 1 // SPDX-License-Identifier: Apache-2.0 2 // Copyright Authors of Cilium 3 4 package common 5 6 import ( 7 "github.com/cilium/cilium/pkg/metrics" 8 "github.com/cilium/cilium/pkg/metrics/metric" 9 ) 10 11 type Metrics struct { 12 // TotalRemoteClusters tracks the total number of remote clusters. 13 TotalRemoteClusters metric.Vec[metric.Gauge] 14 // LastFailureTimestamp tracks the last failure timestamp. 15 LastFailureTimestamp metric.Vec[metric.Gauge] 16 // ReadinessStatus tracks the readiness status of remote clusters. 17 ReadinessStatus metric.Vec[metric.Gauge] 18 // TotalFailure tracks the number of failures when connecting to remote clusters. 19 TotalFailures metric.Vec[metric.Gauge] 20 } 21 22 func MetricsProvider(subsystem string) func() Metrics { 23 return func() Metrics { 24 return Metrics{ 25 TotalRemoteClusters: metric.NewGaugeVec(metric.GaugeOpts{ 26 Namespace: metrics.Namespace, 27 Subsystem: subsystem, 28 Name: "remote_clusters", 29 Help: "The total number of remote clusters meshed with the local cluster", 30 }, []string{metrics.LabelSourceCluster, metrics.LabelSourceNodeName}), 31 32 LastFailureTimestamp: metric.NewGaugeVec(metric.GaugeOpts{ 33 Namespace: metrics.Namespace, 34 Subsystem: subsystem, 35 Name: "remote_cluster_last_failure_ts", 36 Help: "The timestamp of the last failure of the remote cluster", 37 }, []string{metrics.LabelSourceCluster, metrics.LabelSourceNodeName, metrics.LabelTargetCluster}), 38 39 ReadinessStatus: metric.NewGaugeVec(metric.GaugeOpts{ 40 Namespace: metrics.Namespace, 41 Subsystem: subsystem, 42 Name: "remote_cluster_readiness_status", 43 Help: "The readiness status of the remote cluster", 44 }, []string{metrics.LabelSourceCluster, metrics.LabelSourceNodeName, metrics.LabelTargetCluster}), 45 46 TotalFailures: metric.NewGaugeVec(metric.GaugeOpts{ 47 Namespace: metrics.Namespace, 48 Subsystem: subsystem, 49 Name: "remote_cluster_failures", 50 Help: "The total number of failures related to the remote cluster", 51 }, []string{metrics.LabelSourceCluster, metrics.LabelSourceNodeName, metrics.LabelTargetCluster}), 52 } 53 } 54 }