This is an automated email from the ASF dual-hosted git repository.
exceptionfactory 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 c13d101482 NIFI-14590 Fixed Prometheus Performance Metrics to Report
Duration in Milliseconds (#9965)
c13d101482 is described below
commit c13d10148291ebfd818e118417954607433d2605
Author: Eric Secules <[email protected]>
AuthorDate: Mon May 26 11:19:10 2025 -0700
NIFI-14590 Fixed Prometheus Performance Metrics to Report Duration in
Milliseconds (#9965)
Signed-off-by: David Handermann <[email protected]>
---
.../apache/nifi/prometheusutil/PrometheusMetricsUtil.java | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
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 b3756b6720..c3b40517d5 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
@@ -45,6 +45,7 @@ public class PrometheusMetricsUtil {
protected static final String DEFAULT_LABEL_STRING = "";
private static final double MAXIMUM_BACKPRESSURE = 1.0;
private static final double UNDEFINED_BACKPRESSURE = -1.0;
+ private static final double NANOS_PER_MILLI = 1000000.0;
public static CollectorRegistry createNifiMetrics(NiFiMetricsRegistry
nifiMetricsRegistry, ProcessGroupStatus status,
String instId, String
parentProcessGroupId, String compType, String metricsStrategy) {
@@ -84,7 +85,8 @@ public class PrometheusMetricsUtil {
addProcessingPerformanceMetrics(nifiMetricsRegistry,
status.getProcessingPerformanceStatus(),
instanceId, componentType, componentName, componentId,
parentPGId);
- nifiMetricsRegistry.setDataPoint(status.getProcessingNanos(),
"TOTAL_TASK_DURATION",
+ // prometheus metric expects milliseconds
+ nifiMetricsRegistry.setDataPoint(status.getProcessingNanos() /
NANOS_PER_MILLI, "TOTAL_TASK_DURATION",
instanceId, componentType, componentName, componentId,
parentPGId);
// Report metrics for child process groups if specified
@@ -522,20 +524,20 @@ public class PrometheusMetricsUtil {
private static void addProcessingPerformanceMetrics(final
NiFiMetricsRegistry niFiMetricsRegistry, final ProcessingPerformanceStatus
perfStatus, final String instanceId,
final String
componentType, final String componentName, final String componentId, final
String parentId) {
if (perfStatus != null) {
- niFiMetricsRegistry.setDataPoint(perfStatus.getCpuDuration() /
1000.0, "PROCESSING_PERFORMANCE_CPU_DURATION",
+ // convert base metrics from nanoseconds to milliseconds except
for PROCESSING_PERFORMANCE_GC_DURATION which is already in milliseconds
+ niFiMetricsRegistry.setDataPoint(perfStatus.getCpuDuration() /
NANOS_PER_MILLI, "PROCESSING_PERFORMANCE_CPU_DURATION",
instanceId, componentType, componentName, componentId,
parentId, perfStatus.getIdentifier());
- // Base metric already in milliseconds
niFiMetricsRegistry.setDataPoint(perfStatus.getGarbageCollectionDuration(),
"PROCESSING_PERFORMANCE_GC_DURATION",
instanceId, componentType, componentName, componentId,
parentId, perfStatus.getIdentifier());
-
niFiMetricsRegistry.setDataPoint(perfStatus.getContentReadDuration() / 1000.0,
"PROCESSING_PERFORMANCE_CONTENT_READ_DURATION",
+
niFiMetricsRegistry.setDataPoint(perfStatus.getContentReadDuration() /
NANOS_PER_MILLI, "PROCESSING_PERFORMANCE_CONTENT_READ_DURATION",
instanceId, componentType, componentName, componentId,
parentId, perfStatus.getIdentifier());
-
niFiMetricsRegistry.setDataPoint(perfStatus.getContentWriteDuration() / 1000.0,
"PROCESSING_PERFORMANCE_CONTENT_WRITE_DURATION",
+
niFiMetricsRegistry.setDataPoint(perfStatus.getContentWriteDuration() /
NANOS_PER_MILLI, "PROCESSING_PERFORMANCE_CONTENT_WRITE_DURATION",
instanceId, componentType, componentName, componentId,
parentId, perfStatus.getIdentifier());
-
niFiMetricsRegistry.setDataPoint(perfStatus.getSessionCommitDuration() /
1000.0, "PROCESSING_PERFORMANCE_SESSION_COMMIT_DURATION",
+
niFiMetricsRegistry.setDataPoint(perfStatus.getSessionCommitDuration() /
NANOS_PER_MILLI, "PROCESSING_PERFORMANCE_SESSION_COMMIT_DURATION",
instanceId, componentType, componentName, componentId,
parentId, perfStatus.getIdentifier());
}
}