Community Articles
Find and share helpful community-sourced technical articles
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.
Labels (1)
Super Guru

Properties File Lookup Augmentation of Data Flow in Apache NiFi 1.7.x

A really cool technologist contacted me on LinkedIn and asked an interesting question

Tim,

How do I read values from a properties file and use them in my flow. I want to update/inject an attribute with this value.

If you don't want to use the Variable Registry, but want to inject a value from a properties file how to do it. You could run some REST server and read it or does some file reading hack. But we have a great service to do this very easily!

92663-lookupflow.png

In my UpdateAttribute (or in your regular attributes already), I have an attribute named, keytofind. This contains a lookup key such as an integer or a string key. We will find that value in the properties value and give you that in an attribute of your choosing.

92664-lookupattribute.png

We have a Controller Service to handle this for you. It reads from your specified properties file. Make sure Apache NiFi has permissions to that path and can read the file.

92665-lookupservic.png


PropertiesFileLookupService

https://nifi.apache.org/docs/nifi-docs/components/org.apache.nifi/nifi-lookup-services-nar/1.7.1/org...

We lookup the key specified in the “keytofind”. It returns a value that you specify as an extra attribute, mine is “updatedvalue”.

This is my properties file:

-rwxrwxrwx  1 tspann  staff  67 Oct  4 09:15 lookup.properties

stuff1=value1
stuff2=value2
stuff3=value other
tim=spann
nifi=cool

In this example, we are using the LookupAttribute processor. You can also use the LookupRecord processor depending on your needs.

Resources:

The Flow

lookup-from-properties-values.xml

1,029 Views
Don't have an account?
Coming from Hortonworks? Activate your account here
Version history
Revision #:
2 of 2
Last update:
‎08-17-2019 06:17 AM
Updated by:
 
Contributors
Top Kudoed Authors