<?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 Help with Advanced Source Type in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Help-with-Advanced-Source-Type/m-p/486798#M83345</link>
    <description>&lt;P&gt;I'm trying to create a custom source type which is reading a TSV log file and the 3 column in the file is a JSON payload wrapped in quotes. I can't figure out how to get the source type to parse out the 3 column in a JSON format on splunk. Here's an example of a line entry below.&lt;/P&gt;

&lt;P&gt;6680    "2020-03-06 13:50:13.254"   "{"date":"3/6/2020 1:50:13 PM","received":"from FooServer (Unknown [172.20.36.5]) by smtp-dev.foo.com with ESMTP ; Fri, 6 Mar 2020 13:50:13 -0500","message-id":"&lt;A href="mailto:id@message.com"&gt;id@message.com&lt;/A&gt;","from":"&lt;A href="mailto:foo@thisMachine.com"&gt;foo@thisMachine.com&lt;/A&gt;","recipients":"&lt;A href="mailto:John.Smith@example.com"&gt;John.Smith@example.com&lt;/A&gt;","cc":"","subject":"Test Email"}"&lt;/P&gt;

&lt;P&gt;Any advice would be helpful, thank you.&lt;/P&gt;</description>
    <pubDate>Fri, 06 Mar 2020 18:53:23 GMT</pubDate>
    <dc:creator>jaredneedell</dc:creator>
    <dc:date>2020-03-06T18:53:23Z</dc:date>
    <item>
      <title>Help with Advanced Source Type</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Help-with-Advanced-Source-Type/m-p/486798#M83345</link>
      <description>&lt;P&gt;I'm trying to create a custom source type which is reading a TSV log file and the 3 column in the file is a JSON payload wrapped in quotes. I can't figure out how to get the source type to parse out the 3 column in a JSON format on splunk. Here's an example of a line entry below.&lt;/P&gt;

&lt;P&gt;6680    "2020-03-06 13:50:13.254"   "{"date":"3/6/2020 1:50:13 PM","received":"from FooServer (Unknown [172.20.36.5]) by smtp-dev.foo.com with ESMTP ; Fri, 6 Mar 2020 13:50:13 -0500","message-id":"&lt;A href="mailto:id@message.com"&gt;id@message.com&lt;/A&gt;","from":"&lt;A href="mailto:foo@thisMachine.com"&gt;foo@thisMachine.com&lt;/A&gt;","recipients":"&lt;A href="mailto:John.Smith@example.com"&gt;John.Smith@example.com&lt;/A&gt;","cc":"","subject":"Test Email"}"&lt;/P&gt;

&lt;P&gt;Any advice would be helpful, thank you.&lt;/P&gt;</description>
      <pubDate>Fri, 06 Mar 2020 18:53:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Help-with-Advanced-Source-Type/m-p/486798#M83345</guid>
      <dc:creator>jaredneedell</dc:creator>
      <dc:date>2020-03-06T18:53:23Z</dc:date>
    </item>
    <item>
      <title>Re: Help with Advanced Source Type</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Help-with-Advanced-Source-Type/m-p/486799#M83346</link>
      <description>&lt;P&gt;Add below content to transforms.conf. This will extract key value pair and index them.&lt;/P&gt;

&lt;P&gt;transforms.conf.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[extract_json_fields]
REGEX = \"([\w-]+)\":\"([^"]*)\"
FORMAT = $1::$2
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Refer &lt;STRONG&gt;extract_json_fields&lt;/STRONG&gt; in props.conf under sourcetype stanza.&lt;/P&gt;

&lt;P&gt;props.conf&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[sourcetype_name]
TRANSFORMS-extract_fields = extract_json_fields
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 30 Sep 2020 04:30:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Help-with-Advanced-Source-Type/m-p/486799#M83346</guid>
      <dc:creator>manjunathmeti</dc:creator>
      <dc:date>2020-09-30T04:30:48Z</dc:date>
    </item>
    <item>
      <title>Re: Help with Advanced Source Type</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Help-with-Advanced-Source-Type/m-p/486800#M83347</link>
      <description>&lt;P&gt;How would I go about this if I am using the UI to create the Source Type?&lt;/P&gt;</description>
      <pubDate>Fri, 06 Mar 2020 19:53:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Help-with-Advanced-Source-Type/m-p/486800#M83347</guid>
      <dc:creator>jaredneedell</dc:creator>
      <dc:date>2020-03-06T19:53:28Z</dc:date>
    </item>
    <item>
      <title>Re: Help with Advanced Source Type</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Help-with-Advanced-Source-Type/m-p/486801#M83348</link>
      <description>&lt;P&gt;Add new setting &lt;STRONG&gt;EXTRACT-fields&lt;/STRONG&gt; and put this below regex. Save and search sourcetype.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;"date":"(?&amp;lt;date&amp;gt;[^\"]*)","received":"(?&amp;lt;received&amp;gt;[^\"]*)","message-id":"(?&amp;lt;messageid&amp;gt;[^\"]*)","from":"(?&amp;lt;from&amp;gt;[^\"]*)","recipients":"(?&amp;lt;recipients&amp;gt;[^\"]*)","cc":"(?&amp;lt;cc&amp;gt;[^\"]*)","subject":"(?&amp;lt;subject&amp;gt;[^\"]*)"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 06 Mar 2020 20:18:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Help-with-Advanced-Source-Type/m-p/486801#M83348</guid>
      <dc:creator>manjunathmeti</dc:creator>
      <dc:date>2020-03-06T20:18:28Z</dc:date>
    </item>
    <item>
      <title>Re: Help with Advanced Source Type</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Help-with-Advanced-Source-Type/m-p/486802#M83349</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval _raw="6680 \"2020-03-06 13:50:13.254\" \"{\"date\":\"3/6/2020 1:50:13 PM\",\"received\":\"from FooServer (Unknown [172.20.36.5]) by smtp-dev.foo.com with ESMTP ; Fri, 6 Mar 2020 13:50:13 -0500\",\"message-id\":\" \",\"from\":\" foo@thisMachine.com\",\"recipients\":\" John.Smith@example.com\",\"cc\":\"\",\"subject\":\"Test Email\"}\"" 
