You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@nifi.apache.org by Madhukar Thota <ma...@gmail.com> on 2016/02/18 05:15:54 UTC

Execute script - python example

Hi

I am looking for an example in python to convert a new field based on
attribute value.

Let say syslog.facilty holds value 23, based on the value i want to create
new field with text value like syslog.facility_label=LOCAL7

If this transformation possible with existing processors, please provide an
example or direct me to right processor.

Thanks in Advance,

Re: Execute script - python example

Posted by Conrad Crampton <co...@SecData.com>.
Hi,
UpdateAttributes is (probably) the processor you need. Using ExpressionLanguage you can set a new attribute based on the value of another. Might get quite long though if you have a number of lookups to do.
On a side note, if you have the value that you want to map to a label (23 -> LOCAL7 in your example), and it is in the FlowFile content, then you can use ReplaceTextWithMapping to use a regexp and lookup to a mapping file (on the local drive – in the format of

value[tab]replacement\n

But this replaces the original value in and not adds to it in the FlowFile content, not attributes. Only including this as I wanted to do a similar thing but the lookups were from FlowFile not attributes.

HTH,
Conrad

From: Madhukar Thota <ma...@gmail.com>>
Reply-To: "users@nifi.apache.org<ma...@nifi.apache.org>" <us...@nifi.apache.org>>
Date: Thursday, 18 February 2016 at 04:15
To: "users@nifi.apache.org<ma...@nifi.apache.org>" <us...@nifi.apache.org>>
Subject: Execute script - python example

Hi

I am looking for an example in python to convert a new field based on attribute value.

Let say syslog.facilty holds value 23, based on the value i want to create new field with text value like syslog.facility_label=LOCAL7

If this transformation possible with existing processors, please provide an example or direct me to right processor.

Thanks in Advance,



***This email originated outside SecureData***

Click here<https://www.mailcontrol.com/sr/MZbqvYs5QwJvpeaetUwhCQ==> to report this email as spam.


SecureData, combating cyber threats
______________________________________________________________________ 
The information contained in this message or any of its attachments may be privileged and confidential and intended for the exclusive use of the intended recipient. If you are not the intended recipient any disclosure, reproduction, distribution or other dissemination or use of this communications is strictly prohibited. The views expressed in this email are those of the individual and not necessarily of SecureData Europe Ltd. Any prices quoted are only valid if followed up by a formal written quote.

SecureData Europe Limited. Registered in England & Wales 04365896. Registered Address: SecureData House, Hermitage Court, Hermitage Lane, Maidstone, Kent, ME16 9NT