I want to create execution cycle of n8n workflows, like how many time a workflow was called how much time it took and how many sub workflow it executed and how much time they took.
The N8n API do give me execution stats, but there is no way to find out who called a workflow, if we can have parent workflow id, it will add a great value.
As far I am aware, workflow/sub-workflow are all executions … all get an execution id(but is not different like parent or child).
There’s something like Insights available and Custom execution metadata , but in Pro/Cloud and Enterprise/self versions.
What are trying to achieve is only though API to get executions, and do whatever you want to count/sort etc… but to “corellate” , honestly I don’t know.
Hi! You are correct—the default n8n API response for executions is “flat,” meaning it doesn’t automatically link child executions to their parents in a queryable way.
However, you can build this observability yourself with a “Pass the Baton” strategy. Since {{ $execution.id }} is always available, you just need to pass it down explicitly.
Some ideas you may consider below. :
1. Pass the Parent ID explicitly
In your Parent Workflow, inside the Execute Workflow node, you must pass the current execution ID as an input to the child.
Node: Execute Workflow
Input Data: JSON
JSON Config:
JSON
{
"parentExecutionId": "{{ $execution.id }}",
"parentWorkflowName": "My Parent Workflow"
}
2. Log the relationship (The “Logger” Pattern)
Since you want to analyze cycles and duration, relying on the internal n8n database isn’t ideal (as it gets pruned/vacuumed). It is better to have both the Parent and Child send a log to an external source (like a Postgres DB, Google Sheet, or a dedicated logging workflow).
In the Child Workflow: At the end of the execution, send a log entry containing:
Self ID:{{ $execution.id }}
Parent ID:{{ $json["parentExecutionId"] }} (received from input)
Duration: You can calculate this using expressions or just log the start and end timestamps.
3. Reconstructing the Tree
Once you have this data in a database/sheet, you can easily query it:
Count Sub-workflows:SELECT count(*) WHERE parentExecutionId = 'X'
Total Time: Sum the duration of all rows sharing the same Root Parent ID.
n8n doesn’t natively “stamp” the child with the parent’s ID in the system metadata, so you have to treat the Execution ID like a foreign key and pass it manually through the node inputs.
Hi @Aqeel, All of this information can be extracted by using the “Get an execution” node. Just make sure you have the workflows settings set to save the execution data. This way you can actually see the nodes which got executed and whether a sub-workflow was called, how long it took etc.
All you’ll need to do is build a workflow which will loop over the executions and pull out the information. You can then store this in a custom db to pull your stats from.