| rex mode=sed "s/^.*(?={)(.*)\"/\1/g" 
| spath
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;this is OK.&lt;/P&gt;

&lt;P&gt;props.conf  or Create source types &amp;gt;&amp;gt; advanced&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[your sourcetype]
DATETIME_CONFIG = %F %T.%3Q
SEDCMD-trim_json = s/^.*(?={)(.*)\"/\1/g
KV_MODE = json
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 06 Mar 2020 22:41:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Help-with-Advanced-Source-Type/m-p/486802#M83349</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-03-06T22:41:27Z</dc:date>
    </item>
    <item>
      <title>Re: Help with Advanced Source Type</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Help-with-Advanced-Source-Type/m-p/486803#M83350</link>
      <description>&lt;P&gt;The documentation is EXTREMELY misleading in this regard.  There is no such thing as &lt;CODE&gt;creating a sourcetype&lt;/CODE&gt;.  All possible &lt;CODE&gt;sourcetype&lt;/CODE&gt; values "already exist" in any meaningful sense of the word &lt;CODE&gt;exist&lt;/CODE&gt;.  There is NOTHING that must be done to &lt;CODE&gt;create&lt;/CODE&gt; one before using it.  Just use it and &lt;EM&gt;poof&lt;/EM&gt; it now exists and works.&lt;/P&gt;

&lt;P&gt;This is not the right way to do it, however, assuming there is no nesting and no arrays in your JSON, you can get away with doing this:&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;Settings&lt;/CODE&gt; -&amp;gt; &lt;CODE&gt;Fields&lt;/CODE&gt; -&amp;gt; &lt;CODE&gt;Field Transformations&lt;/CODE&gt; -&amp;gt; &lt;CODE&gt;New Field Transformation&lt;/CODE&gt; then&lt;BR /&gt;
Set &lt;CODE&gt;Name&lt;/CODE&gt; to something like &lt;CODE&gt;&amp;lt;YourSourcetype&amp;gt;_JSONpayload&lt;/CODE&gt;.&lt;BR /&gt;
Set &lt;CODE&gt;Type&lt;/CODE&gt; to &lt;CODE&gt;regex-based&lt;/CODE&gt;.&lt;BR /&gt;
Set &lt;CODE&gt;Regular expression&lt;/CODE&gt; to &lt;CODE&gt;(?&amp;lt;=[,{])"([^"]+)":"([^"]*)&lt;/CODE&gt;.&lt;BR /&gt;
Set &lt;CODE&gt;Format&lt;/CODE&gt; to &lt;CODE&gt;$1::$2&lt;/CODE&gt;.&lt;BR /&gt;
Set &lt;CODE&gt;Create multivalued fields&lt;/CODE&gt; to &lt;CODE&gt;checked&lt;/CODE&gt; (e.g. &lt;CODE&gt;true&lt;/CODE&gt; / &lt;CODE&gt;yes&lt;/CODE&gt; ).&lt;BR /&gt;
Click green &lt;CODE&gt;Save&lt;/CODE&gt; button.&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;Settings&lt;/CODE&gt; -&amp;gt; &lt;CODE&gt;Fields&lt;/CODE&gt; -&amp;gt; &lt;CODE&gt;Field Extractions&lt;/CODE&gt; -&amp;gt; &lt;CODE&gt;New Field Extraction&lt;/CODE&gt; then:&lt;BR /&gt;
Set &lt;CODE&gt;Name&lt;/CODE&gt; to &lt;CODE&gt;&amp;lt;YourSourcetype&amp;gt;_JSONpayload&lt;/CODE&gt;.&lt;BR /&gt;
Set &lt;CODE&gt;Apply to&lt;/CODE&gt; to &lt;CODE&gt;Sourcetype&lt;/CODE&gt; + &lt;CODE&gt;named&lt;/CODE&gt; = &lt;CODE&gt;&amp;lt;YourSourcetype&amp;gt;&lt;/CODE&gt;.&lt;BR /&gt;
Set &lt;CODE&gt;Type&lt;/CODE&gt; to &lt;CODE&gt;Uses transform&lt;/CODE&gt;.&lt;BR /&gt;
Set &lt;CODE&gt;Extraction/Transform&lt;/CODE&gt; to &lt;CODE&gt;&amp;lt;YourSourcetype&amp;gt;_JSONpayload&lt;/CODE&gt;.&lt;BR /&gt;
Click green &lt;CODE&gt;Save&lt;/CODE&gt; button.&lt;/P&gt;</description>
      <pubDate>Fri, 06 Mar 2020 23:31:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Help-with-Advanced-Source-Type/m-p/486803#M83350</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2020-03-06T23:31:09Z</dc:date>
    </item>
  </channel>
</rss>

