<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question Get total count of number of events per minute from consumer kafka in Support Questions</title>
    <link>https://community.cloudera.com/t5/Support-Questions/Get-total-count-of-number-of-events-per-minute-from-consumer/m-p/317129#M227024</link>
    <description>&lt;P class="lia-align-left"&gt;Hi, I am new to NIFI, I wanted to Get total count of number of events per minute from consumer kafka.&lt;BR /&gt;After searching on internet, I get 'UpdateCounter' , but information was very less. Can someone suggest me how to add counter . I added ${filename} in UpdateCounter&amp;gt;properities&amp;gt;counter name, It is giving individual file name with value 1 in hamburger menu&amp;gt;counter.&lt;BR /&gt;Or is there any other processor that can give the event count from the consumer kafka.&lt;BR /&gt;Thank you in advance.&lt;/P&gt;</description>
    <pubDate>Wed, 26 May 2021 04:07:50 GMT</pubDate>
    <dc:creator>aie</dc:creator>
    <dc:date>2021-05-26T04:07:50Z</dc:date>
    <item>
      <title>Get total count of number of events per minute from consumer kafka</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Get-total-count-of-number-of-events-per-minute-from-consumer/m-p/317129#M227024</link>
      <description>&lt;P class="lia-align-left"&gt;Hi, I am new to NIFI, I wanted to Get total count of number of events per minute from consumer kafka.&lt;BR /&gt;After searching on internet, I get 'UpdateCounter' , but information was very less. Can someone suggest me how to add counter . I added ${filename} in UpdateCounter&amp;gt;properities&amp;gt;counter name, It is giving individual file name with value 1 in hamburger menu&amp;gt;counter.&lt;BR /&gt;Or is there any other processor that can give the event count from the consumer kafka.&lt;BR /&gt;Thank you in advance.&lt;/P&gt;</description>
      <pubDate>Wed, 26 May 2021 04:07:50 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Get-total-count-of-number-of-events-per-minute-from-consumer/m-p/317129#M227024</guid>
      <dc:creator>aie</dc:creator>
      <dc:date>2021-05-26T04:07:50Z</dc:date>
    </item>
    <item>
      <title>Re: Get total count of number of events per minute from consumer kafka</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Get-total-count-of-number-of-events-per-minute-from-consumer/m-p/317313#M227111</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/88925"&gt;@aie&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Awesome to hear you're getting involved with NiFi.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;NiFi has both ConsumeKafka and ConsumeKafkaRecord based processors.&amp;nbsp; These Kafka processor components in NiFi utilize Kafka client code and with Kafka the client version matters.&amp;nbsp; So make sure you are using the component version that matches the version of yoru Kafka server.&lt;BR /&gt;&lt;BR /&gt;NiFi produces FlowFiles that move from component to component in your dataflow(s).&amp;nbsp; A FlowFile consists of two parts, FlowFile Attributes/metatdata and FlowFile Content (actual physical content of ingested/created data).&amp;nbsp; The FlowFile Attributes/Metadata lives with NiFi's JVM heap memory space and is persisted to the FlowFile repository while content resides in the content repository and only exists in heap memory space if a specific processor should need for that.&amp;nbsp; I bring this up because more FlowFiles = higher heap usage and processing resources related to the creating and management of those FlowFiles.&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;The many NIFi "record" based processors (like ConsumeKafkaRecord) are much more efficient to use.&amp;nbsp; The consumeKafkaRecord processor while ingest many Kafka messages to a single FlowFile.&amp;nbsp; Down side here is this makes calculating things like messages per minute much harder to do.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now if you are just looking to count the total number of consumed messages, you can do this.&amp;nbsp; I'll use the &lt;A href="https://nifi.apache.org/docs/nifi-docs/components/org.apache.nifi/nifi-kafka-2-0-nar/1.13.2/org.apache.nifi.processors.kafka.pubsub.ConsumeKafkaRecord_2_0/index.html" target="_self"&gt;ConsumeKafkaRecord_2_0&lt;/A&gt; processor as an example here.&amp;nbsp; Most processor will create or modify FlowFile attributes and you can look at the embedded usage documentation for each component to see what those attributes are.&amp;nbsp; All created attributes on a FlowFile can be read by other processor using &lt;A href="https://nifi.apache.org/docs/nifi-docs/html/expression-language-guide.html" target="_self"&gt;NiFi Expression Language.&lt;/A&gt;&amp;nbsp; So If we look at the Attributes created on the FlowFiles created by the ConsumeKafkaRecord processor we will find a couple named "&lt;SPAN&gt;&lt;STRONG&gt;record.count&lt;/STRONG&gt;" and "&lt;STRONG&gt;kafka.topic&lt;/STRONG&gt;" (make note that all attribute names are case sensitive).&amp;nbsp; The&amp;nbsp;"&lt;STRONG&gt;record.count&lt;/STRONG&gt;" attribute will tell you the number of messages in this one FlowFile.&lt;BR /&gt;&lt;BR /&gt;We can now use this "&lt;STRONG&gt;record.count&lt;/STRONG&gt;" attribute can now be used to increment a counter using the &lt;A href="https://nifi.apache.org/docs/nifi-docs/components/org.apache.nifi/nifi-standard-nar/1.13.2/org.apache.nifi.processors.standard.UpdateCounter/index.html" target="_self"&gt;UpdateCounter&lt;/A&gt; processor&amp;nbsp;&lt;/SPAN&gt;component.&amp;nbsp; We use the "&lt;STRONG&gt;kafka.topic&lt;/STRONG&gt;" attribute as the counter name so that one counter ic created for each unique topic you may consume from.&amp;nbsp; We use the&amp;nbsp;&lt;SPAN&gt;"&lt;STRONG&gt;record.count&lt;/STRONG&gt;" attribute so we can increment that counter based on number of messages in each FlowFile.&amp;nbsp; Configuration would&amp;nbsp;look like this:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MattWho_0-1622230460687.png" style="width: 400px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/31345i011BBDCA504FAFB9/image-size/medium?v=v2&amp;amp;px=400" role="button" title="MattWho_0-1622230460687.png" alt="MattWho_0-1622230460687.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;You can observe the counters and reset them via the counters UI found under the NiFi global menu in upper right corner of the UI.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MattWho_1-1622230556990.png" style="width: 400px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/31346i9F407D3FC7E109C8/image-size/medium?v=v2&amp;amp;px=400" role="button" title="MattWho_1-1622230556990.png" alt="MattWho_1-1622230556990.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Also keep the following in mind for good performance.&amp;nbsp; NiFi's when it comes to the consumeKafka processors is a Kafka Consumer Group.&amp;nbsp; The processor itself lets you set a unique "Group ID" for this processors Kafka consumer group. When you add any processor component to the NiFi UI it starts with the default "1" concurrent task.&amp;nbsp; For Optimal Kafka performance you want your Kafka Consumer Group to have as many consumers as there are partitions in the target topic.&amp;nbsp; Also keep in mind that if you are running a NiFi cluster (recommended), each processor executes on each node as part of same consumer group.&amp;nbsp; So 3 node cluster, will mean your ConsumeKafkaRecord with 1 concurrent task has three consumers in that group.&amp;nbsp; So you would ideally for best performance want to have a multiple of 3 as the number of partitions on the topic (3, 6, 9, 12, 15, etc...). Let say you have a 3 node cluster and your topic has 15 partitions, then your consumeKafkaRecord should be set to 5 concurrent tasks (5 x 3 nodes = 15 consumers).&amp;nbsp; Avoid having more consumers than partitions or you will constantly have rebalance going on.&amp;nbsp; So even if you had 16 partitions on your topic you would still set only 5 concurrent tasks. One of your 15 available consumers would simply be assigned to receive data from two topics instead of just one.&lt;BR /&gt;&lt;BR /&gt;If you found this information was helpful with yoru query, please take a moment to login and click "Accept" on this solution.&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://nifi.apache.org/docs.html" target="_blank"&gt;https://nifi.apache.org/docs.html&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Thank you and happy NiFi'ing....&lt;BR /&gt;Matt&lt;/P&gt;</description>
      <pubDate>Fri, 28 May 2021 19:50:46 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Get-total-count-of-number-of-events-per-minute-from-consumer/m-p/317313#M227111</guid>
      <dc:creator>MattWho</dc:creator>
      <dc:date>2021-05-28T19:50:46Z</dc:date>
    </item>
    <item>
      <title>Re: Get total count of number of events per minute from consumer kafka</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Get-total-count-of-number-of-events-per-minute-from-consumer/m-p/317635#M227261</link>
      <description>&lt;P&gt;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/88925"&gt;@aie&lt;/a&gt;&amp;nbsp;&amp;nbsp;Has your issue been resolved? If so, please mark the appropriate reply as the solution, as it will make it easier for others to find the answer in the future.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="mark as solution button" style="width: 331px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/5960i4EC112CCAAC11427/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screen Shot 2019-08-06 at 1.54.47 PM.png" alt="Screen Shot 2019-08-06 at 1.54.47 PM.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Jun 2021 12:33:14 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Get-total-count-of-number-of-events-per-minute-from-consumer/m-p/317635#M227261</guid>
      <dc:creator>cjervis</dc:creator>
      <dc:date>2021-06-03T12:33:14Z</dc:date>
    </item>
  </channel>
</rss>

