<?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>topic Re: Reverse-order a DNS at search time in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Reverse-order-a-DNS-at-search-time/m-p/149354#M30422</link>
    <description>&lt;P&gt;I've not written it yet, but my plan to handle this is to write a dynamic lookup that does the equivalent of this (in perl):&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;$sortable_name=$hostname;
$sortable_name=~s{(\d+)}{sprintf "%09d", $1}g;
$sortable_name=join('.', reverse(split(/\./, $sortable_name)));
return $sortable_name;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;So given a field with the hostname, it'd return a new field with a "sortable name."  You could sort on that field, and then remove it from the results.&lt;/P&gt;</description>
    <pubDate>Thu, 06 Mar 2014 19:01:34 GMT</pubDate>
    <dc:creator>yplambert</dc:creator>
    <dc:date>2014-03-06T19:01:34Z</dc:date>
    <item>
      <title>Reverse-order a DNS at search time</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Reverse-order-a-DNS-at-search-time/m-p/149353#M30421</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;

&lt;P&gt;In certain search, Splunk returns DNS hostnames, for example:&lt;BR /&gt;
a.monetate.net.akadns.net&lt;BR /&gt;
evsecure-ocsp.verisign.com&lt;/P&gt;

&lt;P&gt;To facilitate sorting, I'd like to have the names displayed in reverse order across the dots, e.g.:&lt;BR /&gt;
net.akadns.net.monetate.a&lt;BR /&gt;
com.verisign.evsecure-ocsp&lt;/P&gt;

&lt;P&gt;I've found some examples that suggest how to change word order but Splunk rejects it during search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=dns | rex field=domain mode=sed "s/\n/!G;s/\(.\)\(.*\n\)/&amp;amp;\2\1/;//D;s/.//"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Yields: Error in 'rex' command: Failed to initialize sed. Invalid option string: (.)(.*\n)/&amp;amp;\2\1/;//D;s/.// &lt;/P&gt;

&lt;P&gt;Ideas?&lt;/P&gt;

&lt;P&gt;folkstalk [dot] com/2011/12/methods-to-reverse-string-using-unix.html&lt;BR /&gt;
programmingforums [dot] org/post188712.html&lt;/P&gt;</description>
      <pubDate>Thu, 13 Feb 2014 17:21:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Reverse-order-a-DNS-at-search-time/m-p/149353#M30421</guid>
      <dc:creator>ahamilton</dc:creator>
      <dc:date>2014-02-13T17:21:42Z</dc:date>
    </item>
    <item>
      <title>Re: Reverse-order a DNS at search time</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Reverse-order-a-DNS-at-search-time/m-p/149354#M30422</link>
      <description>&lt;P&gt;I've not written it yet, but my plan to handle this is to write a dynamic lookup that does the equivalent of this (in perl):&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;$sortable_name=$hostname;
$sortable_name=~s{(\d+)}{sprintf "%09d", $1}g;
$sortable_name=join('.', reverse(split(/\./, $sortable_name)));
return $sortable_name;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;So given a field with the hostname, it'd return a new field with a "sortable name."  You could sort on that field, and then remove it from the results.&lt;/P&gt;</description>
      <pubDate>Thu, 06 Mar 2014 19:01:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Reverse-order-a-DNS-at-search-time/m-p/149354#M30422</guid>
      <dc:creator>yplambert</dc:creator>
      <dc:date>2014-03-06T19:01:34Z</dc:date>
    </item>
    <item>
      <title>Re: Reverse-order a DNS at search time</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Reverse-order-a-DNS-at-search-time/m-p/692248#M115095</link>
      <description>&lt;P&gt;Starting with a field: domain, you can do the following:&lt;/P&gt;&lt;PRE&gt;| eval domain_reversed=split(domain,".")&lt;BR /&gt;| eval domain_reversed=mvreverse(domain_reversed)&lt;BR /&gt;| eval domain_reversed=mvjoin(domain_reversed,".")&lt;BR /&gt;| sort domain_reversed&lt;/PRE&gt;&lt;P&gt;This splits the field into a multivalued field called domain_reversed with the values separated by the dot, then reverses the order of the resulting multivalued field, then joins the results back together and sorts on the resulting field.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Jul 2024 20:35:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Reverse-order-a-DNS-at-search-time/m-p/692248#M115095</guid>
      <dc:creator>matthewg</dc:creator>
      <dc:date>2024-07-02T20:35:30Z</dc:date>
    </item>
  </channel>
</rss>

