<?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: Extracting sub fields or sub string in multiline log. in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Extracting-sub-fields-or-sub-string-in-multiline-log/m-p/666964#M228793</link>
    <description>&lt;P&gt;Before we delve into SPL, I want to ask if you have any influence on developers of this application. &amp;nbsp;The put in so much energy into crafting a seemingly stiff log format. &amp;nbsp;With that energy, why don't they just give you compliant JSON? &amp;nbsp;That will easily satisfy all your structural desire to have parent node and children nodes. &amp;nbsp;For example,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;{"Changed Attributes":
 {
  "SAM Account Name": "-",
  "Display Name": "-",
  "User Principal Name": "-",
  "Home Directory": "-",
  "Home Drive": "-",
  "Script Path": "-",
  "Profile Path": "-",
  "User Workstations": "-",
  "Password Last Set": "9/12/2023 7:30:15 AM",
  "Account Expires": "-",
  "Primary Group ID": "-",
  "AllowedToDelegateTo": "-",
  "Old UAC Value": "-",
  "New UAC Value": "-",
  "User Account Control": "-",
  "User Parameters": "-",
  "SID History": "-",
  "Logon Hours": "-"
 }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And this sample will give the following fields:&lt;/P&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;field name&lt;/TD&gt;&lt;TD&gt;field value&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Changed Attributes.Account Expires&lt;/TD&gt;&lt;TD&gt;-&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Changed Attributes.AllowedToDelegateTo&lt;/TD&gt;&lt;TD&gt;-&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Changed Attributes.Display Name&lt;/TD&gt;&lt;TD&gt;-&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Changed Attributes.Home Directory&lt;/TD&gt;&lt;TD&gt;-&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Changed Attributes.Home Drive&lt;/TD&gt;&lt;TD&gt;-&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Changed Attributes.Logon Hours&lt;/TD&gt;&lt;TD&gt;-&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Changed Attributes.New UAC Value&lt;/TD&gt;&lt;TD&gt;-&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Changed Attributes.Old UAC Value&lt;/TD&gt;&lt;TD&gt;-&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Changed Attributes.Password Last Set&lt;/TD&gt;&lt;TD&gt;9/12/2023 7:30:15 AM&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Changed Attributes.Primary Group ID&lt;/TD&gt;&lt;TD&gt;-&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Changed Attributes.Profile Path&lt;/TD&gt;&lt;TD&gt;-&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Changed Attributes.SAM Account Name&lt;/TD&gt;&lt;TD&gt;-&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Changed Attributes.SID History&lt;/TD&gt;&lt;TD&gt;-&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Changed Attributes.Script Path&lt;/TD&gt;&lt;TD&gt;-&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Changed Attributes.User Account Control&lt;/TD&gt;&lt;TD&gt;-&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Changed Attributes.User Parameters&lt;/TD&gt;&lt;TD&gt;-&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Changed Attributes.User Principal Name&lt;/TD&gt;&lt;TD&gt;-&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Changed Attributes.User Workstations&lt;/TD&gt;&lt;TD&gt;-&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;I believe this satisfies your structural requirement.&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;If you absolutely have no influence, AND if the developers are so disciplined that they will &lt;U&gt;never&lt;/U&gt; make tiny changes in log format, I want to ask how do you expect Splunk to identify "&lt;SPAN&gt;Changed Attributes:" as parent node? &amp;nbsp;Is it merely by leading space in the line? &amp;nbsp;Such criteria are extremely unrobust. &amp;nbsp;Additionally, how many different parent nodes can there be? &amp;nbsp;Is the illustration the entirety of the log or just a portion of the log? &amp;nbsp;Unless you can clearly describe data characteristics, there is no way to give a meaningful solution.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Now, if the illustration &lt;STRONG&gt;is&lt;/STRONG&gt; the entirety of the log, and your developers are &lt;STRONG&gt;extremely&lt;/STRONG&gt; religious about spaces and swear on their souls never to make change, you can use these characteristics to derive information you need. &amp;nbsp;One such methods is to convert the free-hand string to compliant JSON, then use &lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Spath" target="_blank" rel="noopener"&gt;spath&lt;/A&gt; to extract and flatten the structure.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| rex max_match=0 mode=sed "s/^/{\"/ s/  /  \"/g s/: /\"&amp;amp;\"/g s/
/\",
/g s/:\",/\":
 {/ s/$/\"
 }
}/"
| spath&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;As to group the fields into changed and unchanged sets, that can also be achieved. &amp;nbsp;If your developers are flexible to make the log compliant JSON, they can just make unchanged fields JSON null. &amp;nbsp;Else you can try to handle them as string provided that the free-hand text is extremely rigid like mentioned above.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| foreach *
    [eval changed = mvappend(changed, if('&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;' == "-", null(), "&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;" . " =&amp;gt; " . '&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;')),
    unchanged = mvappend(unchanged, if('&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;' == "-", "&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;", null()))]
