I have a field in my flowfiles, mime.extension. My requirement is to maintain and update counters that cross-tabulate the values that occur in this field as flowfiles stream through my process group.
I thought I might use a Groovy script in an ExecuteScript function to grab the value in mime.extension as each flowfile passes through the processor. If a counter already exists for the value, I will increment it by one. If the value does not yet exist as a counter, I will need to create it as a counter and then increment it by one. This will allow me to build a crosstab of distribution in that field as data passes through over time. I can’t figure out how to check existing counters to see if the value in mime.extension for a flowfile already exists, and add it as a new counter if it does not. Has anyone got an example of something like this in Groovy? A means to dynamically check existing counters and add new ones? Am I overlooking a simpler approach - perhaps a nifi processor that already exists to do this? I do this in a very neanderthal way today: I review flowfiles in queue, add new mime.extension values to a mapping in a RouteOnAttribute processor, and route copies of flowfiles to temporary holding queues for some sampling of my data over time. It works but it isn’t very dynamic, elegant, or adaptable to different flows. Thanks in advance for your any help. Jim
