<?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 Trouble setting host from a hostname field in a json datastructure. in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Trouble-setting-host-from-a-hostname-field-in-a-json/m-p/70869#M14424</link>
    <description>&lt;P&gt;Here is our props.conf:&lt;/P&gt;

&lt;P&gt;[aristajson]&lt;BR /&gt;
TIME_PREFIX = hosttime": "&lt;BR /&gt;
MAX_TIMESTAMP_LOOKAHEAD = 22&lt;BR /&gt;
BREAK_ONLY_BEFORE = {{"hostname&lt;BR /&gt;
KV_MODE = json&lt;BR /&gt;
NO_BINARY_CHECK = 1&lt;BR /&gt;
SHOULD_LINEMERGE = false&lt;BR /&gt;
TRUNCATE = 90000&lt;BR /&gt;
pulldown_type = 1&lt;BR /&gt;
TRANSFORMS-larry = aristahostname&lt;/P&gt;

&lt;P&gt;Here is our transforms.conf:&lt;/P&gt;

&lt;P&gt;I've tried it with and without the host in &amp;lt;&amp;gt; . I've also tried to indicate the space after the : with a \s&lt;/P&gt;

&lt;P&gt;[aristahostname]&lt;BR /&gt;
REGEX = "hostname": "(&lt;HOST&gt;[a-zA-Z0-9-_]+)"&lt;BR /&gt;
FORMAT = host::$1&lt;BR /&gt;
DEST_KEY = MetaData:Host&lt;/HOST&gt;&lt;/P&gt;

&lt;P&gt;Here is a snippet of our data that comes in via tcp. There is only one cr at the very end of the event:&lt;/P&gt;

&lt;P&gt;{{"hostname": "nyaristalab-2"}{"hosttime": "2012-09-19 18:58:58"}{"neighbors": {"Ethernet3": {"2": {"sysName": "nyaristalab-1", ..... }&lt;/P&gt;

&lt;P&gt;Here is what it kinda looks like in search. Each of the + are drill downable. So it is all good except for it not using what is in hostname as the host field.&lt;/P&gt;

&lt;P&gt;1   »  9/25/12&lt;BR /&gt;
10:25:59.000 PM &lt;BR /&gt;
{[-]&lt;BR /&gt;
  hostname : "nyaristalab-2",&lt;BR /&gt;
  hosttime : "2012-09-25 22:25:59",&lt;BR /&gt;
  interfaces : {[+]},&lt;BR /&gt;
  neighbors : {[+]},&lt;BR /&gt;
  routing : {[+]}&lt;BR /&gt;
}&lt;/P&gt;

&lt;P&gt;Thanks for looking!&lt;/P&gt;</description>
    <pubDate>Mon, 28 Sep 2020 12:30:13 GMT</pubDate>
    <dc:creator>gryz</dc:creator>
    <dc:date>2020-09-28T12:30:13Z</dc:date>
    <item>
      <title>Trouble setting host from a hostname field in a json datastructure.</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Trouble-setting-host-from-a-hostname-field-in-a-json/m-p/70869#M14424</link>
      <description>&lt;P&gt;Here is our props.conf:&lt;/P&gt;

&lt;P&gt;[aristajson]&lt;BR /&gt;
TIME_PREFIX = hosttime": "&lt;BR /&gt;
MAX_TIMESTAMP_LOOKAHEAD = 22&lt;BR /&gt;
BREAK_ONLY_BEFORE = {{"hostname&lt;BR /&gt;
KV_MODE = json&lt;BR /&gt;
NO_BINARY_CHECK = 1&lt;BR /&gt;
SHOULD_LINEMERGE = false&lt;BR /&gt;
TRUNCATE = 90000&lt;BR /&gt;
pulldown_type = 1&lt;BR /&gt;
TRANSFORMS-larry = aristahostname&lt;/P&gt;

&lt;P&gt;Here is our transforms.conf:&lt;/P&gt;

&lt;P&gt;I've tried it with and without the host in &amp;lt;&amp;gt; . I've also tried to indicate the space after the : with a \s&lt;/P&gt;

&lt;P&gt;[aristahostname]&lt;BR /&gt;
REGEX = "hostname": "(&lt;HOST&gt;[a-zA-Z0-9-_]+)"&lt;BR /&gt;
FORMAT = host::$1&lt;BR /&gt;
DEST_KEY = MetaData:Host&lt;/HOST&gt;&lt;/P&gt;

&lt;P&gt;Here is a snippet of our data that comes in via tcp. There is only one cr at the very end of the event:&lt;/P&gt;

&lt;P&gt;{{"hostname": "nyaristalab-2"}{"hosttime": "2012-09-19 18:58:58"}{"neighbors": {"Ethernet3": {"2": {"sysName": "nyaristalab-1", ..... }&lt;/P&gt;

&lt;P&gt;Here is what it kinda looks like in search. Each of the + are drill downable. So it is all good except for it not using what is in hostname as the host field.&lt;/P&gt;

&lt;P&gt;1   »  9/25/12&lt;BR /&gt;
10:25:59.000 PM &lt;BR /&gt;
{[-]&lt;BR /&gt;
  hostname : "nyaristalab-2",&lt;BR /&gt;
  hosttime : "2012-09-25 22:25:59",&lt;BR /&gt;
  interfaces : {[+]},&lt;BR /&gt;
  neighbors : {[+]},&lt;BR /&gt;
  routing : {[+]}&lt;BR /&gt;
}&lt;/P&gt;

&lt;P&gt;Thanks for looking!&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 12:30:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Trouble-setting-host-from-a-hostname-field-in-a-json/m-p/70869#M14424</guid>
      <dc:creator>gryz</dc:creator>
      <dc:date>2020-09-28T12:30:13Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble setting host from a hostname field in a json datastructure.</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Trouble-setting-host-from-a-hostname-field-in-a-json/m-p/70870#M14425</link>
      <description>&lt;P&gt;In transforms.conf you should not specify &lt;CODE&gt;&amp;lt;host&amp;gt;&lt;/CODE&gt; inside the capturing group. Have you tried;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[aristahome]
REGEX = \"hostname\":\s+\"([^"]+)
FORMAT = host::$1
DEST_KEY = MetaData:Host
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;On a side note, your combination of &lt;CODE&gt;SHOULD_LINEMERGE=false&lt;/CODE&gt; and &lt;CODE&gt;BREAK_ONLY_BEFORE=...&lt;/CODE&gt; is invalid. &lt;CODE&gt;BREAK_ONLY_BEFORE/AFTER, MUST_(NOT_)BREAK_BEFORE/AFTER&lt;/CODE&gt; etc will only work with &lt;CODE&gt;SHOULD_LINEMERGE=true&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;If you have &lt;CODE&gt;SHOULD_LINEMERGE=false&lt;/CODE&gt;, you set your event splitting with &lt;CODE&gt;LINE_BREAKER= regex&lt;/CODE&gt;. The default value for &lt;CODE&gt;LINE_BREAKER&lt;/CODE&gt; is one or more newlines, so for single-line events, you do not need to specify this.&lt;/P&gt;

&lt;P&gt;If your event is multilined, you should probably set &lt;CODE&gt;SHOULD_LINEMERGE = true&lt;/CODE&gt; and &lt;CODE&gt;BREAK_ONLY_BEFORE_DATE = true&lt;/CODE&gt;. If this breaks events in a strange manner, because there are several date/timestamps in the events, you might have to set &lt;CODE&gt;SHOULD_LINEMERGE = false&lt;/CODE&gt;, and use a &lt;CODE&gt;LINE_BREAKER&lt;/CODE&gt; regex like&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;([\r\n]+)\d+/\d+/\d+\s+\d+:\d+:\d+&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;which should match a m/d/y h:m:s style timestamp after a newline&lt;/P&gt;

&lt;P&gt;Hope this helps,&lt;/P&gt;

&lt;P&gt;Kristian&lt;/P&gt;</description>
      <pubDate>Wed, 26 Sep 2012 07:33:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Trouble-setting-host-from-a-hostname-field-in-a-json/m-p/70870#M14425</guid>
      <dc:creator>kristian_kolb</dc:creator>
      <dc:date>2012-09-26T07:33:08Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble setting host from a hostname field in a json datastructure.</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Trouble-setting-host-from-a-hostname-field-in-a-json/m-p/70871#M14426</link>
      <description>&lt;P&gt;Thanks for the clearer explanation of the SHOULD_LINEMERGE and BREAK_ONLY_BEFORE. I got rid of those.&lt;/P&gt;

&lt;P&gt;However the regex suggestions did not work. As I had noted in my original post, I had tried without the &lt;HOST&gt;.&lt;/HOST&gt;&lt;/P&gt;

&lt;P&gt;I checked both your and my regexes with various regex checkers and they both should work.&lt;/P&gt;

&lt;P&gt;Any other ideas?&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 12:31:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Trouble-setting-host-from-a-hostname-field-in-a-json/m-p/70871#M14426</guid>
      <dc:creator>gryz</dc:creator>
      <dc:date>2020-09-28T12:31:51Z</dc:date>
    </item>
  </channel>
</rss>

