Add a new metric for telemetry usage
@@ -84,6 +84,16 @@ var (
connectionsStatusLabel,
},
)
+ shortConnectionsGauge = prometheus.NewGaugeVec(
+ prometheus.GaugeOpts{
+ Name: "submariner_connections_short",
+ Help: "Summary of connections and corresponding status without cable information",
+ },
+ []string{
+ cableDriverLabel,
+ connectionsStatusLabel,
+ },
+ )
connectionEstablishedTimestampGauge = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Name: "submariner_connection_established_timestamp",
@@ -117,7 +127,8 @@ var (
)
func init() {
- prometheus.MustRegister(rxGauge, txGauge, connectionsGauge, connectionEstablishedTimestampGauge, connectionLatencySecondsGauge)
+ prometheus.MustRegister(rxGauge, txGauge, connectionsGauge, shortConnectionsGauge, connectionEstablishedTimestampGauge,
+ connectionLatencySecondsGauge)
}
func getLabels(cableDriverName string, localEndpoint, remoteEndpoint *submv1.EndpointSpec) prometheus.Labels {
@@ -132,6 +143,12 @@ func getLabels(cableDriverName string, localEndpoint, remoteEndpoint *submv1.End
}
}
+func getShortLabels(cableDriverName string) prometheus.Labels {
+ return prometheus.Labels{
+ cableDriverLabel: cableDriverName,
+ }
+}
+
func RecordRxBytes(cableDriverName string, localEndpoint, remoteEndpoint *submv1.EndpointSpec, bytes int) {
rxGauge.With(getLabels(cableDriverName, localEndpoint, remoteEndpoint)).Set(float64(bytes))
}
@@ -153,20 +170,27 @@ func RecordConnection(cableDriverName string, localEndpoint, remoteEndpoint *sub
labels[connectionsStatusLabel] = status
connectionsGauge.With(labels).Set(1)
+
+ shortLabels := getShortLabels(cableDriverName)
+ shortLabels[connectionsStatusLabel] = status
+ shortConnectionsGauge.With(shortLabels).Set(1)
}
func RecordDisconnected(cableDriverName string, localEndpoint, remoteEndpoint *submv1.EndpointSpec) {
labels := getLabels(cableDriverName, localEndpoint, remoteEndpoint)
+ shortLabels := getShortLabels(cableDriverName)
connectionLatencySecondsGauge.Delete(labels)
connectionEstablishedTimestampGauge.Delete(labels)
rxGauge.Delete(labels)
txGauge.Delete(labels)
connectionsGauge.Delete(labels)
+ shortConnectionsGauge.Delete(shortLabels)
}
func RecordNoConnections() {
// TODO: assuming only 1 cable driver is active at a time, calling Reset() will work.
// once this is changed, there is a need to be updated accordingly
connectionsGauge.Reset()
+ shortConnectionsGauge.Reset()
}
