<?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 Why doesn't replace work on a nested field? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Why-doesn-t-replace-work-on-a-nested-field/m-p/621130#M215922</link>
    <description>&lt;P&gt;Sample event&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;{ 
    durationMs:  83  
    properties:  { 
        url:  https://mywebsite/v1/organization/41547/buildings
    } 
   correlationId: e581d476-fa5f-4023-a53e-53d6e06734ae
}&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;I want to replace the ids into&lt;BR /&gt;&lt;A href="https://mywebsite/v1/organization/{id}/buildings" target="_blank" rel="noopener"&gt;https://mywebsite/v1/organization/{id}/buildings&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;I tried {base search string} | eval endpoint=replace(properties.url, "\d+", "{id}") | stats by endpoint&amp;nbsp;&lt;BR /&gt;This return no result, but if I try other coorelationId field on the root level,&amp;nbsp;{base search string} | eval endpoint=replace(coorelationId, "\d+", "{id}") | stats by endpoint&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;This return what I expected&lt;BR /&gt;endpoint&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;|&amp;nbsp; &amp;nbsp;(other fields)&lt;BR /&gt;&lt;SPAN&gt;adb{id}f{id}-{id}fd{id}-{id}-a{id}b-{id}c{id}f{id}d | (other fields)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;aea{id}e{id}c-fcdc-{id}-a{id}-{id}a{id}bfe{id}ee{id} | (other fields)&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;Why replace doesn't work on nested field?&lt;/P&gt;</description>
    <pubDate>Thu, 17 Nov 2022 14:34:40 GMT</pubDate>
    <dc:creator>YatMan</dc:creator>
    <dc:date>2022-11-17T14:34:40Z</dc:date>
    <item>
      <title>Why doesn't replace work on a nested field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-doesn-t-replace-work-on-a-nested-field/m-p/621130#M215922</link>
      <description>&lt;P&gt;Sample event&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;{ 
    durationMs:  83  
    properties:  { 
        url:  https://mywebsite/v1/organization/41547/buildings
    } 
   correlationId: e581d476-fa5f-4023-a53e-53d6e06734ae
}&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;I want to replace the ids into&lt;BR /&gt;&lt;A href="https://mywebsite/v1/organization/{id}/buildings" target="_blank" rel="noopener"&gt;https://mywebsite/v1/organization/{id}/buildings&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;I tried {base search string} | eval endpoint=replace(properties.url, "\d+", "{id}") | stats by endpoint&amp;nbsp;&lt;BR /&gt;This return no result, but if I try other coorelationId field on the root level,&amp;nbsp;{base search string} | eval endpoint=replace(coorelationId, "\d+", "{id}") | stats by endpoint&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;This return what I expected&lt;BR /&gt;endpoint&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;|&amp;nbsp; &amp;nbsp;(other fields)&lt;BR /&gt;&lt;SPAN&gt;adb{id}f{id}-{id}fd{id}-{id}-a{id}b-{id}c{id}f{id}d | (other fields)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;aea{id}e{id}c-fcdc-{id}-a{id}-{id}a{id}bfe{id}ee{id} | (other fields)&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;Why replace doesn't work on nested field?&lt;/P&gt;</description>
      <pubDate>Thu, 17 Nov 2022 14:34:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-doesn-t-replace-work-on-a-nested-field/m-p/621130#M215922</guid>
      <dc:creator>YatMan</dc:creator>
      <dc:date>2022-11-17T14:34:40Z</dc:date>
    </item>
    <item>
      <title>Re: Replace a nested field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-doesn-t-replace-work-on-a-nested-field/m-p/621135#M215923</link>
      <description>&lt;P&gt;Splunk doesn't like fieldnames with special characters like periods.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| rename properties.url AS endpoint
| rex field=endpoint mode=sed "s/\/\d+\//\/{id}\//"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Nov 2022 22:29:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-doesn-t-replace-work-on-a-nested-field/m-p/621135#M215923</guid>
      <dc:creator>johnhuang</dc:creator>
      <dc:date>2022-11-16T22:29:24Z</dc:date>
    </item>
    <item>
      <title>Re: Replace a nested field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-doesn-t-replace-work-on-a-nested-field/m-p/621144#M215924</link>
      <description>&lt;P&gt;Field names with dots in or other special characters need to be in single quotes. Try this&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval endpoint=replace('properties.url', "\d+", "{id}")&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 16 Nov 2022 22:33:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-doesn-t-replace-work-on-a-nested-field/m-p/621144#M215924</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2022-11-16T22:33:24Z</dc:date>
    </item>
    <item>
      <title>Re: Replace a nested field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-doesn-t-replace-work-on-a-nested-field/m-p/621148#M215925</link>
      <description>&lt;P&gt;this single quote solution works well. thank you.&lt;BR /&gt;It would be helpful if you guys can add an example in the document, thanks! &lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Replace#Syntax" target="_blank"&gt;https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Replace#Syntax&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Nov 2022 22:45:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-doesn-t-replace-work-on-a-nested-field/m-p/621148#M215925</guid>
      <dc:creator>YatMan</dc:creator>
      <dc:date>2022-11-16T22:45:59Z</dc:date>
    </item>
  </channel>
</rss>

