Skip to main content
andrewg
Gold ⭐️
Gold ⭐️
Oct 6, 2015 7:47 PM UTC

A Collection of NiFi Examples

  • Oct 5, 2026 9:19 AM UTC
  • 3 replies
  • 71974 views
  • Translate All

A series of examples and flow files:

https://github.com/xmlking/nifi-examples

NiFi Examples

Apache NiFi example flows.

collect-stream-logs

This flow shows workflow for log collection, aggregation, store and display.

  1. Ingest logs from folders.
  2. Listen for syslogs on UDP port.
  3. Merge syslogs and drop-in logs and persist merged logs to Solr for historical search.
  4. Dashboard: stream real-time log events to dashboard and enable cross-filter search on historical logs data.

csv-to-json

This flow shows how to convert a CSV entry to a JSON document using ExtractText and ReplaceText.

decompression

This flow demonstrates taking an archive that is created with several levels of compression and then continuously decompressing it using a loop until the archived file is extracted out.

http-get-route

his flow pulls from a web service (example is nifi itself), extracts text from a specific section, makes a routing decision on that extracted value, prepares to write to disk using PutFile.

invoke-http-route

This flow demonstrates how to call an HTTP service based on an incoming FlowFile, and route the original FlowFile based on the status code returned from the invocation. In this example, every 30 seconds a FlowFile is produced, an attribute is added to the FlowFile that sets q=nifi, the google.com is invoked for that FlowFile, and any response with a 200 is routed to a relationship called 200.

retry-count-loop

This process group can be used to maintain a count of how many times a flowfile goes through it. If it reaches some configured threshold it will route to a 'Limit Exceeded' relationship otherwise it will route to 'retry'. Great for processes which you only want to run X number of times before you give up.

split-route

This flow demonstrates splitting a file on line boundaries, routing the splits based on a regex in the content, merging the less important files together for storage somewhere, and sending the higher priority files down another path to take immediate action.

twitter-garden-hose

This flow pulls from Twitter using the garden hose setting; it pulls out some basic attributes from the Json and then routes only those items that are actually tweets.

twitter-solr

This flow shows how to index tweets with Solr using NiFi. Pre-requisites for this flow are NiFi 0.3.0 or later, the creation of a Twitter application, and a running instance of Solr 5.1 or later with a tweets collection. Here are sample steps to set this up (along with Banana dashboard) on HDP Sandbox.

Other examples

https://github.com/hortonworks-gallery/nifi-templates

3 replies

gbraccialli3
Gold ⭐️
Oct 23, 2015 12:21 AM UTC

@abajwa@hortonworks.com I tried collect-stream-logs but I got error below when trying to use the imported template. Do you know what version of nifi it's supposed to work with?

302-error-nifi.png

Translate
andrewg
Gold ⭐️
andrewgAuthor
Gold ⭐️
Oct 23, 2015 11:45 PM UTC

You are missing a dependency from the example. Note that this is an external link, not created nor endorsed by Hortonworks.

Example instructions mention it in the first paragraph:

Note: this flow depends on nifi-websocket module, download nar and copy to $NIFI_HOME/lib

Module source code is here:

https://github.com/xmlking/nifi-websocket

Translate
paparazi257
Silver ⭐️⭐️
Jul 27, 2017 10:45 AM UTC

I agree

This flow shows workflow for log collection, aggregation, store and display.

  1. Ingest logs from folders.
  2. Listen for syslogs on UDP port.
  3. Merge syslogs and drop-in logs and persist merged logs to Solr for historical search.
  4. Dashboard: stream real-time log events to dashboard and enable cross-filter search on historical logs data https://community.hortonworks.com/articles/961/a-collection-of-nifi-examples.html
Translate