NIFI-16298 Expose Primary Node and Cluster Coordinator role as Prometheus metrics - #11628
Open
abij wants to merge 1 commit into
Open
NIFI-16298 Expose Primary Node and Cluster Coordinator role as Prometheus metrics#11628abij wants to merge 1 commit into
abij wants to merge 1 commit into
Conversation
Contributor
Author
|
@exceptionfactory I was building Grafana dashboards for NiFi Clusters and noticed 2 issues and 1 improvement. First of all so cool that this long-lived project is still so actively maintained. I have created JIRA-tickets and implementation of 3 separate small PR's (with some help of AI, less honor/pride to gain for myself...). Please have a look and have a nice weekend. |
Contributor
|
Thanks for the contribution @abij - do you mind rebasing your PR as I merged the other one and there are now merge conflicts? |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
NIFI-16298 - Expose Primary Node and Cluster Coordinator role as Prometheus metrics
The Prometheus flow metrics endpoint (
/nifi-api/flow/metrics/prometheus) exposes cluster membership/connectivity metrics (cluster_is_clustered,cluster_is_connected_to_cluster,cluster_connected_node_count,cluster_total_node_count), but nothing indicates which node currently holds the Primary Node or Cluster Coordinator role. Building a per-node cluster-overview dashboard currently has no way to mark those roles without querying NiFi's REST API separately and joining the data out-of-band.The data is already available internally and simply wasn't wired into these metrics:
FlowController.isPrimary()andFlowController.isClusterCoordinator()already exist, following the exact same pattern asFlowController.isClustered(), whichControllerFacade/StandardNiFiServiceFacadealready use for the existing cluster metrics.What this PR does
ControllerFacade#isPrimary()andControllerFacade#isClusterCoordinator(), delegating to the equivalentFlowControllermethods — following the exact pattern of the existingControllerFacade#isClustered()passthrough.ClusterMetricsRegistry, labeledinstanceonly (consistent with the other single-value cluster gauges):cluster_is_primary_nodeandcluster_is_cluster_coordinator.PrometheusMetricsUtil#createClusterMetricsandStandardNiFiServiceFacade#populateFlowMetricsalongside the existing cluster metrics.TestFlowResource's fixture and sample-count assertions for the two new metrics.This lets a dashboard mark the Primary Node and Cluster Coordinator directly from the same Prometheus scrape already used for the rest of the cluster-overview table, without a separate REST API call/join. Also useful for alerting (e.g. "no node in this cluster is reporting as coordinator" indicates a leader-election problem).
Tests
./mvnw -pl nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api -am -P contrib-check clean install— 0 Checkstyle violations, RAT license check passed, 642/642 tests passed, BUILD SUCCESSVerification
Build
./mvnw clean install -P contrib-check(scoped tonifi-framework-bundle/nifi-framework/nifi-web/nifi-web-apiand its dependencies via-pl ... -am; full reactor build not run locally, deferred to CI) — 0 Checkstyle violations, RAT license check passed, 642/642 tests passed, BUILD SUCCESSmaven.compiler.releasetargets 21Licensing
Documentation