<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question NiFi Reverse DNS Lookup in Support Questions</title>
    <link>https://community.cloudera.com/t5/Support-Questions/NiFi-Reverse-DNS-Lookup/m-p/369752#M240552</link>
    <description>&lt;P&gt;Is there capability to perform a reverse DNS lookup in NiFi without executing an external script, process, or code? (i.e. without execute code permission)&lt;/P&gt;</description>
    <pubDate>Sat, 29 Apr 2023 21:02:47 GMT</pubDate>
    <dc:creator>plummcrazy</dc:creator>
    <dc:date>2023-04-29T21:02:47Z</dc:date>
    <item>
      <title>NiFi Reverse DNS Lookup</title>
      <link>https://community.cloudera.com/t5/Support-Questions/NiFi-Reverse-DNS-Lookup/m-p/369752#M240552</link>
      <description>&lt;P&gt;Is there capability to perform a reverse DNS lookup in NiFi without executing an external script, process, or code? (i.e. without execute code permission)&lt;/P&gt;</description>
      <pubDate>Sat, 29 Apr 2023 21:02:47 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/NiFi-Reverse-DNS-Lookup/m-p/369752#M240552</guid>
      <dc:creator>plummcrazy</dc:creator>
      <dc:date>2023-04-29T21:02:47Z</dc:date>
    </item>
    <item>
      <title>Re: NiFi Reverse DNS Lookup</title>
      <link>https://community.cloudera.com/t5/Support-Questions/NiFi-Reverse-DNS-Lookup/m-p/369776#M240559</link>
      <description>&lt;P&gt;Welcome to the community&amp;nbsp;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/82455"&gt;@plummcrazy&lt;/a&gt;&amp;nbsp;. Perhaps&amp;nbsp;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/61221"&gt;@dyadav1&lt;/a&gt;&amp;nbsp;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/48783"&gt;@gpinnadhari&lt;/a&gt;&amp;nbsp;or&amp;nbsp;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/35454"&gt;@MattWho&lt;/a&gt;&amp;nbsp;can be of assistance.&lt;/P&gt;</description>
      <pubDate>Mon, 01 May 2023 13:12:16 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/NiFi-Reverse-DNS-Lookup/m-p/369776#M240559</guid>
      <dc:creator>cjervis</dc:creator>
      <dc:date>2023-05-01T13:12:16Z</dc:date>
    </item>
    <item>
      <title>Re: NiFi Reverse DNS Lookup</title>
      <link>https://community.cloudera.com/t5/Support-Questions/NiFi-Reverse-DNS-Lookup/m-p/369800#M240561</link>
      <description>&lt;P&gt;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/82455"&gt;@plummcrazy&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Not sure I understand the use case here.&amp;nbsp;&amp;nbsp;&lt;BR /&gt;You are looking for a way to pass an IP address and get the returned hostname and put it in a FlowFile attribute?&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;The &lt;A href="https://nifi.apache.org/docs/nifi-docs/components/org.apache.nifi/nifi-enrich-nar/1.21.0/org.apache.nifi.processors.enrich.QueryDNS/index.html" target="_self"&gt;QueryDNS&lt;/A&gt;&amp;nbsp;does not require any additional "special permissions" to use it. I have never tried using this processor myself.&lt;BR /&gt;&lt;BR /&gt;There are no other DNS specific processor designed to perform such task, you could need utilize the executeStreamCommand, ExecuteScript, or ExecuteGroovyScript processors to execute the system level command to return your reverse DNS lookup results.&lt;BR /&gt;Execute based processor will require an additional layer of authorization since the processor is executed like every other processor as the NiFi service user (this means that ANY access the NiFi service user has will be accessible by the NiFi dataflow using these processors).&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="batang,apple gothic"&gt;If you found that the provided solution(s) assisted you with your query, please take a moment to login and click&lt;/FONT&gt;&amp;nbsp;&lt;FONT face="arial black,avant garde" color="#FF0000"&gt;Accept as Solution&amp;nbsp;&lt;/FONT&gt;&lt;FONT face="batang,apple gothic" color="#000000"&gt;below each response that helped.&lt;BR /&gt;&lt;BR /&gt;Thank you,&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="batang,apple gothic" color="#000000"&gt;Matt&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 01 May 2023 17:29:23 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/NiFi-Reverse-DNS-Lookup/m-p/369800#M240561</guid>
      <dc:creator>MattWho</dc:creator>
      <dc:date>2023-05-01T17:29:23Z</dc:date>
    </item>
    <item>
      <title>Re: NiFi Reverse DNS Lookup</title>
      <link>https://community.cloudera.com/t5/Support-Questions/NiFi-Reverse-DNS-Lookup/m-p/370246#M240663</link>
      <description>&lt;P&gt;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/82455"&gt;@plummcrazy&lt;/a&gt;,&amp;nbsp;Has the reply helped resolve your issue? If so, please mark the appropriate reply as the solution, as it will make it easier for others to find the answer in the future.&lt;/P&gt;</description>
      <pubDate>Mon, 08 May 2023 10:58:28 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/NiFi-Reverse-DNS-Lookup/m-p/370246#M240663</guid>
      <dc:creator>VidyaSargur</dc:creator>
      <dc:date>2023-05-08T10:58:28Z</dc:date>
    </item>
    <item>
      <title>Re: NiFi Reverse DNS Lookup</title>
      <link>https://community.cloudera.com/t5/Support-Questions/NiFi-Reverse-DNS-Lookup/m-p/372634#M241324</link>
      <description>&lt;P&gt;Would a ScriptedProcessor within NiFi, not having to call an external script but within NiFi be adequate?&lt;/P&gt;</description>
      <pubDate>Wed, 14 Jun 2023 21:45:57 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/NiFi-Reverse-DNS-Lookup/m-p/372634#M241324</guid>
      <dc:creator>joseomjr</dc:creator>
      <dc:date>2023-06-14T21:45:57Z</dc:date>
    </item>
    <item>
      <title>Re: NiFi Reverse DNS Lookup</title>
      <link>https://community.cloudera.com/t5/Support-Questions/NiFi-Reverse-DNS-Lookup/m-p/372732#M241362</link>
      <description>&lt;P&gt;This simple InvokeScriptedProcessor will look for a FlowFile attribute called "ip_address" and will attempt the reverse lookup and create a new attribute called "host_name" with the resolved value.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="java"&gt;import groovy.json.JsonOutput
