Search code examples
apache-nifi

Get id from previous processor NiFi


Processors I'm referring to

Is it possible that the processor "InvokeHTTP" takes the information "id" from the previous processor(in this case SELECT_FROM_SNOWFLAKE)?

Where i want to change

I would like the "Remote URL" to be something like:

http://${hostname()}:8080/nifi-api/processors/${previousProcessorId()}

Solution

  • No, you can't. But you can get name, id or other properties for current processor group using ExecuteScript or ExecuteGroovy processors somewhere in this flow to find these informations with script:

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

    After that, you can find get the id of this snow_flake processor in this processor group for example in rest api.