Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to reference an environment variable in Nifi?

Tags:

apache-nifi

I would like to reference an environment variable (a linux environment variable) in my Nifi Processors. I tried using expression language by referencing ${MY_VARIABLE_NAME} directly in the properties of the processor. But this doesn't seem to work. Is this even possible ? If yes How can it be done ?

Thank you for your suggestions.

like image 956
Mohammed El Moumni Avatar asked Oct 15 '25 13:10

Mohammed El Moumni


1 Answers

You can reference environment variables in NiFi Expression Language as you describe. If it is not working, you might check a few things:

  • The processor property supports Expression Language
  • The environment variable is defined for the NiFi process (try ${USER} or ${PATH} for contrast)
  • There are no other attributes with the same name that have precedence over the environment variable in EL evaluation

This is briefly discussed in Structure of a NiFi Expression in the NiFi Expression Language Guide with respect to escaping:

For example, the following can be used to escape an attribute named “my attribute”: ${"my attribute"} or ${'my attribute'}.

In this example, the value to be returned is the value of the "my attribute" value, if it exists. If that attribute does not exist, the Expression Language will then look for a System Environment Variable named "my attribute." If unable to find this, it will look for a JVM System Property named "my attribute." Finally, if none of these exists, the Expression Language will return a null value.

like image 153
James Avatar answered Oct 19 '25 11:10

James



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!