mirror of
https://github.com/apache/nifi.git
synced 2025-02-10 20:15:09 +00:00
NIFI-6723: Enrich processor-related and JVM GC metrics in Prometheus Reporting Task
Signed-off-by: Matthew Burgess <mattyb149@apache.org> This closes #3771
This commit is contained in:
parent
02d3b7e92b
commit
d7ca37d065
@ -20,6 +20,7 @@ package org.apache.nifi.reporting.prometheus.api;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import io.prometheus.client.SimpleCollector;
|
||||
import org.apache.nifi.components.AllowableValue;
|
||||
@ -47,7 +48,7 @@ public class PrometheusMetricsUtil {
|
||||
private static final CollectorRegistry NIFI_REGISTRY = new CollectorRegistry();
|
||||
private static final CollectorRegistry JVM_REGISTRY = new CollectorRegistry();
|
||||
|
||||
// Process Group metrics
|
||||
// Processor / Process Group metrics
|
||||
private static final Gauge AMOUNT_FLOWFILES_SENT = Gauge.build()
|
||||
.name("nifi_amount_flowfiles_sent")
|
||||
.help("Total number of FlowFiles sent by the component")
|
||||
@ -66,6 +67,12 @@ public class PrometheusMetricsUtil {
|
||||
.labelNames("instance", "component_type", "component_name", "component_id", "parent_id")
|
||||
.register(NIFI_REGISTRY);
|
||||
|
||||
private static final Gauge AMOUNT_FLOWFILES_REMOVED = Gauge.build()
|
||||
.name("nifi_amount_flowfiles_removed")
|
||||
.help("Total number of FlowFiles removed by the component")
|
||||
.labelNames("instance", "component_type", "component_name", "component_id", "parent_id")
|
||||
.register(NIFI_REGISTRY);
|
||||
|
||||
private static final Gauge AMOUNT_BYTES_SENT = Gauge.build()
|
||||
.name("nifi_amount_bytes_sent")
|
||||
.help("Total number of bytes sent by the component")
|
||||
@ -150,6 +157,7 @@ public class PrometheusMetricsUtil {
|
||||
"source_id", "source_name", "destination_id", "destination_name")
|
||||
.register(NIFI_REGISTRY);
|
||||
|
||||
// Processor metrics
|
||||
private static final Gauge PROCESSOR_COUNTERS = Gauge.build()
|
||||
.name("nifi_processor_counters")
|
||||
.help("Counters exposed by NiFi Processors")
|
||||
@ -252,6 +260,18 @@ public class PrometheusMetricsUtil {
|
||||
.labelNames("instance")
|
||||
.register(JVM_REGISTRY);
|
||||
|
||||
private static final Gauge JVM_GC_RUNS = Gauge.build()
|
||||
.name("nifi_jvm_gc_runs")
|
||||
.help("NiFi JVM GC number of runs")
|
||||
.labelNames("instance", "gc_name")
|
||||
.register(JVM_REGISTRY);
|
||||
|
||||
private static final Gauge JVM_GC_TIME = Gauge.build()
|
||||
.name("nifi_jvm_gc_time")
|
||||
.help("NiFi JVM GC time in milliseconds")
|
||||
.labelNames("instance", "gc_name")
|
||||
.register(JVM_REGISTRY);
|
||||
|
||||
public static CollectorRegistry createNifiMetrics(ProcessGroupStatus status, String instanceId, String parentPGId, String componentType, String metricsStrategy) {
|
||||
|
||||
final String componentId = status.getId();
|
||||
@ -317,6 +337,29 @@ public class PrometheusMetricsUtil {
|
||||
final String procComponentId = processorStatus.getId();
|
||||
final String procComponentName = processorStatus.getName();
|
||||
final String parentId = processorStatus.getGroupId();
|
||||
|
||||
AMOUNT_FLOWFILES_SENT.labels(instanceId, procComponentType, procComponentName, procComponentId, parentPGId).set(processorStatus.getFlowFilesSent());
|
||||
AMOUNT_FLOWFILES_RECEIVED.labels(instanceId, procComponentType, procComponentName, procComponentId, parentPGId).set(processorStatus.getFlowFilesReceived());
|
||||
AMOUNT_FLOWFILES_REMOVED.labels(instanceId, procComponentType, procComponentName, procComponentId, parentPGId).set(processorStatus.getFlowFilesRemoved());
|
||||
|
||||
AMOUNT_BYTES_SENT.labels(instanceId, procComponentType, procComponentName, procComponentId, parentPGId).set(processorStatus.getBytesSent());
|
||||
AMOUNT_BYTES_READ.labels(instanceId, procComponentType, procComponentName, procComponentId, parentPGId).set(processorStatus.getBytesRead());
|
||||
AMOUNT_BYTES_WRITTEN.labels(instanceId, procComponentType, procComponentName, procComponentId, parentPGId).set(processorStatus.getBytesWritten());
|
||||
AMOUNT_BYTES_RECEIVED.labels(instanceId, procComponentType, procComponentName, procComponentId, parentPGId).set(processorStatus.getBytesReceived());
|
||||
|
||||
SIZE_CONTENT_OUTPUT_TOTAL.labels(instanceId, procComponentType, procComponentName, procComponentId, parentPGId, "", "", "", "")
|
||||
.set(processorStatus.getOutputBytes());
|
||||
SIZE_CONTENT_INPUT_TOTAL.labels(instanceId, procComponentType, procComponentName, procComponentId, parentPGId, "", "", "", "")
|
||||
.set(processorStatus.getInputBytes());
|
||||
|
||||
AMOUNT_ITEMS_OUTPUT.labels(instanceId, procComponentType, procComponentName, procComponentId, parentPGId, "", "", "", "")
|
||||
.set(processorStatus.getOutputCount());
|
||||
AMOUNT_ITEMS_INPUT.labels(instanceId, procComponentType, procComponentName, procComponentId, parentPGId, "", "", "", "")
|
||||
.set(processorStatus.getInputCount());
|
||||
|
||||
AVERAGE_LINEAGE_DURATION.labels(instanceId, procComponentType, procComponentName, procComponentId, parentPGId, "", "", "", "")
|
||||
.set(processorStatus.getAverageLineageDuration());
|
||||
|
||||
AMOUNT_THREADS_TOTAL_ACTIVE.labels(instanceId, procComponentType, procComponentName, procComponentId, parentId)
|
||||
.set(status.getActiveThreadCount() == null ? 0 : status.getActiveThreadCount());
|
||||
AMOUNT_THREADS_TOTAL_TERMINATED.labels(instanceId, procComponentType, procComponentName, procComponentId, parentId)
|
||||
@ -446,6 +489,12 @@ public class PrometheusMetricsUtil {
|
||||
JVM_UPTIME.labels(instanceId).set(jvmMetrics.uptime());
|
||||
JVM_FILE_DESCRIPTOR_USAGE.labels(instanceId).set(jvmMetrics.fileDescriptorUsage());
|
||||
|
||||
jvmMetrics.garbageCollectors()
|
||||
.forEach((name, stat) -> {
|
||||
JVM_GC_RUNS.labels(instanceId, name).set(stat.getRuns());
|
||||
JVM_GC_TIME.labels(instanceId, name).set(stat.getTime(TimeUnit.MILLISECONDS));
|
||||
});
|
||||
|
||||
return JVM_REGISTRY;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user