86e85593-0156-1000-de74-34836a4cd39epython_ExecuteScript440fe4d5-0157-1000-0000-00000000000086e85593-0156-1000-0000-0000000000001 GB1000086e85593-0156-1000-0000-00000000000044023d4c-0157-1000-0000-000000000000PROCESSOR0 sec1success86e85593-0156-1000-0000-000000000000440276ec-0157-1000-0000-000000000000PROCESSOR044cc6dee-0157-1000-0000-00000000000086e85593-0156-1000-0000-0000000000001 GB10000754.280472882269261.1654684925437754.280472882269311.165468492543786e85593-0156-1000-0000-00000000000044023d4c-0157-1000-0000-000000000000PROCESSOR0 sec1failure86e85593-0156-1000-0000-00000000000044023d4c-0157-1000-0000-000000000000PROCESSOR04524787f-0157-1000-0000-00000000000086e85593-0156-1000-0000-0000000000001 GB1000086e85593-0156-1000-0000-00000000000045240b89-0157-1000-0000-000000000000PROCESSOR0 sec1success86e85593-0156-1000-0000-00000000000044023d4c-0157-1000-0000-000000000000PROCESSOR0459336f1-0157-1000-0000-00000000000086e85593-0156-1000-0000-0000000000001 GB100001129.8499554404893490.895083112815771129.8499554404893540.895083112815886e85593-0156-1000-0000-00000000000045240b89-0157-1000-0000-000000000000PROCESSOR0 sec1failure86e85593-0156-1000-0000-00000000000045240b89-0157-1000-0000-000000000000PROCESSOR044023d4c-0157-1000-0000-00000000000086e85593-0156-1000-0000-000000000000299.2804728822689221.1654684925437WARN1Script EngineECMAScriptECMAScriptGroovyGroovylualuapythonpythonrubyrubyECMAScriptThe engine to execute scriptsScript EnginefalseScript EnginetruefalsefalseScript FilePath to script file to execute. Only one of Script File or Script Body may be usedScript FilefalseScript FilefalsefalsetrueScript BodyBody of script to execute. Only one of Script File or Script Body may be usedScript BodyfalseScript BodyfalsefalsefalseModule DirectoryComma-separated list of paths to files and/or directories which contain modules required by the script.Module DirectoryfalseModule Directoryfalsefalsefalsefalse30 secScript EnginepythonScript FileScript Bodyimport json
import java.io
from org.apache.commons.io import IOUtils
# Get flowFile Session
flowFile = session.get()
# Open data.json file and parse json values
filename = flowFile.getAttribute('filename')
filepath = flowFile.getAttribute('absolute.path')
data = json.loads(open(filepath + filename, "r").read())
data_value1 = data["record"]["value1"]
# Calculate arbitrary new value within python
new_value = data_value1 * 100
# Add/Put values to flowFile as new attributes
if (flowFile != None):
flowFile = session.putAttribute(flowFile, "from_python_string", "python string example")
flowFile = session.putAttribute(flowFile, "from_python_number", str(new_value))
session.transfer(flowFile, REL_SUCCESS)
session.commit()
#ZENDModule Directory00 secTIMER_DRIVEN1 secExecuteScriptfalsefailurefalsesuccessorg.apache.nifi.processors.script.ExecuteScript440276ec-0157-1000-0000-00000000000086e85593-0156-1000-0000-0000000000000.00.0WARN1Input DirectoryThe input directory from which to pull filesInput DirectoryfalseInput DirectorytruefalsetrueFile Filter[^\.].*Only files whose names match the given regular expression will be picked upFile FilterfalseFile FiltertruefalsefalsePath FilterWhen Recurse Subdirectories is true, then only subdirectories whose path matches the given regular expression will be scannedPath FilterfalsePath FilterfalsefalsefalseBatch Size10The maximum number of files to pull in each iterationBatch SizefalseBatch SizetruefalsefalseKeep Source FiletruetruefalsefalsefalseIf true, the file is not deleted after it has been copied to the Content Repository; this causes the file to be picked up continually and is useful for testing purposes. If not keeping original NiFi will need write permissions on the directory it is pulling from otherwise it will ignore the file.Keep Source FilefalseKeep Source FiletruefalsefalseRecurse SubdirectoriestruetruefalsefalsetrueIndicates whether or not to pull files from subdirectoriesRecurse SubdirectoriesfalseRecurse SubdirectoriestruefalsefalsePolling Interval0 secIndicates how long to wait before performing a directory listingPolling IntervalfalsePolling IntervaltruefalsefalseIgnore Hidden FilestruetruefalsefalsetrueIndicates whether or not hidden files should be ignoredIgnore Hidden FilesfalseIgnore Hidden FilestruefalsefalseMinimum File Age0 secThe minimum age that a file must be in order to be pulled; any file younger than this amount of time (according to last modification date) will be ignoredMinimum File AgefalseMinimum File AgetruefalsefalseMaximum File AgeThe maximum age that a file must be in order to be pulled; any file older than this amount of time (according to last modification date) will be ignoredMaximum File AgefalseMaximum File AgefalsefalsefalseMinimum File Size0 BThe minimum size that a file must be in order to be pulledMinimum File SizefalseMinimum File SizetruefalsefalseMaximum File SizeThe maximum size that a file can be in order to be pulledMaximum File SizefalseMaximum File Sizefalsefalsefalsefalse30 secInput Directory/tmpFile Filterdata\.jsonPath FilterBatch Size10Keep Source FiletrueRecurse SubdirectoriesfalsePolling Interval0 secIgnore Hidden FilestrueMinimum File Age0 secMaximum File AgeMinimum File Size0 BMaximum File Size010 secTIMER_DRIVEN1 secGetFilefalsesuccessorg.apache.nifi.processors.standard.GetFile45240b89-0157-1000-0000-00000000000086e85593-0156-1000-0000-000000000000674.8499554404895450.89508311281577WARN1Attributes ListComma separated list of attributes to be included in the resulting JSON. If this value is left empty then all existing Attributes will be included. This list of attributes is case sensitive. If an attribute specified in the list is not found it will be be emitted to the resulting JSON with an empty string or NULL value.Attributes ListfalseAttributes ListfalsefalsefalseDestinationflowfile-attributeflowfile-attributeflowfile-contentflowfile-contentflowfile-attributeControl if JSON value is written as a new flowfile attribute 'JSONAttributes' or written in the flowfile content. Writing to flowfile content will overwrite any existing flowfile content.DestinationfalseDestinationtruefalsefalseInclude Core AttributestruetruefalsefalsetrueDetermines if the FlowFile org.apache.nifi.flowfile.attributes.CoreAttributes which are contained in every FlowFile should be included in the final JSON value generated.Include Core AttributesfalseInclude Core AttributestruefalsefalseNull ValuetruetruefalsefalsefalseIf true a non existing or empty attribute will be NULL in the resulting JSON. If false an empty string will be placed in the JSONNull ValuefalseNull Valuetruefalsefalsefalse30 secAttributes Listfilename, from_python_number, from_python_stringDestinationflowfile-attributeInclude Core AttributestrueNull Valuefalse00 secTIMER_DRIVEN1 secAttributesToJSONfalsefailuretruesuccessorg.apache.nifi.processors.standard.AttributesToJSON09/19/2016 23:35:27 EDT