<?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: How to replace hostname with IP in result? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-replace-hostname-with-IP-in-result/m-p/376417#M110516</link>
    <description>&lt;P&gt;Then why did you ask a question that has absolutely nothing to do with what you really are doing and need?&lt;/P&gt;</description>
    <pubDate>Thu, 11 Jul 2019 14:44:26 GMT</pubDate>
    <dc:creator>woodcock</dc:creator>
    <dc:date>2019-07-11T14:44:26Z</dc:date>
    <item>
      <title>How to replace hostname with IP in result?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-replace-hostname-with-IP-in-result/m-p/376410#M110509</link>
      <description>&lt;P&gt;Hi, splunkers:&lt;/P&gt;

&lt;P&gt;I have a puzzle that I need to show host IP in result but not the hostname. E.g. after I ran the search query &lt;CODE&gt;index=* error | stats count by host&lt;/CODE&gt; the result looks like following:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;host    count
aj-ins5577  229
sja_v_jp0_236   4
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But I need to show the IP in the result bu not hostname just like:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;host    count
10.6.10.132    229
10.6.11.10    4
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And I have no lookup table on my server. So is there any method to get ip in splunk?&lt;BR /&gt;
I found a REST way to list all forwarders IP in search like run &lt;CODE&gt;| rest /services/deployment/server/clients | table hostname, ip&lt;/CODE&gt; and the result is:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;hostname    ip
aj-ins5577  10.6.10.132
sja_v_jp0_236   10.6.11.10
sja_b_us0_139   10.6.10.111
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I think maybe I can append a &lt;CODE&gt;output&lt;/CODE&gt; command to export the result then I can use the lookup table to display the IP in result. But there are obviously a disadvantage is there is only the forwarders IP in it but no indexer and search heads in it.&lt;/P&gt;

&lt;P&gt;Is there any good ideas? Thanks!&lt;/P&gt;

&lt;P&gt;Best regards,&lt;BR /&gt;
Shengjyer Ao&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jul 2019 05:18:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-replace-hostname-with-IP-in-result/m-p/376410#M110509</guid>
      <dc:creator>aojie654</dc:creator>
      <dc:date>2019-07-11T05:18:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to replace hostname with IP in result?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-replace-hostname-with-IP-in-result/m-p/376411#M110510</link>
      <description>&lt;P&gt;The easiest way is just to do a DNS lookup by adding this to your search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | lookup dnslookup clientip AS host
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 11 Jul 2019 05:22:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-replace-hostname-with-IP-in-result/m-p/376411#M110510</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-07-11T05:22:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to replace hostname with IP in result?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-replace-hostname-with-IP-in-result/m-p/376412#M110511</link>
      <description>&lt;P&gt;Like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;Your first search here&amp;gt;
| eval which="main"
| appendpipe [|rest/services/deployment/server/clients | table hostname ip | rename hostname As host]
| stats values(*) AS * BY host
| where which=="main"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 11 Jul 2019 05:25:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-replace-hostname-with-IP-in-result/m-p/376412#M110511</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-07-11T05:25:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to replace hostname with IP in result?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-replace-hostname-with-IP-in-result/m-p/376413#M110512</link>
      <description>&lt;P&gt;Hi, woodcock:&lt;/P&gt;

&lt;P&gt;I used the search query following you like this:&lt;BR /&gt;
&lt;CODE&gt;index=_internal error | stats count by host&lt;BR /&gt;
 | appendpipe [|rest/services/deployment/server/clients | table hostname ip | rename hostname As host ]&lt;BR /&gt;
 | stats values(*) AS * BY host&lt;BR /&gt;
 | eval host=if(isnotnull(ip), ip, host)&lt;BR /&gt;
 | fields host count&lt;/CODE&gt;&lt;BR /&gt;
And the result is looks like this:&lt;BR /&gt;
   host count&lt;BR /&gt;
    10.6.10.132 12834&lt;BR /&gt;
    aojie654-splunk-aab4    2806&lt;BR /&gt;
    sja-q-sh0-110   80&lt;BR /&gt;
    10.6.11.10  14&lt;BR /&gt;
    10.6.10.111 10 &lt;BR /&gt;
It looks like the fowarders result is good and the indexers and search head is still display their hostname, any idea to replace their hostname with IP?&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jul 2019 05:55:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-replace-hostname-with-IP-in-result/m-p/376413#M110512</guid>
      <dc:creator>aojie654</dc:creator>
      <dc:date>2019-07-11T05:55:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to replace hostname with IP in result?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-replace-hostname-with-IP-in-result/m-p/376414#M110513</link>
      <description>&lt;P&gt;Like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=_internal error 
| stats count by host 
| append
[|rest/services/deployment/server/clients 
| table hostname ip 
| rename hostname As host] 
| stats values(*) AS * BY host
| eval host=coalesce(ip, host)
| fields host count
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 11 Jul 2019 06:36:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-replace-hostname-with-IP-in-result/m-p/376414#M110513</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-07-11T06:36:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to replace hostname with IP in result?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-replace-hostname-with-IP-in-result/m-p/376415#M110514</link>
      <description>&lt;P&gt;And if you still have problems, SEE MY OTHER ANSWER!&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jul 2019 06:37:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-replace-hostname-with-IP-in-result/m-p/376415#M110514</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-07-11T06:37:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to replace hostname with IP in result?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-replace-hostname-with-IP-in-result/m-p/376416#M110515</link>
      <description>&lt;P&gt;I'll using python to replace hostname with IP and thanks a lot for you help ^_^&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jul 2019 06:44:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-replace-hostname-with-IP-in-result/m-p/376416#M110515</guid>
      <dc:creator>aojie654</dc:creator>
      <dc:date>2019-07-11T06:44:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to replace hostname with IP in result?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-replace-hostname-with-IP-in-result/m-p/376417#M110516</link>
      <description>&lt;P&gt;Then why did you ask a question that has absolutely nothing to do with what you really are doing and need?&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jul 2019 14:44:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-replace-hostname-with-IP-in-result/m-p/376417#M110516</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-07-11T14:44:26Z</dc:date>
    </item>
  </channel>
</rss>

