Multicluster dashboard for traffic metrics
This change adds labels to endpoints that target remote services. It also adds a Grafana dashboard that can be used to monitor multicluster traffic.
@@ -19,6 +19,15 @@ import (
const (
kubeSystem = "kube-system"
podIPIndex = "ip"
+
+ // metrics labels
+ service = "service"
+ namespace = "namespace"
+ remoteGatewayNamespace = "remote_gateway_namespace"
+ remoteGateway = "remote_gateway"
+ remoteCluster = "remote_cluster"
+ remoteService = "remote_service"
+ remoteServiceNamespace = "remote_service_namespace"
)
// TODO: prom metrics for all the queues/caches
@@ -450,6 +459,30 @@ func (pp *portPublisher) updateEndpoints(endpoints *corev1.Endpoints) {
pp.metrics.setExists(true)
}
+func metricLabels(endpoints *corev1.Endpoints) map[string]string {
+ labels := map[string]string{service: endpoints.Name, namespace: endpoints.Namespace}
+
+ gateway, hasRemoteGateway := endpoints.Labels[consts.RemoteGatewayNameLabel]
+ gatewayNs, hasRemoteGatwayNs := endpoints.Labels[consts.RemoteGatewayNsLabel]
+ remoteClusterName, hasRemoteClusterName := endpoints.Labels[consts.RemoteClusterNameLabel]
+ serviceFqn, hasServiceFqn := endpoints.Annotations[consts.RemoteServiceFqName]
+
+ if hasRemoteGateway && hasRemoteGatwayNs && hasRemoteClusterName && hasServiceFqn {
+ // this means we are looking at Endpoints created for the purpose of mirroring
+ // an out of cluster service.
+ labels[remoteGatewayNamespace] = gatewayNs
+ labels[remoteGateway] = gateway
+ labels[remoteCluster] = remoteClusterName
+
+ fqParts := strings.Split(serviceFqn, ".")
+ if len(fqParts) >= 2 {
+ labels[remoteService] = fqParts[0]
+ labels[remoteServiceNamespace] = fqParts[1]
+ }
+ }
+ return labels
+}
+
func (pp *portPublisher) endpointsToAddresses(endpoints *corev1.Endpoints) AddressSet {
addresses := make(map[ID]Address)
for _, subset := range endpoints.Subsets {
@@ -504,7 +537,7 @@ func (pp *portPublisher) endpointsToAddresses(endpoints *corev1.Endpoints) Addre
}
return AddressSet{
Addresses: addresses,
- Labels: map[string]string{"service": endpoints.Name, "namespace": endpoints.Namespace},
+ Labels: metricLabels(endpoints),
}
}