import groovy.json.JsonSlurper
import java.net.InetAddress
import java.net.UnknownHostException
import java.nio.charset.StandardCharsets
import org.apache.commons.io.IOUtils

class GroovyProcessor implements Processor {
    PropertyDescriptor BATCH_SIZE = new PropertyDescriptor.Builder()
        .name("BATCH_SIZE")
        .displayName("Batch Size")
        .description("The number of incoming FlowFiles to process in a single execution of this processor.")
        .required(true)
        .defaultValue("1000")
        .addValidator(StandardValidators.POSITIVE_INTEGER_VALIDATOR)
        .build()

    Relationship REL_SUCCESS = new Relationship.Builder()
        .name("success")
        .description('FlowFiles that were successfully processed are routed here')
        .build()

    Relationship REL_FAILURE = new Relationship.Builder()
        .name("failure")
        .description('FlowFiles that were not successfully processed are routed here')
        .build()
    
    ComponentLog log 
    
    void initialize(ProcessorInitializationContext context) { log = context.logger }
    Set&amp;lt;Relationship&amp;gt; getRelationships() { return [REL_FAILURE, REL_SUCCESS] as Set }
    Collection&amp;lt;ValidationResult&amp;gt; validate(ValidationContext context) { null }
    PropertyDescriptor getPropertyDescriptor(String name) { null }
    void onPropertyModified(PropertyDescriptor descriptor, String oldValue, String newValue) { }
    List&amp;lt;PropertyDescriptor&amp;gt; getPropertyDescriptors() { Collections.unmodifiableList([BATCH_SIZE]) as List&amp;lt;PropertyDescriptor&amp;gt; }
    String getIdentifier() { null }

    JsonSlurper jsonSlurper = new JsonSlurper()
    JsonOutput jsonOutput = new JsonOutput()

    def reverseDnsLookup(String ipAddress) {
        try {
            InetAddress inetAddress = InetAddress.getByName(ipAddress)
            String hostName = inetAddress.getCanonicalHostName()
            return hostName
        } catch (UnknownHostException e) {
            return "Unknown"
        }
    }
    
    void onTrigger(ProcessContext context, ProcessSessionFactory sessionFactory) throws ProcessException {
        ProcessSession session = sessionFactory.createSession()
        try {
            List&amp;lt;FlowFile&amp;gt; flowFiles = session.get(context.getProperty(BATCH_SIZE).asInteger())
            if (!flowFiles) return

            Map customAttributes = [:]
            flowFiles.each { flowFile -&amp;gt;
                String ipAddress = flowFile.getAttribute("ip_address")
                if (ipAddress) {
                    String hostName = reverseDnsLookup(ipAddress)
                    customAttributes["host_name"] = hostName
                    flowFile = session.putAllAttributes(flowFile, customAttributes)
                }
                session.transfer(flowFile, REL_SUCCESS)
            }
            session.commit()
        } catch (final Throwable t) {
            log.error('{} failed to process due to {}; rolling back session', [this, t] as Object[])
            session.rollback(true)
            throw t
        }
    }
}

processor = new GroovyProcessor()&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 15 Jun 2023 18:41:12 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/NiFi-Reverse-DNS-Lookup/m-p/372732#M241362</guid>
      <dc:creator>joseomjr</dc:creator>
      <dc:date>2023-06-15T18:41:12Z</dc:date>
    </item>
  </channel>
</rss>

