Subjectless Functions
While the majority of functions in the Expression Language are called by using the syntax ${attributeName:function()}
, there exist a few functions that are not expected to have subjects. In this case, the attribute name is not present. For example, the IP address of the machine can be obtained by using the Expression ${ip()}
. All of the functions in this section are to be called without a subject. Attempting to call a subjectless function and provide it a subject will result in an error when validating the function.
ip
Description: Returns the IP address of the machine.
Subject Type: No subject
Arguments: No arguments
Return Type: String
Examples: The IP address of the machine can be obtained by using the Expression
${ip()}
.
hostname
Description: Returns the Hostname of the machine. An optional argument of type
Boolean can be provided to specify whether or not the Fully Qualified Domain Name should
be used. If false
, or not specified, the hostname will not be fully
qualified. If the argument is true
but the fully qualified hostname
cannot be resolved, the simple hostname will be returned.
Subject Type: No subject
Arguments:
-
Fully Qualified : Optional parameter that specifies whether or not the hostname should be fully qualified. If not specified, defaults to false.
Return Type: String
Examples: The fully qualified hostname of the machine can be obtained by using
the Expression ${hostname(true)}
, while the simple hostname can be
obtained by using either ${hostname(false)}
or simply
${hostname()}
.
UUID
Description: Returns a randomly generated type 4 UUID.
Subject Type: No Subject
Arguments: No arguments
Return Type: String
Examples: ${UUID()}
returns a value similar to
"de305d54-75b4-431b-adb2-eb6b9e546013"
nextInt
Description: Returns a one-up value (starting at 0) and increasing over the lifetime of the running instance of NiFi. This value is not persisted across restarts and is not guaranteed to be unique across a cluster. This value is considered "one-up" in that if called multiple times across the NiFi instance, the values will be sequential. However, this counter is shared across all NiFi components, so calling this function multiple times from one Processor will not guarantee sequential values within the context of a particular Processor.
Subject Type: No Subject
Arguments: No arguments
Return Type: Number
Examples: If the previous value returned by nextInt
was
5
, the Expression ${nextInt():divide(2)}
obtains
the next available integer (6) and divides the result by 2, returning a value of
3
.
literal
Description: Returns its argument as a literal String value. This is useful in order to treat a string or a number at the beginning of an Expression as an actual value, rather than treating it as an attribute name. Additionally, it can be used when the argument is an embedded Expression that we would then like to evaluate additional functions against.
Subject Type: No Subject
Arguments:
-
value : The value to be treated as a literal string, number, or boolean value.
Return Type: String
Examples: ${literal(2):gt(1)}
returns true
${literal( ${allMatchingAttributes('a.*'):count()}
):gt(3)}
returns true if there are more than 3 attributes whose names begin with the letter
a
.getStateValue
Description: Access a processor’s state values by passing in the String key and getting the value back as a String. This is a special Expression Language function that only works with processors that explicitly allow EL to query state. Currently only UpdateAttribute does.
Subject Type: No Subject
Arguments:
-
Key : The key to use when accessing the state map.
Return Type: String
Examples: UpdateAttribute processor has stored the key "count" with value "20" in
state. '${getStateValue("count")}` returns 20
.
thread
Description: Returns the name of the thread used by the processor when evaluating the Expression. This can be useful when using a processor with multiple concurrent tasks and where some data uniqueness is required.
Subject Type: No Subject
Arguments: No arguments
Return Type: String
Examples: ${thread()}
could return something like
Timer-Driven Process Thread-4
.