| table changed unchanged&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This way, you get&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;changed&lt;/TD&gt;&lt;TD&gt;&lt;DIV class=""&gt;unchanged&lt;/DIV&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Changed Attributes.Password Last Set =&amp;gt; 9/12/2023 7:30:15 AM&lt;/TD&gt;&lt;TD&gt;&lt;DIV class=""&gt;Changed Attributes.Account Expires&lt;/DIV&gt;&lt;DIV class=""&gt;Changed Attributes.AllowedToDelegateTo&lt;/DIV&gt;&lt;DIV class=""&gt;Changed Attributes.Display Name&lt;/DIV&gt;&lt;DIV class=""&gt;Changed Attributes.Home Directory&lt;/DIV&gt;&lt;DIV class=""&gt;Changed Attributes.Home Drive&lt;/DIV&gt;&lt;DIV class=""&gt;Changed Attributes.Logon Hours&lt;/DIV&gt;&lt;DIV class=""&gt;Changed Attributes.New UAC Value&lt;/DIV&gt;&lt;DIV class=""&gt;Changed Attributes.Old UAC Value&lt;/DIV&gt;&lt;DIV class=""&gt;Changed Attributes.Primary Group ID&lt;/DIV&gt;&lt;DIV class=""&gt;Changed Attributes.Profile Path&lt;/DIV&gt;&lt;DIV class=""&gt;Changed Attributes.SAM Account Name&lt;/DIV&gt;&lt;DIV class=""&gt;Changed Attributes.SID History&lt;/DIV&gt;&lt;DIV class=""&gt;Changed Attributes.Script Path&lt;/DIV&gt;&lt;DIV class=""&gt;Changed Attributes.User Account Control&lt;/DIV&gt;&lt;DIV class=""&gt;Changed Attributes.User Parameters&lt;/DIV&gt;&lt;DIV class=""&gt;Changed Attributes.User Principal Name&lt;/DIV&gt;&lt;DIV class=""&gt;Changed Attributes.User Workstations&lt;/DIV&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;If your illustrated data is the entirety of the log, this is an emulation you can play with and compare with real data&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults
| fields - _time
| eval data = "Changed Attributes:
  SAM Account Name: -
  Display Name: -
  User Principal Name: -
  Home Directory: -
  Home Drive: -
  Script Path: -
  Profile Path: -
  User Workstations: -
  Password Last Set: 9/12/2023 7:30:15 AM
  Account Expires: -
  Primary Group ID: -
  AllowedToDelegateTo: -
  Old UAC Value: -
  New UAC Value: -
  User Account Control: -
  User Parameters: -
  SID History: -
  Logon Hours: -"
