Support Questions

Find answers, ask questions, and share your expertise
Celebrating as our community reaches 100,000 members! Thank you!

NIFI --How to get the Current Processor group Name ( like a breadcrumb) through the custom processor using JAVA.


I have created a nifi custom processor, I need get a current process group id, How can I do that?

Say for instance I need to update the flowfile attribute with the process group id for some later report generation or something.... Is it possible to get the current process group id?


I have created a custom processor. At runtime I want to get the process group id, How do i do that?.

Say for instance I want update the flowfile attribute of every data packet with process group id, so that I can manipulate the provenance data based on the this field.



If the goal is to only update the flowfiles with group id i would suggest to use the script mentioned here by @mburgess here : . As mentioned in the post, there is a caveat so please double check.

I would still recommend to use this script anyway if there the custom processor has more to do, you can always pull in attributes in the custom processor very easily.

Hope this helps. If the comment helps you to find a solution or move forward, please accept it as a solution for other community members.


Thanks for your suggestion,  Below one is groovy manner... I want to implement in Java 

Could not find direct way like mentioned below. 

Please suggest me the Java Code implementation


def flowFile = session.get()
if(!flowFile) return
processGroupId = context.procNode?.processGroupIdentifier ?: 'unknown'
flowFile = session.putAttribute(flowFile, 'processGroupId', processGroupId)
session.transfer(flowFile, REL_SUCCESS)



I tried to a little to find Java implementation but i didnt find any. But, cant you use as i mentioned above. Use the groovy script to add the PG id and then in your custom processor just get the attribute containing the PG id and do whatever you goal is?