Created 02-12-2018 02:26 PM
Hi,
I need to get the processor-group name in my NIFI flow.
I could hardcode it in updateAttribute, but would prefere to get it dynamilly
Is that possible using expression langugage or executescript
Created 02-12-2018 04:14 PM
It is possible with ExecuteScript and Groovy if you don't have a SecurityManager set on the JVM that would prevent Groovy from getting at the ProcessorNode which is a private member variable of the StandardProcessContext. The following script can be used in ExecuteScript to add the parent process group ID as an attribute to an incoming flow file:
def flowFile = session.get() if(!flowFile) return processGroupId = context.procNode?.processGroupIdentifier ?: 'unknown' flowFile = session.putAttribute(flowFile, 'processGroupId', processGroupId) session.transfer(flowFile, REL_SUCCESS)
Created 02-12-2018 04:14 PM
It is possible with ExecuteScript and Groovy if you don't have a SecurityManager set on the JVM that would prevent Groovy from getting at the ProcessorNode which is a private member variable of the StandardProcessContext. The following script can be used in ExecuteScript to add the parent process group ID as an attribute to an incoming flow file:
def flowFile = session.get() if(!flowFile) return processGroupId = context.procNode?.processGroupIdentifier ?: 'unknown' flowFile = session.putAttribute(flowFile, 'processGroupId', processGroupId) session.transfer(flowFile, REL_SUCCESS)
Created 05-15-2018 10:41 AM
Hi @Matt Burgess, your solution works really fine, thanks.
I was trying to see where procNode property was defined to see what else can be get from there but I am unable to find it.
Do you know where is this information?
Thanks.
Created 05-15-2018 02:22 PM
It comes from knowing that the ProcessContext passed into the script is actually a StandardProcessContext which has some variables you can get at with Groovy (provided there is no SecurityManager as mentioned).
Created 06-22-2018 02:16 PM
The process group name can actually be found with the attached groovy code:
def flowFile = session.get() if(!flowFile) return processGroupName = context.procNode?.getProcessGroup().getName() flowFile = session.putAttribute(flowFile, 'processGroupName', processGroupName) session.transfer(flowFile, REL_SUCCESS)
Created on 09-25-2025 02:57 AM - edited 09-25-2025 05:20 AM
Hello!
I'm newbe in NiFi and Groovy. I hope you can help me.
Related Topic: I found here – "Solved: Re: Get the processor-group name in NIFI flow - Cloudera Community - 213662" (2018) – very interestion solution! Thank to @mburges
I have related question: I want to build with Groovy dictionary/cache for every proceccor where key = Proccesor ID, value = "bread crumbs" (full path to processor from root canvas – the string like this: "PG1_Name" / "PG2_(Child_of_PG1)_Name" / "PG3_(Child_of_PG2)_Name" .
The quesions are:
Thanks in advance for any help!
Created 09-26-2025 06:14 AM
@IgorSpryzhkov
You have asked a new unrelated question in an older post which already has an accepted answer. You would get better traction/visibility in the community of you were to start a new community question instead.
Thank you,
Matt