Reputation: 10565
In NiFi 1.3.0, I have created a flow to split a JSON file and update the counter with name filenamecounter
so that I can save each split into different file names. I see that the counter value gets updated when I view the NiFi counters pane. But how can I access this value?
I tried setting an attribute with the counter name, and counters property. Like ${filenamecounter}
and ${filenamecounter.counter}
but unsuccessful.
Upvotes: 2
Views: 5072
Reputation: 18630
Currently counters are mostly a monitoring feature, you can't really access them from expression language. They're used to answer questions like "how many messages have I received from source xyz?".
In your case, all of the "split" processors should be writing a standard set of fragment attributes:
@WritesAttribute(attribute = "fragment.identifier",
description = "All split FlowFiles produced from the same parent FlowFile will have the same randomly generated UUID added for this attribute"),
@WritesAttribute(attribute = "fragment.index",
description = "A one-up number that indicates the ordering of the split FlowFiles that were created from a single parent FlowFile"),
@WritesAttribute(attribute = "fragment.count",
description = "The number of split FlowFiles generated from the parent FlowFile"),
So you should be able to use ${fragment.index} in your filename.
Upvotes: 3