``` data emulation above ```&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 01 Nov 2023 07:46:45 GMT</pubDate>
    <dc:creator>yuanliu</dc:creator>
    <dc:date>2023-11-01T07:46:45Z</dc:date>
    <item>
      <title>Extracting sub fields or sub string in multiline log.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extracting-sub-fields-or-sub-string-in-multiline-log/m-p/666859#M228751</link>
      <description>&lt;P&gt;Good mornign All,&lt;/P&gt;&lt;P&gt;I have several logs with fields which have sibfield. I would like to be able to extract the subfield and append it to the parent. The example should clarify my query. I have a log of user modifications. The log would look something like that:&lt;/P&gt;&lt;DIV&gt;Changed Attributes:&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; SAM Account Name: -&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; Display Name: -&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; User Principal Name: -&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; Home Directory: -&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; Home Drive: -&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; Script Path: -&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; Profile Path: -&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; User Workstations: -&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; Password Last Set: 9/12/2023 7:30:15 AM&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; Account Expires: -&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; Primary Group ID: -&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; AllowedToDelegateTo: -&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; Old UAC Value: -&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; New UAC Value: -&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; User Account Control: -&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; User Parameters: -&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; SID History: -&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; Logon Hours: -&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;I would like to be able to create a table which will have a column which will include the "parent" field: Changed Attributes as well as the child field, for example: CHanged Attributes: Password Last Set.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Altenatively, I would also settle for a table with statically assigned column, lets call it changed data and a sa value have: Password Last Set:&amp;nbsp; 9/12/2023 7:30:15 AM&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Another challenge I have (probably candidate for another question on the forum) is to add the value to a table column, only if it has value other than "-" to the right of it. The reason is that only one changed attribue (of all those in the list above) will have any value. I would like to report on what attribue for a user was changed.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Thank you very much in advance for any direction.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Kind Regards,&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Mike.&lt;/SPAN&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 31 Oct 2023 08:55:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extracting-sub-fields-or-sub-string-in-multiline-log/m-p/666859#M228751</guid>
      <dc:creator>BoscoBaracus</dc:creator>
      <dc:date>2023-10-31T08:55:35Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting sub fields or sub string in multiline log.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extracting-sub-fields-or-sub-string-in-multiline-log/m-p/666964#M228793</link>
      <description>&lt;P&gt;Before we delve into SPL, I want to ask if you have any influence on developers of this application. &amp;nbsp;The put in so much energy into crafting a seemingly stiff log format. &amp;nbsp;With that energy, why don't they just give you compliant JSON? &amp;nbsp;That will easily satisfy all your structural desire to have parent node and children nodes. &amp;nbsp;For example,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;{"Changed Attributes":
 {
  "SAM Account Name": "-",
  "Display Name": "-",
  "User Principal Name": "-",
  "Home Directory": "-",
  "Home Drive": "-",
  "Script Path": "-",
  "Profile Path": "-",
  "User Workstations": "-",
  "Password Last Set": "9/12/2023 7:30:15 AM",
  "Account Expires": "-",
  "Primary Group ID": "-",
  "AllowedToDelegateTo": "-",
  "Old UAC Value": "-",
  "New UAC Value": "-",
  "User Account Control": "-",
  "User Parameters": "-",
  "SID History": "-",
  "Logon Hours": "-"
 }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And this sample will give the following fields:&lt;/P&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;field name&lt;/TD&gt;&lt;TD&gt;field value&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Changed Attributes.Account Expires&lt;/TD&gt;&lt;TD&gt;-&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Changed Attributes.AllowedToDelegateTo&lt;/TD&gt;&lt;TD&gt;-&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Changed Attributes.Display Name&lt;/TD&gt;&lt;TD&gt;-&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Changed Attributes.Home Directory&lt;/TD&gt;&lt;TD&gt;-&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Changed Attributes.Home Drive&lt;/TD&gt;&lt;TD&gt;-&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Changed Attributes.Logon Hours&lt;/TD&gt;&lt;TD&gt;-&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Changed Attributes.New UAC Value&lt;/TD&gt;&lt;TD&gt;-&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Changed Attributes.Old UAC Value&lt;/TD&gt;&lt;TD&gt;-&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Changed Attributes.Password Last Set&lt;/TD&gt;&lt;TD&gt;9/12/2023 7:30:15 AM&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Changed Attributes.Primary Group ID&lt;/TD&gt;&lt;TD&gt;-&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Changed Attributes.Profile Path&lt;/TD&gt;&lt;TD&gt;-&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Changed Attributes.SAM Account Name&lt;/TD&gt;&lt;TD&gt;-&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Changed Attributes.SID History&lt;/TD&gt;&lt;TD&gt;-&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Changed Attributes.Script Path&lt;/TD&gt;&lt;TD&gt;-&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Changed Attributes.User Account Control&lt;/TD&gt;&lt;TD&gt;-&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Changed Attributes.User Parameters&lt;/TD&gt;&lt;TD&gt;-&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Changed Attributes.User Principal Name&lt;/TD&gt;&lt;TD&gt;-&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Changed Attributes.User Workstations&lt;/TD&gt;&lt;TD&gt;-&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;I believe this satisfies your structural requirement.&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;If you absolutely have no influence, AND if the developers are so disciplined that they will &lt;U&gt;never&lt;/U&gt; make tiny changes in log format, I want to ask how do you expect Splunk to identify "&lt;SPAN&gt;Changed Attributes:" as parent node? &amp;nbsp;Is it merely by leading space in the line? &amp;nbsp;Such criteria are extremely unrobust. &amp;nbsp;Additionally, how many different parent nodes can there be? &amp;nbsp;Is the illustration the entirety of the log or just a portion of the log? &amp;nbsp;Unless you can clearly describe data characteristics, there is no way to give a meaningful solution.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Now, if the illustration &lt;STRONG&gt;is&lt;/STRONG&gt; the entirety of the log, and your developers are &lt;STRONG&gt;extremely&lt;/STRONG&gt; religious about spaces and swear on their souls never to make change, you can use these characteristics to derive information you need. &amp;nbsp;One such methods is to convert the free-hand string to compliant JSON, then use &lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Spath" target="_blank" rel="noopener"&gt;spath&lt;/A&gt; to extract and flatten the structure.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| rex max_match=0 mode=sed "s/^/{\"/ s/  /  \"/g s/: /\"&amp;amp;\"/g s/
/\",
/g s/:\",/\":
 {/ s/$/\"
 }
}/"
| spath&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;As to group the fields into changed and unchanged sets, that can also be achieved. &amp;nbsp;If your developers are flexible to make the log compliant JSON, they can just make unchanged fields JSON null. &amp;nbsp;Else you can try to handle them as string provided that the free-hand text is extremely rigid like mentioned above.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| foreach *
    [eval changed = mvappend(changed, if('&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;' == "-", null(), "&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;" . " =&amp;gt; " . '&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;')),
    unchanged = mvappend(unchanged, if('&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;' == "-", "&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;", null()))]
