Support Questions
Find answers, ask questions, and share your expertise

Execute a process when a ProcessGroup starts (or shutdown)?

Is there a possibility to defined somewhere a trigger that gets executed when a ProcessGroup starts?

 

My use case is this:

 

  • Someone creates a copy of an existing ProcessGroup in the Nifi workspace
  • When the ProcessGroup starts some administrative tasks are started that setup the ProcessGroup
    • E.g. create required database
    • E.g. created required directories
    • Any ProcessGroup initialization
2 REPLIES 2

Explorer

EDIT: @MattWho 's answer made it clear to me I slightly misunderstood the question. His suggestion of managing the entire process using a script is definitely the way to go and would perfectly fit your use-case of someone creating a new instance of an existing process group. If I may add, it sounds like using the nifi registry might benefit you. You could upload your base process group to the registry and use version control with it. Then, when creating new copies, you would instead 'pull' the same process group from the registry instead of creating a copy of process group that exists in your canvas and might unintentionally get changed or deleted.

----------------

 

I do not believe there is a built-in way to directly run an event when a process group is started/stopped, but a reasonable workaround would be to monitor nifi's app-logs and trigger your own event when you receive a log that mentions starting your PG.

 

If you only want to use tools offered by nifi, you could use the TailFile processor and configure it to run over your app-logs file, then use another processor (such as RouteOnContent) to match the log for starting the PG. From there you can try and do whatever it is that starts the administrative tasks (such as sending an http request with InvokeHTTP processor)

 

If this answer helped, please mark it as 'solved' and/or apply 'kudos' 🙂

Master Guru

@patrick_hochste 

There is nothing built in that can help with this task.

The challenges here:
1. A user who can copy and paste a PG can also modify that PG before ti gets started (like change the PG name).
2. The created PG and all the containing components are assigned new unique UUIDs.  The log will use these new UUIDs when component is started.
3. How do you distinguish between a PG that is copied and one that is being created new?
4. How do you distinguish between a PG that is being started after it was stopped versus starting a brand new copied PG?
5. A copied PG will get a copy of all components and their current configuration. Since you reference setting up an ew DB, does that mean changes to some components configurations?
------

While there is nothing built in to NiFi that can help you trigger based on a copy, paste, and start of a PG, if you could automate the entire process externally via a script, you could build a controlled and structured copy and paste capability.  Keep in mind that anything you can do from directly within the NiFi UI, you can also accomplish via the NiFi Rest API.  This flexibility would allow you to automate the copy of an existing PG, the pasting of that PG, modifying of that copied PG, and any other external scripted requirements.

If you found the provided response(s) assisted with your query, please take a moment to login and click on "Accept as Solution" below each solution that helped you.

Thank you,

Matt

Take a Tour of the Community
Don't have an account?
Your experience may be limited. Sign in to explore more.