<?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: Duplicate host field after indexing JSON event in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Duplicate-host-field-after-indexing-JSON-event/m-p/292473#M55713</link>
    <description>&lt;P&gt;I'd modify the source at index time to contain &lt;CODE&gt;hostname&lt;/CODE&gt; instead of &lt;CODE&gt;host&lt;/CODE&gt; so that there would be no conflict. That will happen so that any search time field extractions will keep the host names separate. It is hard to deal with the host having two values if it does automatic field extractions.&lt;/P&gt;

&lt;P&gt;The other thing that you &lt;EM&gt;could&lt;/EM&gt; do at search time it use a &lt;CODE&gt;rex&lt;/CODE&gt; to create a &lt;CODE&gt;hostname&lt;/CODE&gt; field, then eliminate the extra &lt;CODE&gt;host&lt;/CODE&gt; value that matches the &lt;CODE&gt;hostname&lt;/CODE&gt; in the event, something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval host="orighost,myHostname" 
| makemv host delim="," 
| eval _raw="{\"_check_command\":\"hostalive\",_execution_time\":4.0079541206359863281,**,\"host\":\"myHostname\",**\"short_message\":\"PING OK\",\"timestamp\":1502959941.4374480247}" 
| rex "\"host\":\"(?P&amp;lt;hostname&amp;gt;[^\"]*)\"" 
| mvexpand host 
| where host!=hostname
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The first four lines are just setting up the data, the last three are doing the work of setting the &lt;CODE&gt;host&lt;/CODE&gt; and &lt;CODE&gt;hostname&lt;/CODE&gt; properly.&lt;/P&gt;</description>
    <pubDate>Thu, 17 Aug 2017 15:25:18 GMT</pubDate>
    <dc:creator>cpetterborg</dc:creator>
    <dc:date>2017-08-17T15:25:18Z</dc:date>
    <item>
      <title>Duplicate host field after indexing JSON event</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Duplicate-host-field-after-indexing-JSON-event/m-p/292472#M55712</link>
      <description>&lt;P&gt;We are indexing a Logfile that has the following JSON format:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;{"_check_command":"hostalive",_execution_time":4.0079541206359863281,**,"host":"myHostname",**"short_message":"PING OK","timestamp":1502959941.4374480247}
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The Splunkforwarder is on the same server with the same "host" entry in the &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;inputs.conf 
[default] 
host = myHostname
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;When i'm searching in Splunk after the events from the Logfile, i have the problem that every Events has 2 Host fields, that one that is extracted from the JSON and that from the Forwarder. The counter is also doubled)&lt;/P&gt;

&lt;P&gt;My first opinion was i cut out the host field in the JSON but it's not my prefered one. &lt;/P&gt;

&lt;P&gt;Any ideas?&lt;/P&gt;

&lt;P&gt;EDIT: &lt;BR /&gt;
I added following line to the props.conf:&lt;BR /&gt;
SEDCMD = s/\"host\"/\"hostname\"/&lt;/P&gt;</description>
      <pubDate>Thu, 17 Aug 2017 09:01:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Duplicate-host-field-after-indexing-JSON-event/m-p/292472#M55712</guid>
      <dc:creator>ColinCH</dc:creator>
      <dc:date>2017-08-17T09:01:19Z</dc:date>
    </item>
    <item>
      <title>Re: Duplicate host field after indexing JSON event</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Duplicate-host-field-after-indexing-JSON-event/m-p/292473#M55713</link>
      <description>&lt;P&gt;I'd modify the source at index time to contain &lt;CODE&gt;hostname&lt;/CODE&gt; instead of &lt;CODE&gt;host&lt;/CODE&gt; so that there would be no conflict. That will happen so that any search time field extractions will keep the host names separate. It is hard to deal with the host having two values if it does automatic field extractions.&lt;/P&gt;

&lt;P&gt;The other thing that you &lt;EM&gt;could&lt;/EM&gt; do at search time it use a &lt;CODE&gt;rex&lt;/CODE&gt; to create a &lt;CODE&gt;hostname&lt;/CODE&gt; field, then eliminate the extra &lt;CODE&gt;host&lt;/CODE&gt; value that matches the &lt;CODE&gt;hostname&lt;/CODE&gt; in the event, something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval host="orighost,myHostname" 
| makemv host delim="," 
| eval _raw="{\"_check_command\":\"hostalive\",_execution_time\":4.0079541206359863281,**,\"host\":\"myHostname\",**\"short_message\":\"PING OK\",\"timestamp\":1502959941.4374480247}" 
| rex "\"host\":\"(?P&amp;lt;hostname&amp;gt;[^\"]*)\"" 
| mvexpand host 
| where host!=hostname
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The first four lines are just setting up the data, the last three are doing the work of setting the &lt;CODE&gt;host&lt;/CODE&gt; and &lt;CODE&gt;hostname&lt;/CODE&gt; properly.&lt;/P&gt;</description>
      <pubDate>Thu, 17 Aug 2017 15:25:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Duplicate-host-field-after-indexing-JSON-event/m-p/292473#M55713</guid>
      <dc:creator>cpetterborg</dc:creator>
      <dc:date>2017-08-17T15:25:18Z</dc:date>
    </item>
    <item>
      <title>Re: Duplicate host field after indexing JSON event</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Duplicate-host-field-after-indexing-JSON-event/m-p/292474#M55714</link>
      <description>&lt;P&gt;ahh, thank you. I did not think of that. I will SED the host field to hostname, so i don't need do delete it!&lt;/P&gt;</description>
      <pubDate>Fri, 18 Aug 2017 06:28:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Duplicate-host-field-after-indexing-JSON-event/m-p/292474#M55714</guid>
      <dc:creator>ColinCH</dc:creator>
      <dc:date>2017-08-18T06:28:11Z</dc:date>
    </item>
    <item>
      <title>Re: Duplicate host field after indexing JSON event</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Duplicate-host-field-after-indexing-JSON-event/m-p/292475#M55715</link>
      <description>&lt;P&gt;If this works for you, please accept the answer so that future viewers will know that it is a valid answer to your question. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; Thanks!&lt;/P&gt;</description>
      <pubDate>Fri, 18 Aug 2017 17:41:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Duplicate-host-field-after-indexing-JSON-event/m-p/292475#M55715</guid>
      <dc:creator>cpetterborg</dc:creator>
      <dc:date>2017-08-18T17:41:33Z</dc:date>
    </item>
  </channel>
</rss>

