<?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 Can I parse data prepended to json logs upon logging within splunk so I can search the parsed data? in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Can-I-parse-data-prepended-to-json-logs-upon-logging-within/m-p/591162#M103546</link>
    <description>&lt;P&gt;I'm having some troubles parsing data prepended to json logs. I can do it via search, but I'd like to do it upon logging within splunk so I can search the parsed data. Can you point me in the right direction and if I can do this via the UI or need to go into props.conf manually?&lt;/P&gt;
&lt;P&gt;This is working via search&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;sourcetype="Untangle"| rex "(?&amp;lt;json&amp;gt;\{.+)" | spath input=json&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What I've tried in props.conf&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;[untangle]
EXTRACT-untangle=(?&amp;lt;json&amp;gt;\{.+)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example Log:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Mar 29 01:45:04 _gateway Mar 28 20:45:04 INFO  uvm[0]:  {"timeStamp":"2022-03-28 20:45:04.762","s2pBytes":160,"p2sBytes":65,"sessionId":107845676257000,"endTime":0,"class":"class com.untangle.uvm.app.SessionStatsEvent","c2pBytes":65,"p2cBytes":160}&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 29 Mar 2022 13:11:00 GMT</pubDate>
    <dc:creator>grrtt</dc:creator>
    <dc:date>2022-03-29T13:11:00Z</dc:date>
    <item>
      <title>Can I parse data prepended to json logs upon logging within splunk so I can search the parsed data?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Can-I-parse-data-prepended-to-json-logs-upon-logging-within/m-p/591162#M103546</link>
      <description>&lt;P&gt;I'm having some troubles parsing data prepended to json logs. I can do it via search, but I'd like to do it upon logging within splunk so I can search the parsed data. Can you point me in the right direction and if I can do this via the UI or need to go into props.conf manually?&lt;/P&gt;
&lt;P&gt;This is working via search&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;sourcetype="Untangle"| rex "(?&amp;lt;json&amp;gt;\{.+)" | spath input=json&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What I've tried in props.conf&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;[untangle]
EXTRACT-untangle=(?&amp;lt;json&amp;gt;\{.+)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example Log:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Mar 29 01:45:04 _gateway Mar 28 20:45:04 INFO  uvm[0]:  {"timeStamp":"2022-03-28 20:45:04.762","s2pBytes":160,"p2sBytes":65,"sessionId":107845676257000,"endTime":0,"class":"class com.untangle.uvm.app.SessionStatsEvent","c2pBytes":65,"p2cBytes":160}&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Mar 2022 13:11:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Can-I-parse-data-prepended-to-json-logs-upon-logging-within/m-p/591162#M103546</guid>
      <dc:creator>grrtt</dc:creator>
      <dc:date>2022-03-29T13:11:00Z</dc:date>
    </item>
    <item>
      <title>Re: Troubles with parsing for my first time</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Can-I-parse-data-prepended-to-json-logs-upon-logging-within/m-p/591172#M103548</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/244348"&gt;@grrtt&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried below configuration and it's worked for me.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;EXTRACT-json = (?P&amp;lt;json&amp;gt;\{.+)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2022-03-29 at 10.39.32 AM.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/18802i28E84E21EA4BB74A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Screenshot 2022-03-29 at 10.39.32 AM.png" alt="Screenshot 2022-03-29 at 10.39.32 AM.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you need only json to be indexed and make life easy during searching, you can ignore extra text also.&lt;/P&gt;&lt;P&gt;Try below configuration.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;[My_Sourcetype]
SHOULD_LINEMERGE=true
LINE_BREAKER=([\r\n]+)
NO_BINARY_CHECK=true
SEDCMD-a=s/.*\{/{/g&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2022-03-29 at 10.42.43 AM.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/18803i76298A2E829D8F48/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Screenshot 2022-03-29 at 10.42.43 AM.png" alt="Screenshot 2022-03-29 at 10.42.43 AM.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I hope&amp;nbsp;this will help you.&lt;/P&gt;&lt;P&gt;Thanks&lt;BR /&gt;KV&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;If any of my reply helps you to solve the problem Or gain knowledge, an upvote would be appreciated.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;</description>
      <pubDate>Tue, 29 Mar 2022 05:13:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Can-I-parse-data-prepended-to-json-logs-upon-logging-within/m-p/591172#M103548</guid>
      <dc:creator>kamlesh_vaghela</dc:creator>
      <dc:date>2022-03-29T05:13:34Z</dc:date>
    </item>
    <item>
      <title>Re: Troubles with parsing for my first time</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Can-I-parse-data-prepended-to-json-logs-upon-logging-within/m-p/591176#M103550</link>
      <description>&lt;P&gt;But that's different. You're cutting a part of the event off during ingest. That's modifying the original raw event.&lt;/P&gt;&lt;P&gt;I also looked some time ago to find a way to do auto-kv on part of message (when you have some "header" and after that you get json or xml structure) and didn't find any.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Mar 2022 05:43:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Can-I-parse-data-prepended-to-json-logs-upon-logging-within/m-p/591176#M103550</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2022-03-29T05:43:31Z</dc:date>
    </item>
    <item>
      <title>Re: Troubles with parsing for my first time</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Can-I-parse-data-prepended-to-json-logs-upon-logging-within/m-p/591378#M103581</link>
      <description>&lt;P&gt;I tried&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;EXTRACT-json = (?P&amp;lt;json&amp;gt;\{.+)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This does look to remove the beginning portion of the log as I'd like, but does not parse the json. I was hoping that setting the index extractor to json would parse the remaining json log into fields for me as doing the search with spath does.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="grrtt_0-1648604538581.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/18830i7D425AEC17CABBCE/image-size/medium?v=v2&amp;amp;px=400" role="button" title="grrtt_0-1648604538581.png" alt="grrtt_0-1648604538581.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Mar 2022 03:18:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Can-I-parse-data-prepended-to-json-logs-upon-logging-within/m-p/591378#M103581</guid>
      <dc:creator>grrtt</dc:creator>
      <dc:date>2022-03-30T03:18:19Z</dc:date>
    </item>
    <item>
      <title>Re: Troubles with parsing for my first time</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Can-I-parse-data-prepended-to-json-logs-upon-logging-within/m-p/591390#M103582</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/244348"&gt;@grrtt&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This will gives you required value in json field. Now just add `| spath input=json` to get values from json..&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;KV&lt;/P&gt;</description>
      <pubDate>Wed, 30 Mar 2022 05:41:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Can-I-parse-data-prepended-to-json-logs-upon-logging-within/m-p/591390#M103582</guid>
      <dc:creator>kamlesh_vaghela</dc:creator>
      <dc:date>2022-03-30T05:41:58Z</dc:date>
    </item>
    <item>
      <title>Re: Troubles with parsing for my first time</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Can-I-parse-data-prepended-to-json-logs-upon-logging-within/m-p/591461#M103586</link>
      <description>&lt;P&gt;Well, with splunk you have three different ways to handle json.&lt;/P&gt;&lt;P&gt;1. Indexed-extractions&lt;/P&gt;&lt;P&gt;2. Automatic search-time extractions&lt;/P&gt;&lt;P&gt;3. spath&lt;/P&gt;&lt;P&gt;The first two rely on the event in its entirety being a well-formed json. So they won't work if the event contains additional "headers" or "footers".&lt;/P&gt;&lt;P&gt;If I remember correctly, the indexed extractions are done way before the SEDCMD's in the parsing queue (which makes sense since you can do indexed extractions on Universal Forwarders but can't do SEDCMD's on them), so you can't trim your events with SEDCMD's (or any other transforms) to leave just the json part for indexed extractions. But you can trim your original event and have splunk extract json fields in search-time.&lt;/P&gt;&lt;P&gt;Mind you that the extractions done with each method produce a bit different results in terms of field naming.&lt;/P&gt;&lt;P&gt;So if you have a well-formed json as an input event you can use any of those three options. If you have some extra data in your event you're left with two options:&lt;/P&gt;&lt;P&gt;1. Transform your event prior to indexing so only the well-formed json data is left (effectively losing some part of your original raw data) and use search-time json KV extraction or&lt;/P&gt;&lt;P&gt;2. Leave the event as is and use spath in search time to parse selected part of the event.&lt;/P&gt;&lt;P&gt;Both approaches have their pros and cons so it's up to you.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Mar 2022 09:56:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Can-I-parse-data-prepended-to-json-logs-upon-logging-within/m-p/591461#M103586</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2022-03-30T09:56:38Z</dc:date>
    </item>
    <item>
      <title>Re: Troubles with parsing for my first time</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Can-I-parse-data-prepended-to-json-logs-upon-logging-within/m-p/592027#M103640</link>
      <description>&lt;P&gt;I was able to take some of the input you provided and get into transforms so now it is all parsing and searchable. Thank you for the help&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/149"&gt;@splunk&lt;/a&gt;:~$ cat /opt/splunk/etc/system/local/props.conf&lt;BR /&gt;[Untangle]&lt;BR /&gt;KV_MODE = json&lt;BR /&gt;TRANSFORMS-untangle = Untangle_transform&lt;BR /&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/149"&gt;@splunk&lt;/a&gt;:~$ cat /opt/splunk/etc/system/local/transforms.conf&lt;BR /&gt;[Untangle_transform]&lt;BR /&gt;SOURCE_KEY = _raw&lt;BR /&gt;DEST_KEY = _raw&lt;BR /&gt;REGEX = ({.+})&lt;BR /&gt;FORMAT = $1&lt;/P&gt;</description>
      <pubDate>Fri, 01 Apr 2022 23:45:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Can-I-parse-data-prepended-to-json-logs-upon-logging-within/m-p/592027#M103640</guid>
      <dc:creator>grrtt</dc:creator>
      <dc:date>2022-04-01T23:45:50Z</dc:date>
    </item>
  </channel>
</rss>