| table changed unchanged&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This way, you get&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;changed&lt;/TD&gt;&lt;TD&gt;&lt;DIV class=""&gt;unchanged&lt;/DIV&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Changed Attributes.Password Last Set =&amp;gt; 9/12/2023 7:30:15 AM&lt;/TD&gt;&lt;TD&gt;&lt;DIV class=""&gt;Changed Attributes.Account Expires&lt;/DIV&gt;&lt;DIV class=""&gt;Changed Attributes.AllowedToDelegateTo&lt;/DIV&gt;&lt;DIV class=""&gt;Changed Attributes.Display Name&lt;/DIV&gt;&lt;DIV class=""&gt;Changed Attributes.Home Directory&lt;/DIV&gt;&lt;DIV class=""&gt;Changed Attributes.Home Drive&lt;/DIV&gt;&lt;DIV class=""&gt;Changed Attributes.Logon Hours&lt;/DIV&gt;&lt;DIV class=""&gt;Changed Attributes.New UAC Value&lt;/DIV&gt;&lt;DIV class=""&gt;Changed Attributes.Old UAC Value&lt;/DIV&gt;&lt;DIV class=""&gt;Changed Attributes.Primary Group ID&lt;/DIV&gt;&lt;DIV class=""&gt;Changed Attributes.Profile Path&lt;/DIV&gt;&lt;DIV class=""&gt;Changed Attributes.SAM Account Name&lt;/DIV&gt;&lt;DIV class=""&gt;Changed Attributes.SID History&lt;/DIV&gt;&lt;DIV class=""&gt;Changed Attributes.Script Path&lt;/DIV&gt;&lt;DIV class=""&gt;Changed Attributes.User Account Control&lt;/DIV&gt;&lt;DIV class=""&gt;Changed Attributes.User Parameters&lt;/DIV&gt;&lt;DIV class=""&gt;Changed Attributes.User Principal Name&lt;/DIV&gt;&lt;DIV class=""&gt;Changed Attributes.User Workstations&lt;/DIV&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;If your illustrated data is the entirety of the log, this is an emulation you can play with and compare with real data&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults
| fields - _time
| eval data = "Changed Attributes:
  SAM Account Name: -
  Display Name: -
  User Principal Name: -
  Home Directory: -
  Home Drive: -
  Script Path: -
  Profile Path: -
  User Workstations: -
  Password Last Set: 9/12/2023 7:30:15 AM
  Account Expires: -
  Primary Group ID: -
  AllowedToDelegateTo: -
  Old UAC Value: -
  New UAC Value: -
  User Account Control: -
  User Parameters: -
  SID History: -
  Logon Hours: -"
``` data emulation above ```&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 01 Nov 2023 07:46:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extracting-sub-fields-or-sub-string-in-multiline-log/m-p/666964#M228793</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2023-11-01T07:46:45Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting sub fields or sub string in multiline log.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extracting-sub-fields-or-sub-string-in-multiline-log/m-p/667088#M228858</link>
      <description>&lt;P&gt;Good morning&amp;nbsp;&lt;SPAN&gt;yuanliu,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thank you very much for such detailed response. I will go through the proposed solutions and let you know how this worked for us.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;As to the format of the log, this is a standard Windows Active Direcotry log. There is no way we can change the format. Many other Windows / AD logs will have similar structure. Not much we can do about this.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Again, thank you for your answer.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Kind Regards,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Mike.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Nov 2023 06:34:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extracting-sub-fields-or-sub-string-in-multiline-log/m-p/667088#M228858</guid>
      <dc:creator>BoscoBaracus</dc:creator>
      <dc:date>2023-11-02T06:34:48Z</dc:date>
    </item>
  </channel>
</rss>

