Support Questions

Find answers, ask questions, and share your expertise

Custom reporting task not triggering

avatar

I have implemented a custom reporting task, very simple one to start with, which just logs all details that come in the context of `onTrigger` method. I see the nar being unpacked and the reporting task being started when I start from the settings, but nothing logs after that.

My Run Schedule is 30 sec (I also tried changing this to 1 mins and 5 mins), but nothing ever logs, but reporting task shows as running. No errors in logs whatsoever.

Only log lines I see in nifi-app.log are these

org.apache.nifi.metrics.reporting.task.MetricsReportingTask
                org.apache.nifi:nifi-metrics-reporting-nar:1.6.0-SNAPSHOT || ./work/nar/extensions/nifi-metrics-reporting-nar-1.6.0-SNAPSHOT.nar-unpacked
        org.apache.nifi.reporting.ambari.AmbariReportingTask
                org.apache.nifi:nifi-ambari-nar:1.6.0-SNAPSHOT || ./work/nar/extensions/nifi-ambari-nar-1.6.0-SNAPSHOT.nar-unpacked
        org.apache.nifi.reporting.datadog.DataDogReportingTask
                org.apache.nifi:nifi-datadog-nar:1.6.0-SNAPSHOT || ./work/nar/extensions/nifi-datadog-nar-1.6.0-SNAPSHOT.nar-unpacked
        org.apache.nifi.controller.ControllerStatusReportingTask
                org.apache.nifi:nifi-standard-nar:1.6.0-SNAPSHOT || ./work/nar/extensions/nifi-standard-nar-1.6.0-SNAPSHOT.nar-unpacked
        org.apache.nifi.controller.MonitorDiskUsage
                org.apache.nifi:nifi-standard-nar:1.6.0-SNAPSHOT || ./work/nar/extensions/nifi-standard-nar-1.6.0-SNAPSHOT.nar-unpacked
        com.blah.cloud.datamanager.tasks.CSReportingTask
                com.blah.cloud.datamanager:nifi-csreporting-nar:1.0-SNAPSHOT || ./work/nar/extensions/nifi-csreporting-nar-1.0-SNAPSHOT.nar-unpacked<br>2018-06-05 04:03:29,056 INFO [Timer-Driven Process Thread-9] o.a.n.c.s.TimerDrivenSchedulingAgent CSReportingTask[id=ce15e357-0163-1000-0000-0000139a1779] started.

My Reporting Task code

public class CSReportingTask extends AbstractReportingTask {
    @Override
    public void onTrigger(ReportingContext context) {
        EventAccess eventAccess = context.getEventAccess();
        ProcessGroupStatus groupStatus = eventAccess.getControllerStatus();
        Collection<ProcessorStatus> processorStatus = groupStatus.getProcessorStatus();
        String nodeId = context.getClusterNodeIdentifier();
        for (ProcessorStatus status : statuses) {
            String groupID = status.getGroupId();
            String name = status.getName();
            String execNode = status.getExecutionNode().name();
            String id = status.getId();
            String type = status.getType();
            String runStatus = status.getRunStatus().name();
            getLogger().info("id: {}; name: {}; groupID: {}; execNode: {}; type: {}; runStatus: {}; nodeID: {}", new Object[]{id, name, groupID, execNode, type, runStatus, nodeId});
        }
    }
}
1 ACCEPTED SOLUTION

avatar
Master Guru

Your getLogger.info(...) statement is inside a for loop over "statuses" and I don't see a variable called statuses so it is hard to say what is in the variable, but if that is an empty collection then you might not be executing your for loop. I would try putting a logging statement right at the beginning of onTrigger to see if the reporting task is even executed.

View solution in original post

4 REPLIES 4

avatar
Master Guru

Your getLogger.info(...) statement is inside a for loop over "statuses" and I don't see a variable called statuses so it is hard to say what is in the variable, but if that is an empty collection then you might not be executing your for loop. I would try putting a logging statement right at the beginning of onTrigger to see if the reporting task is even executed.

avatar

statuses variable not in code is a copy paste error. I did add more logging and I see the statuses is empty which is why nothing logs.

avatar
@Bryan Bende

Similar question along same lines. I want to report metrics from nifi at the processor level and processor group level and I was able to get this metrics from the rest API, but I am when I get aggregate snapshot I am worried that all nodes will send exactly the same metrics which might show wrong values after aggregation in graphite or I planned to use node level metrics snapshot, if I can compare the node which is sending data can only send its specific metrcis not all nodes metrics.

Is this possible ? or there is a better solution to get fine level metrics ?

avatar
Master Guru

I don't know that much about the internals of NiFi's metrics, but when you use the REST API it should be making a federated request to all the nodes, which is different from a reporting task which should only have the metrics for the given node it is running on.