<?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 placeholders in message templates with property values in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Replace-placeholders-in-message-templates-with-property-values/m-p/554151#M157316</link>
    <description>&lt;P&gt;Try something like this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults 
| eval _raw="{ \"time\": \"...\", \"template\": \"User {Username} logged into {Application}\", \"Username\": \"John.Doe\", \"Application\": \"SomeApp\" }"


| spath
| foreach *
    [| eval template=if("&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;"="template",template,replace(template,"\{"."&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;"."\}",&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;))]&lt;/LI-CODE&gt;&lt;P&gt;The first two lines just set up some dummy data.&lt;/P&gt;</description>
    <pubDate>Wed, 02 Jun 2021 20:47:35 GMT</pubDate>
    <dc:creator>ITWhisperer</dc:creator>
    <dc:date>2021-06-02T20:47:35Z</dc:date>
    <item>
      <title>Replace placeholders in message templates with property values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Replace-placeholders-in-message-templates-with-property-values/m-p/554150#M157315</link>
      <description>&lt;P&gt;We are importing structured logs stored as json lines in a text file. An example event:&lt;/P&gt;&lt;P&gt;{ "time": "...", "template": "User {Username} logged into {Application}", "Username": "John.Doe", "Application": "SomeApp" }&lt;/P&gt;&lt;P&gt;I am looking to &lt;EM&gt;render&lt;/EM&gt; the template into a message property that would read "User John.Doe logged into SomeApp" by replacing the tokens with values from their respective properties.&lt;/P&gt;&lt;P&gt;The template and properties are dynamic, so I cannot hard code the property names in the regex. Is there a way to perform this rendering dynamically either during log ingestion or during search time?&lt;/P&gt;</description>
      <pubDate>Wed, 02 Jun 2021 20:30:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Replace-placeholders-in-message-templates-with-property-values/m-p/554150#M157315</guid>
      <dc:creator>nathanjr</dc:creator>
      <dc:date>2021-06-02T20:30:35Z</dc:date>
    </item>
    <item>
      <title>Re: Replace placeholders in message templates with property values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Replace-placeholders-in-message-templates-with-property-values/m-p/554151#M157316</link>
      <description>&lt;P&gt;Try something like this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults 
| eval _raw="{ \"time\": \"...\", \"template\": \"User {Username} logged into {Application}\", \"Username\": \"John.Doe\", \"Application\": \"SomeApp\" }"


| spath
| foreach *
    [| eval template=if("&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;"="template",template,replace(template,"\{"."&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;"."\}",&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;))]&lt;/LI-CODE&gt;&lt;P&gt;The first two lines just set up some dummy data.&lt;/P&gt;</description>
      <pubDate>Wed, 02 Jun 2021 20:47:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Replace-placeholders-in-message-templates-with-property-values/m-p/554151#M157316</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2021-06-02T20:47:35Z</dc:date>
    </item>
    <item>
      <title>Re: Replace placeholders in message templates with property values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Replace-placeholders-in-message-templates-with-property-values/m-p/554158#M157319</link>
      <description>&lt;P&gt;Thank you so much!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Jun 2021 22:44:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Replace-placeholders-in-message-templates-with-property-values/m-p/554158#M157319</guid>
      <dc:creator>nathanjr</dc:creator>
      <dc:date>2021-06-02T22:44:02Z</dc:date>
    </item>
  </channel>
</rss>

