This is an automated email from the ASF dual-hosted git repository.
pvillard31 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/nifi.git
The following commit(s) were added to refs/heads/main by this push:
new 9823a25ea73 NIFI-16296 Remove connected_nodes label from
cluster_connected_node_count to prevent stale Prometheus series (#11623)
9823a25ea73 is described below
commit 9823a25ea73da9de880616e3ed156915229766a6
Author: Alexander <[email protected]>
AuthorDate: Sat Sep 5 17:29:18 2026 +0200
NIFI-16296 Remove connected_nodes label from cluster_connected_node_count
to prevent stale Prometheus series (#11623)
---
.../java/org/apache/nifi/prometheusutil/ClusterMetricsRegistry.java | 2 +-
.../java/org/apache/nifi/prometheusutil/PrometheusMetricsUtil.java | 4 ++--
.../src/main/java/org/apache/nifi/web/StandardNiFiServiceFacade.java | 5 +----
.../src/test/java/org/apache/nifi/web/api/TestFlowResource.java | 2 +-
4 files changed, 5 insertions(+), 8 deletions(-)
diff --git
a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/prometheusutil/ClusterMetricsRegistry.java
b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/prometheusutil/ClusterMetricsRegistry.java
index fe778c1f409..462b2328812 100644
---
a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/prometheusutil/ClusterMetricsRegistry.java
+++
b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/prometheusutil/ClusterMetricsRegistry.java
@@ -40,7 +40,7 @@ public class ClusterMetricsRegistry extends
AbstractMetricsRegistry {
nameToGaugeMap.put("CONNECTED_NODE_COUNT", Gauge.build()
.name("cluster_connected_node_count")
.help("The number of connected nodes in this cluster")
- .labelNames("instance", "connected_nodes")
+ .labelNames("instance")
.register(registry));
nameToGaugeMap.put("TOTAL_NODE_COUNT", Gauge.build()
diff --git
a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/prometheusutil/PrometheusMetricsUtil.java
b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/prometheusutil/PrometheusMetricsUtil.java
index c9eaa86a3f3..60c7d4d223a 100644
---
a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/prometheusutil/PrometheusMetricsUtil.java
+++
b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/prometheusutil/PrometheusMetricsUtil.java
@@ -500,11 +500,11 @@ public class PrometheusMetricsUtil {
}
public static CollectorRegistry createClusterMetrics(final
ClusterMetricsRegistry clusterMetricsRegistry, final String instId, final
boolean isClustered, final boolean isConnectedToCluster,
- final String
connectedNodes, final int connectedNodeCount, final int totalNodeCount) {
+ final int
connectedNodeCount, final int totalNodeCount) {
final String instanceId = StringUtils.isEmpty(instId) ?
DEFAULT_LABEL_STRING : instId;
clusterMetricsRegistry.setDataPoint(isClustered ? 1 : 0,
"IS_CLUSTERED", instanceId);
clusterMetricsRegistry.setDataPoint(isConnectedToCluster ? 1 : 0,
"IS_CONNECTED_TO_CLUSTER", instanceId);
- clusterMetricsRegistry.setDataPoint(connectedNodeCount,
"CONNECTED_NODE_COUNT", instanceId, connectedNodes);
+ clusterMetricsRegistry.setDataPoint(connectedNodeCount,
"CONNECTED_NODE_COUNT", instanceId);
clusterMetricsRegistry.setDataPoint(totalNodeCount,
"TOTAL_NODE_COUNT", instanceId);
return clusterMetricsRegistry.getRegistry();
diff --git
a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiServiceFacade.java
b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiServiceFacade.java
index 4b9e9b2ffac..fd9d4a26d1a 100644
---
a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiServiceFacade.java
+++
b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiServiceFacade.java
@@ -8158,7 +8158,6 @@ public class StandardNiFiServiceFacade implements
NiFiServiceFacade {
// Collect cluster summary metrics
int connectedNodeCount = 0;
int totalNodeCount = 0;
- String connectedNodesLabel = "Not clustered";
if (clusterCoordinator != null && clusterCoordinator.isConnected()) {
final Map<NodeConnectionState, List<NodeIdentifier>> stateMap =
clusterCoordinator.getConnectionStates();
for (final List<NodeIdentifier> nodeList : stateMap.values()) {
@@ -8166,12 +8165,10 @@ public class StandardNiFiServiceFacade implements
NiFiServiceFacade {
}
final List<NodeIdentifier> connectedNodeIds =
stateMap.get(NodeConnectionState.CONNECTED);
connectedNodeCount = (connectedNodeIds == null) ? 0 :
connectedNodeIds.size();
-
- connectedNodesLabel = connectedNodeCount + " / " + totalNodeCount;
}
final boolean isClustered = clusterCoordinator != null;
final boolean isConnectedToCluster = isClustered() &&
clusterCoordinator.isConnected();
- PrometheusMetricsUtil.createClusterMetrics(clusterMetricsRegistry,
instanceId, isClustered, isConnectedToCluster, connectedNodesLabel,
connectedNodeCount, totalNodeCount);
+ PrometheusMetricsUtil.createClusterMetrics(clusterMetricsRegistry,
instanceId, isClustered, isConnectedToCluster, connectedNodeCount,
totalNodeCount);
Collection<AbstractMetricsRegistry> metricsRegistries = Arrays.asList(
nifiMetricsRegistry,
jvmMetricsRegistry,
diff --git
a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/java/org/apache/nifi/web/api/TestFlowResource.java
b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/java/org/apache/nifi/web/api/TestFlowResource.java
index b377bd2998e..8356406c31a 100644
---
a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/java/org/apache/nifi/web/api/TestFlowResource.java
+++
b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/java/org/apache/nifi/web/api/TestFlowResource.java
@@ -834,7 +834,7 @@ public class TestFlowResource {
clusterMetricsRegistry.setDataPoint(1, "IS_CLUSTERED", "B1Id");
clusterMetricsRegistry.setDataPoint(1, "IS_CONNECTED_TO_CLUSTER",
"B1Id");
- clusterMetricsRegistry.setDataPoint(2, "CONNECTED_NODE_COUNT", "B1Id",
"2 / 3");
+ clusterMetricsRegistry.setDataPoint(2, "CONNECTED_NODE_COUNT", "B1Id");
clusterMetricsRegistry.setDataPoint(3, "TOTAL_NODE_COUNT", "B1Id");
return clusterMetricsRegistry.getRegistry();