<?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: Remove first part of string before creating a JSON source type in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Remove-first-part-of-string-before-creating-a-JSON-source-type/m-p/314265#M58820</link>
    <description>&lt;P&gt;Something like this should work in props.conf to remove the header text:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;SEDCMD-remove_header = s/.*?\{/{/g
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This matches everything up to (and including) the first {.  Then, it replaces it all with just a {. &lt;/P&gt;

&lt;P&gt;Note: this is an index-time extraction.&lt;/P&gt;</description>
    <pubDate>Thu, 05 Apr 2018 14:47:31 GMT</pubDate>
    <dc:creator>jconger</dc:creator>
    <dc:date>2018-04-05T14:47:31Z</dc:date>
    <item>
      <title>Remove first part of string before creating a JSON source type</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Remove-first-part-of-string-before-creating-a-JSON-source-type/m-p/314263#M58818</link>
      <description>&lt;P&gt;HI&lt;/P&gt;

&lt;P&gt;I have used the below answer to get me 95% to a full solution, but i just cant get the last bit.&lt;BR /&gt;
&lt;A href="https://answers.splunk.com/answers/567087/how-to-split-data-into-separate-sourcetypes-with-t.html" target="_blank"&gt;https://answers.splunk.com/answers/567087/how-to-split-data-into-separate-sourcetypes-with-t.html&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;I take in one file with multiple JSON and splits it into multiple source types.&lt;BR /&gt;
However i have a sub issue, one of the source types is like below  Text + JSON trace.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;2018-01-10 15:52:03 [metrics-application-1-thread-1] INFO  METRIC:41 - {"v":"1.0","t":"MTR","ts":"2018-01-10T15:52:03.700Z","h":"mx7654vm","pid"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I am looking to get only the JSON and removing the other data (at the start). &lt;/P&gt;

&lt;P&gt;So, i think i need a SED in the props? but not sure. I am trying not to use a heavy forwarder.&lt;/P&gt;

&lt;P&gt;props.conf&lt;BR /&gt;
[AMBER_RAW]&lt;BR /&gt;
SHOULD_LINEMERGE=false&lt;BR /&gt;
NO_BINARY_CHECK=true&lt;BR /&gt;
TRANSFORMS-sourcetye_routing = AMBER_RAW_json_METRIC&lt;/P&gt;

&lt;P&gt;[AMBER_RAW:METRIC]&lt;BR /&gt;
TIME_FORMAT = %Y-%m-%dT%H:%M:%S.%3N&lt;BR /&gt;
TIME_PREFIX = \"ts\":\"&lt;BR /&gt;
INDEXED_EXTRACTIONS = JSON&lt;BR /&gt;
SEDCMD-REGEX_ONLY = s/^.&lt;EM&gt;({"v".&lt;/EM&gt;).*$/\1/&lt;/P&gt;

&lt;P&gt;Transforms.conf&lt;BR /&gt;
[AMBER_RAW_json_METRIC]&lt;BR /&gt;
DEST_KEY = MetaData:Sourcetype&lt;BR /&gt;
REGEX = {"v":"1.0\"&lt;BR /&gt;
FORMAT = sourcetype::AMBER_RAW:METRIC&lt;/P&gt;

&lt;P&gt;Thanks in Advance&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 18:52:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Remove-first-part-of-string-before-creating-a-JSON-source-type/m-p/314263#M58818</guid>
      <dc:creator>robertlynch2020</dc:creator>
      <dc:date>2020-09-29T18:52:55Z</dc:date>
    </item>
    <item>
      <title>Re: Remove first part of string before creating a JSON source type</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Remove-first-part-of-string-before-creating-a-JSON-source-type/m-p/314264#M58819</link>
      <description>&lt;P&gt;You can try suggestion given here:&lt;/P&gt;

&lt;P&gt;&lt;A href="https://answers.splunk.com/answers/514223/how-can-i-split-and-separate-json-from-a-combined.html"&gt;https://answers.splunk.com/answers/514223/how-can-i-split-and-separate-json-from-a-combined.html&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Apr 2018 13:45:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Remove-first-part-of-string-before-creating-a-JSON-source-type/m-p/314264#M58819</guid>
      <dc:creator>p_gurav</dc:creator>
      <dc:date>2018-04-05T13:45:24Z</dc:date>
    </item>
    <item>
      <title>Re: Remove first part of string before creating a JSON source type</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Remove-first-part-of-string-before-creating-a-JSON-source-type/m-p/314265#M58820</link>
      <description>&lt;P&gt;Something like this should work in props.conf to remove the header text:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;SEDCMD-remove_header = s/.*?\{/{/g
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This matches everything up to (and including) the first {.  Then, it replaces it all with just a {. &lt;/P&gt;

&lt;P&gt;Note: this is an index-time extraction.&lt;/P&gt;</description>
      <pubDate>Thu, 05 Apr 2018 14:47:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Remove-first-part-of-string-before-creating-a-JSON-source-type/m-p/314265#M58820</guid>
      <dc:creator>jconger</dc:creator>
      <dc:date>2018-04-05T14:47:31Z</dc:date>
    </item>
    <item>
      <title>Re: Remove first part of string before creating a JSON source type</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Remove-first-part-of-string-before-creating-a-JSON-source-type/m-p/314266#M58821</link>
      <description>&lt;P&gt;hi&lt;/P&gt;

&lt;P&gt;Thanks for your help here, hower i cant get this to work. &lt;BR /&gt;
I have tried this as the JSON is more complex&lt;/P&gt;

&lt;P&gt;[AMBER_RAW:METRIC]&lt;BR /&gt;
SEDCMD-remove_header = s/.*?{"v/{"v/g&lt;BR /&gt;
TIME_FORMAT = %Y-%m-%dT%H:%M:%S.%3N&lt;BR /&gt;
TIME_PREFIX = \"ts\":\"&lt;BR /&gt;
INDEXED_EXTRACTIONS = JSON&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;2018-01-10 15:52:03 [metrics-application-1-thread-1] INFO  METRIC:41 - {"v":"1.0","t":"MTR","ts":"2018-01-10T15:52:03.700Z","h":"mx7654vm","pid":12483,"src":{"c":"authn-app","d":"auth"},"mtr":{"counters":{"process":{"cpu":{"time_cumulated_s":36},"memory":{"gc":{"ps_marksweep":{"total_duration_ms":814},"ps_scavenge":{"total_duration_ms":539}}}}},"gauges":{"com.murex.serviceframework.rest.datalayer.DataSourceMetrics.datasources.authn-authn-app-1":{"availableConnectionCount":1,"borrowedConnectionCount":0,"currPoolSize":1,"maxPoolSize":50,"poolName":"authn-authn-app-1"},"process":{"cpu":{"percentage":0.04184450581638631},"files":{"open_files":37},"memory":{"jvm":{"heap":{"committed_kb":195072,"used_kb":115080},"nonheap":{"committed_kb":91456,"used_kb":89860}},"rss_kb":32880864,"vsz_kb":2301276}}},"histograms":{},"meters":{},"timers":{"process":{"memory":{"gc":{"ps_marksweep":{"events":{"count":1,"rate_1m":0.0014267037570722622,"rate_5m":0.002038710931305469,"rate_15m":9.431526926661993E-4,"rate_mean":0.006158257067925256},"duration_ms":{"max":620.0,"mean":620.0,"median":620.0,"min":620.0,"percentile_75":620.0,"percentile_95":620.0,"percentile_98":620.0,"percentile_99":620.0,"percentile_999":620.0,"standard_deviation":0.0}},"ps_scavenge":{"events":{"count":32,"rate_1m":0.18094822353052323,"rate_5m":1.237424759817615,"rate_15m":1.7042656064654065,"rate_mean":0.19706273351906517},"duration_ms":{"max":18.0,"mean":9.125,"median":6.5,"min":3.0,"percentile_75":13.0,"percentile_95":18.0,"percentile_98":18.0,"percentile_99":18.0,"percentile_999":18.0,"standard_deviation":5.014495118187132}}}}}}}}
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 29 Sep 2020 18:53:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Remove-first-part-of-string-before-creating-a-JSON-source-type/m-p/314266#M58821</guid>
      <dc:creator>robertlynch2020</dc:creator>
      <dc:date>2020-09-29T18:53:12Z</dc:date>
    </item>
    <item>
      <title>Re: Remove first part of string before creating a JSON source type</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Remove-first-part-of-string-before-creating-a-JSON-source-type/m-p/314267#M58822</link>
      <description>&lt;P&gt;Try this for your SEDCMD.  It anchors the regex to the beginning of the line and sets the replace flag:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;SEDCMD-remove_header = s/^.*?\{/{/1
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 05 Apr 2018 16:34:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Remove-first-part-of-string-before-creating-a-JSON-source-type/m-p/314267#M58822</guid>
      <dc:creator>jconger</dc:creator>
      <dc:date>2018-04-05T16:34:09Z</dc:date>
    </item>
    <item>
      <title>Re: Remove first part of string before creating a JSON source type</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Remove-first-part-of-string-before-creating-a-JSON-source-type/m-p/314268#M58823</link>
      <description>&lt;P&gt;Hi &lt;/P&gt;

&lt;P&gt;Thanks for your help&lt;/P&gt;

&lt;P&gt;I have applied this, but i am still getting the full line into SPLUNK, not sure why as to me it should work.&lt;/P&gt;

&lt;P&gt;[AMBER_RAW:METRIC]&lt;BR /&gt;
SEDCMD-remove_header = s/^.*?{/{/1&lt;BR /&gt;
TIME_FORMAT = %Y-%m-%dT%H:%M:%S.%3N&lt;BR /&gt;
TIME_PREFIX = \"ts\":\"&lt;BR /&gt;
INDEXED_EXTRACTIONS = JSON&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 18:53:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Remove-first-part-of-string-before-creating-a-JSON-source-type/m-p/314268#M58823</guid>
      <dc:creator>robertlynch2020</dc:creator>
      <dc:date>2020-09-29T18:53:15Z</dc:date>
    </item>
    <item>
      <title>Re: Remove first part of string before creating a JSON source type</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Remove-first-part-of-string-before-creating-a-JSON-source-type/m-p/314269#M58824</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;

&lt;P&gt;I can confirm this work if you use the below + take the file in without using a transform&lt;/P&gt;

&lt;P&gt;[AMBER_RAW:METRIC_DIRECT]&lt;BR /&gt;
SEDCMD-remove_header = s/^.*?{/{/1&lt;BR /&gt;
TIME_FORMAT = %Y-%m-%dT%H:%M:%S.%3N&lt;BR /&gt;
TIME_PREFIX = \"ts\":\"&lt;BR /&gt;
INDEXED_EXTRACTIONS = JSON&lt;/P&gt;

&lt;P&gt;However in my case as my source is coming from a transform it does work, so i will post a separate question on this. (Below does work, however the code is exactly the same, so it is a bug or i am missing something)&lt;/P&gt;

&lt;P&gt;transforms.conf&lt;BR /&gt;
[AMBER_RAW_json_METRIC]&lt;BR /&gt;
DEST_KEY = MetaData:Sourcetype&lt;BR /&gt;
REGEX = {"v":"1.0\"&lt;BR /&gt;
FORMAT = sourcetype::AMBER_RAW_METRIC&lt;/P&gt;

&lt;P&gt;props.conf&lt;BR /&gt;
[AMBER_RAW:METRIC]&lt;BR /&gt;
SEDCMD-remove_header = s/^.*?{/{/1&lt;BR /&gt;
TIME_FORMAT = %Y-%m-%dT%H:%M:%S.%3N&lt;BR /&gt;
TIME_PREFIX = \"ts\":\"&lt;BR /&gt;
INDEXED_EXTRACTIONS = JSON&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 18:53:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Remove-first-part-of-string-before-creating-a-JSON-source-type/m-p/314269#M58824</guid>
      <dc:creator>robertlynch2020</dc:creator>
      <dc:date>2020-09-29T18:53:45Z</dc:date>
    </item>
    <item>
      <title>Re: Remove first part of string before creating a JSON source type</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Remove-first-part-of-string-before-creating-a-JSON-source-type/m-p/579164#M102253</link>
      <description>&lt;P&gt;thank you, it helped me a lot&lt;/P&gt;</description>
      <pubDate>Thu, 23 Dec 2021 08:24:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Remove-first-part-of-string-before-creating-a-JSON-source-type/m-p/579164#M102253</guid>
      <dc:creator>ti123</dc:creator>
      <dc:date>2021-12-23T08:24:34Z</dc:date>
    </item>
  </channel>
</rss>

