-
Notifications
You must be signed in to change notification settings - Fork 228
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This commit adds a telemetry for the ipsec mode. The telemetry created is a Gauge named "cluster_network_ipsec_state" with a constant value of 1 and 2 labels: 1. "mode" which lists the ipsec mode, one of "Disabled" "External" or "Full" 2. "apiFlavor" which states the flavor of the API used - either "4.14" or "4.15" Signed-off-by: Josh Salomon <41079547+JoshSalomon@users.noreply.github.com>
- Loading branch information
1 parent
7f981bf
commit 11ef6ae
Showing
2 changed files
with
147 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
package ipsec | ||
|
||
import ( | ||
"sync" | ||
|
||
// "github.com/openshift/cluster-network-operator/pkg/cmd/checkendpoints/trace" | ||
"k8s.io/component-base/metrics" | ||
"k8s.io/component-base/metrics/legacyregistry" | ||
// "github.com/prometheus/client_golang/prometheus" | ||
operv1 "github.com/openshift/api/operator/v1" | ||
"k8s.io/klog/v2" | ||
|
||
) | ||
|
||
var ( | ||
registerMetrics sync.Once | ||
|
||
// endpointCheckCounter *metrics.CounterVec | ||
ipsecStateGauge *metrics.GaugeVec | ||
) | ||
|
||
// RegisterIpsecMetrics in the global registry | ||
func RegisterIpsecMetrics() { | ||
registerMetrics.Do(func() { | ||
ipsecStateGauge = metrics.NewGaugeVec(&metrics.GaugeOpts{ | ||
Name: "cluster_network_ipsec_state", | ||
Help: "A metric with a constant '1' value labeled by the latest ipsecMode of the cluster", | ||
}, []string{"mode", "apiFlavor"}) | ||
legacyregistry.MustRegister(ipsecStateGauge) | ||
}) | ||
} | ||
|
||
// type IpsecTelemetryCContext interface { | ||
// Update(ipsecConfig *operv1.IPsecConfig) | ||
// } | ||
|
||
// type ipsecTelemetryContext struct { | ||
|
||
// } | ||
|
||
func UpdateIpsecTelemetry(ipsecConfig *operv1.IPsecConfig) { | ||
var flavor, mode string | ||
klog.Infof("IPsec Telemetry: %v", ipsecConfig) | ||
RegisterIpsecMetrics() | ||
if ipsecConfig == nil { | ||
mode = "Disabled" | ||
flavor = "4.14" | ||
} else if ipsecConfig.Mode == "" { | ||
mode = "Full" | ||
flavor = "4.14" | ||
} else { | ||
mode = string(ipsecConfig.Mode) | ||
flavor = "4.15" | ||
} | ||
klog.Infof("IPsec Telemetry: (%s, %s), writing to %v", mode, flavor, ipsecStateGauge) | ||
ipsecStateGauge.WithLabelValues(mode, flavor).Set(1) | ||
} | ||
// func SetIPsecMode(newMode operv1.IPsecMode) { | ||
// buildInfo := prometheus.NewGaugeVec( | ||
// prometheus.GaugeOpts{ | ||
// Name: "cluster_network_ipsec_mode", | ||
// Help: "A metric with a constant '1' value labeled by the latest ipsecMode of the cluster", | ||
// }, | ||
// []string{"ipsecMode"}, | ||
// ) | ||
// buildInfo.WithLabelValues(string(newMode)).Set(1) | ||
|
||
// prometheus.MustRegister(buildInfo) | ||
// } | ||
/***** | ||
package network | ||
import ( | ||
"github.com/prometheus/client_golang/prometheus" | ||
operv1 "github.com/openshift/api/operator/v1" | ||
) | ||
func SetIPsecMode(newMode operv1.IPsecMode) { | ||
buildInfo := prometheus.NewGaugeVec( | ||
prometheus.GaugeOpts{ | ||
Name: "cluster_network_ipsec_mode", | ||
Help: "A metric with a constant '1' value labeled by the latest ipsecMode of the cluster", | ||
}, | ||
[]string{"ipsecMode"}, | ||
) | ||
buildInfo.WithLabelValues(string(newMode)).Set(1) | ||
prometheus.MustRegister(buildInfo) | ||
} | ||
{__name__="up"} or | ||
{__name__="cluster_version"} or | ||
{__name__="cluster_version_available_updates"} or | ||
{__name__="cluster_operator_up"} or | ||
{__name__="cluster_operator_conditions"} or | ||
{__name__="cluster_version_payload"} or | ||
{__name__="cluster_version_payload_errors"} or | ||
{__name__="instance:etcd_object_counts:sum"} or | ||
{__name__="ALERTS",alertstate="firing"} or | ||
{__name__="code:apiserver_request_count:rate:sum"} or | ||
{__name__="kube_pod_status_ready:etcd:sum"} or | ||
{__name__="kube_pod_status_ready:image_registry:sum"} or | ||
{__name__="cluster:capacity_cpu_cores:sum"} or | ||
{__name__="cluster:capacity_memory_bytes:sum"} or | ||
{__name__="cluster:cpu_usage_cores:sum"} or | ||
{__name__="cluster:memory_usage_bytes:sum"} or | ||
{__name__="openshift:cpu_usage_cores:sum"} or | ||
{__name__="openshift:memory_usage_bytes:sum"} or | ||
{__name__="cluster:node_instance_type_count:sum"} | ||
*****/ |