The link to Pierre V.'s article was indeed most helpful, Breno - thanks again. Lost on me up till now was this: "... With this example, the ExecuteScript processor will just transmit the flow file without any modification to the success relationship but will also increment the counter “my-counter” of 1. *If this counter does not exist it will be initialized with the delta value given as argument*." In other words we get the benefit of the existence check simply by making the initial call to increment the counter by one. Once again I was overcomplicating the situation. Jim
On Fri, Feb 11, 2022 at 5:33 AM James McMahon <[email protected]> wrote: > Thanks Breno, I will look at those links this morning. -Jim > > On Thu, Feb 10, 2022 at 10:56 PM Breno Cesar <[email protected]> > wrote: > >> Oh, now I understand jim, I believe that this post by Pierre Villard >> (a.k.a god of nifi) can help you, he done that using execute script >> processor: >> >> https://pierrevillard.com/2017/02/07/using-counters-in-apache-nifi/ >> >> As well this execute script cookbook from cloudera community: >> >> https://community.cloudera.com/t5/Community-Articles/ExecuteScript-Cookbook-part-1/ta-p/248922 >> >> Em sex., 11 de fev. de 2022 00:28, James McMahon <[email protected]> >> escreveu: >> >>> It is a flowfile attribute already, Breno. I am trying to keep a count >>> of the number of flowfiles by values found within that attribute as >>> flowfiles pass through the flow. Counters seem to lend themselves to that. >>> I don’t know how to create a new counter, though, each time I find a new >>> value in the attribute. >>> Jim >>> >>> On Thu, Feb 10, 2022 at 8:58 PM Breno Cesar <[email protected]> >>> wrote: >>> >>>> Jim, >>>> >>>> What about use extracttext processor to transform this specific field >>>> in your flowfile content in a flowfile attribute ? doing that, i believe >>>> that modules like updateattribute and replacetext would be more useful in >>>> your logic. >>>> >>>> >>>> *Breno * >>>> >>>> Em qui., 10 de fev. de 2022 às 22:40, James McMahon < >>>> [email protected]> escreveu: >>>> >>>>> 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 >>>>> >>>>
