<?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: replace is giving empty string in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Why-is-replace-giving-empty-string/m-p/645140#M223398</link>
    <description>&lt;P&gt;&lt;SPAN&gt;multivalue field as if&amp;nbsp; 'properties.path' could contains more than one value?&amp;nbsp;No,&amp;nbsp;&lt;/SPAN&gt;&amp;nbsp;&lt;SPAN&gt;'properties.path'&amp;nbsp;&lt;/SPAN&gt; always only have 1 value (1 string). And this field always exist in all logs.&lt;BR /&gt;&lt;BR /&gt;However, your&amp;nbsp;mvmap is able to make 'properties.path' work with replace(). Although I can't quite explain it, this is what I want to achieve.&amp;nbsp; Thank you.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="YatMan_0-1685472159445.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/25617i567885F897F24CD1/image-size/medium?v=v2&amp;amp;px=400" role="button" title="YatMan_0-1685472159445.png" alt="YatMan_0-1685472159445.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 30 May 2023 18:45:23 GMT</pubDate>
    <dc:creator>YatMan</dc:creator>
    <dc:date>2023-05-30T18:45:23Z</dc:date>
    <item>
      <title>Why is replace giving empty string?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-replace-giving-empty-string/m-p/644795#M223282</link>
      <description>&lt;P&gt;Sample event&lt;BR /&gt;&lt;BR /&gt;&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;{ 
    durationMs:  83  
    properties: {
     request-id: 1c910793-8be4-4850-83d5-f360b4b05478
     method: GET
     path: /scenarios/636d40506930b10b8f082f27
    }
}&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;I am trying to create a table of the counts by properties.path&lt;BR /&gt;I want to combine some of the rows into single path /scenarios/{id}&lt;BR /&gt;But my replace('properties.path') is giving empty value as seen in column values(path), please help me take a look why replace doesn't work here.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="YatMan_0-1685142881151.png" style="width: 755px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/25575i153C1F5F416D2229/image-dimensions/755x214?v=v2" width="755" height="214" role="button" title="YatMan_0-1685142881151.png" alt="YatMan_0-1685142881151.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 30 May 2023 03:32:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-replace-giving-empty-string/m-p/644795#M223282</guid>
      <dc:creator>YatMan</dc:creator>
      <dc:date>2023-05-30T03:32:15Z</dc:date>
    </item>
    <item>
      <title>Re: replace is giving empty string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-replace-giving-empty-string/m-p/644802#M223283</link>
      <description>&lt;P&gt;It would help if you posted the SPL as text rather than a screen shot so we can test with it.&lt;/P&gt;&lt;P&gt;The regex in the &lt;FONT face="courier new,courier"&gt;replace&lt;/FONT&gt; command doesn't match the data shown.&amp;nbsp; It's looking for at least 15 letters or digits or any number of digits after the first slash, but the sample data has only 10 characters.&lt;/P&gt;</description>
      <pubDate>Sat, 27 May 2023 00:27:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-replace-giving-empty-string/m-p/644802#M223283</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2023-05-27T00:27:48Z</dc:date>
    </item>
    <item>
      <title>Re: replace is giving empty string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-replace-giving-empty-string/m-p/644807#M223284</link>
      <description>&lt;P&gt;Here is a runanywhere example showing your replace working&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults
| fields - _time
| eval _raw="{ 
    \"durationMs\":  83,  
    \"properties\": {
     \"request-id\": \"1c910793-8be4-4850-83d5-f360b4b05478\",
     \"method\": \"GET\",
     \"path\": \"/scenarios/636d40506930b10b8f082f27\"
    }
}"
| spath
| eval path=replace('properties.path',"(\/[0-9a-zA-Z]{15,}|\/\d+)","/{id}")
| stats values(path) by properties.path , properties.method&lt;/LI-CODE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ITWhisperer_0-1685169681285.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/25576i046CD1C8C10535B3/image-size/medium?v=v2&amp;amp;px=400" role="button" title="ITWhisperer_0-1685169681285.png" alt="ITWhisperer_0-1685169681285.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Which version of Splunk are you running?&lt;/P&gt;</description>
      <pubDate>Sat, 27 May 2023 06:41:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-replace-giving-empty-string/m-p/644807#M223284</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2023-05-27T06:41:44Z</dc:date>
    </item>
    <item>
      <title>Re: replace is giving empty string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-replace-giving-empty-string/m-p/645069#M223389</link>
      <description>&lt;P&gt;Your&lt;SPAN&gt;&amp;nbsp;runanywhere example&amp;nbsp;works, even on my side. But when I actually use it on my real event logs, the same problem occur. So looks the problem is not in replace, but how I feed the properties.url into replace. Thank you, I will do more troubleshooting on my side.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 30 May 2023 16:39:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-replace-giving-empty-string/m-p/645069#M223389</guid>
      <dc:creator>YatMan</dc:creator>
      <dc:date>2023-05-30T16:39:16Z</dc:date>
    </item>
    <item>
      <title>Re: replace is giving empty string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-replace-giving-empty-string/m-p/645072#M223390</link>
      <description>&lt;P&gt;The most common string manipulation "failure" is caused by a field being multivalued. &amp;nbsp;Any chance your data can give multivalued properties.path? &amp;nbsp;Does your replace fail to render {id} with every properties.method or only some of them?&lt;/P&gt;&lt;P&gt;One easy test for multivaluedness can be&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval path=mvmap('properties.path', replace('properties.path',"(\/[0-9a-zA-Z]{15,}|\/\d+)","/{id}"))
| stats values(path) by properties.path , properties.method&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 30 May 2023 16:58:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-replace-giving-empty-string/m-p/645072#M223390</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2023-05-30T16:58:25Z</dc:date>
    </item>
    <item>
      <title>Re: replace is giving empty string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-replace-giving-empty-string/m-p/645140#M223398</link>
      <description>&lt;P&gt;&lt;SPAN&gt;multivalue field as if&amp;nbsp; 'properties.path' could contains more than one value?&amp;nbsp;No,&amp;nbsp;&lt;/SPAN&gt;&amp;nbsp;&lt;SPAN&gt;'properties.path'&amp;nbsp;&lt;/SPAN&gt; always only have 1 value (1 string). And this field always exist in all logs.&lt;BR /&gt;&lt;BR /&gt;However, your&amp;nbsp;mvmap is able to make 'properties.path' work with replace(). Although I can't quite explain it, this is what I want to achieve.&amp;nbsp; Thank you.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="YatMan_0-1685472159445.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/25617i567885F897F24CD1/image-size/medium?v=v2&amp;amp;px=400" role="button" title="YatMan_0-1685472159445.png" alt="YatMan_0-1685472159445.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 30 May 2023 18:45:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-replace-giving-empty-string/m-p/645140#M223398</guid>
      <dc:creator>YatMan</dc:creator>
      <dc:date>2023-05-30T18:45:23Z</dc:date>
    </item>
    <item>
      <title>Re: replace is giving empty string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-replace-giving-empty-string/m-p/645196#M223416</link>
      <description>&lt;P&gt;In that case, I do have another hypothesis. &amp;nbsp;Is it possible that your source type uses both index-time extraction of JSON structure (&lt;SPAN&gt;INDEXED_EXTRACTIONS=JSON)&lt;/SPAN&gt; and search time automatic extraction (KV_MODE=JSON)? &amp;nbsp;A field can not only be multivalued and have several different &amp;nbsp;values per event, but also be multivalued with identical values.&lt;/P&gt;&lt;P&gt;If every event has properties.path populated, this faux multivalue condition can most easily identified by looking at the fields column in smart mode or verbose mode. &amp;nbsp;You will see that properties.path is populated in 200% of events. (As opposed to 100%.) &amp;nbsp;If the fields is sparsely populated, you will need something like&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;base search properties.path=*&lt;/LI-CODE&gt;&lt;P&gt;Hope this helps.&lt;/P&gt;&lt;P&gt;I remember reading warnings about KV_MODE and INDEX_EXTRACTIONS in Splunk docs, but cannot find examples in a quick search.&lt;/P&gt;</description>
      <pubDate>Wed, 31 May 2023 05:23:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-replace-giving-empty-string/m-p/645196#M223416</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2023-05-31T05:23:42Z</dc:date>
    </item>
  </channel>
</rss>

