use of org.onosproject.kubevirtnetworking.api.Constants.PRIORITY_STATEFUL_SNAT_RULE in project onos by opennetworkinglab.
the class KubevirtPrometheusAssuranceManager method publishSnatMetrics.
private void publishSnatMetrics() {
if (prometheusExporter == null) {
log.error("Prometheus Server isn't ready.");
return;
}
String[] snatLabelValues = new String[3];
routerService.routers().stream().filter(router -> router.enableSnat() && router.electedGateway() != null && router.peerRouter() != null && router.peerRouter().ipAddress() != null && router.peerRouter().macAddress() != null).forEach(router -> {
KubevirtNode gateway = nodeService.node(router.electedGateway());
if (gateway == null) {
return;
}
String routerSnatIp = router.external().keySet().stream().findAny().orElse(null);
if (routerSnatIp == null) {
return;
}
flowRuleService.getFlowEntries(gateway.intgBridge()).forEach(flowEntry -> {
if (((IndexTableId) flowEntry.table()).id() == GW_ENTRY_TABLE && flowEntry.priority() == PRIORITY_STATEFUL_SNAT_RULE) {
snatLabelValues[0] = router.name();
snatLabelValues[1] = routerSnatIp;
snatLabelValues[2] = gateway.hostname();
if (isSnatUpstreamFlorEntryForRouter(router, flowEntry)) {
pktSNATTx.labels(snatLabelValues).set(flowEntry.packets());
byteSNATTx.labels(snatLabelValues).set(flowEntry.bytes());
} else if (isSnatDownstreamFlorEntryForRouter(routerSnatIp, flowEntry)) {
pktSNATRx.labels(snatLabelValues).set(flowEntry.packets());
byteSNATRx.labels(snatLabelValues).set(flowEntry.bytes());
}
}
});
});
}
Aggregations