<?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: How to populate a single column with dynamic field values? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-populate-a-single-column-with-dynamic-field-values/m-p/678010#M231866</link>
    <description>&lt;P&gt;&lt;SPAN&gt;Edit: I realized I may have given the wrong impression by posting my example JSON object. The intention was to extract a value from any of the 3 fields into the single column.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;1. Yes, field3 is "Resource Name".&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;2. Yes&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;3.&amp;nbsp;I&amp;nbsp;used&amp;nbsp;"Attribute Name" and "ID" as placeholder values for the real data (just sanitizing the values/fields). They were just meant to give an example. In hindsight I think I should have stuck with generic names "field1-3".&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Output format:&lt;/SPAN&gt;&lt;/P&gt;&lt;TABLE border="1" width="100%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="25%" height="47px"&gt;&lt;SPAN&gt;event.AccountId&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD width="25%" height="47px"&gt;&lt;SPAN&gt;event.CloudPlatform&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD width="25%" height="47px"&gt;&lt;SPAN&gt;event.CloudService&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD width="25%" height="47px"&gt;Additional Details&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="25%" height="25px"&gt;&lt;SPAN&gt;xxxxxxxxxx&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD width="25%" height="25px"&gt;&lt;SPAN&gt;CloudProvider&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD width="25%" height="25px"&gt;&lt;SPAN&gt;Service&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD width="25%" height="25px"&gt;&lt;SPAN&gt;&lt;SPAN&gt;name-resource-121sg6fe&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;BR /&gt;ID-12132423fgrg&lt;BR /&gt;other-named-attribute&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
    <pubDate>Mon, 19 Feb 2024 20:40:31 GMT</pubDate>
    <dc:creator>ea-2023</dc:creator>
    <dc:date>2024-02-19T20:40:31Z</dc:date>
    <item>
      <title>How to populate a single column with dynamic field values?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-populate-a-single-column-with-dynamic-field-values/m-p/677714#M231728</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;I have a working dashboard where I have various fields that can be defined (field1 and field2 in the example), and some events have a field that is an extracted JSON object. I have successfully accessed various elements within the JSON object... but what I am trying to do is create ONE column called "Additional Details" where only certain elements, IF THEY EXIST, will populate in this column.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;The search below technically works, but as you can probably see, it will just add a NULL value if the specified element from field3 does not exist. Is there a way to check for other values in the JSON object, and populate those values in that single column, only if they exist?&lt;BR /&gt;&lt;BR /&gt;i.e. If field3 has "Attribute Name", "Resource Name", and "ID", but many events have only one of these fields, is it possible to have the value from the field, &lt;U&gt;only if it exists&lt;/U&gt;, populate in the "Additional Details" column?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=test field1=* field2=* | spath input=field3 #(which is a json_object)# | fillnull value=NULL | eval type=if(isnotnull(element_from_field3), ElementName, NULL) | stats count values(type) as "Additional Details" by Other&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Feb 2024 18:40:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-populate-a-single-column-with-dynamic-field-values/m-p/677714#M231728</guid>
      <dc:creator>ea-2023</dc:creator>
      <dc:date>2024-02-15T18:40:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to populate a single column with dynamic field values?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-populate-a-single-column-with-dynamic-field-values/m-p/677716#M231730</link>
      <description>&lt;P&gt;Please can you share some sample events and a mockup of what your expect output would look like&lt;/P&gt;</description>
      <pubDate>Thu, 15 Feb 2024 19:06:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-populate-a-single-column-with-dynamic-field-values/m-p/677716#M231730</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2024-02-15T19:06:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to populate a single column with dynamic field values?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-populate-a-single-column-with-dynamic-field-values/m-p/677717#M231731</link>
      <description>&lt;P class="lia-align-left"&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/261772"&gt;@ea-2023&lt;/a&gt;&amp;nbsp;If your JSON field 3 has one or more of those field attributes, then after the spath you can do&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| foreach "Attribute Name", "Resource Name", and "ID" [ 
  | eval type=mvappend(if(isnotnull('&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;'), '&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;', type) ]&lt;/LI-CODE&gt;&lt;P class="lia-align-left"&gt;which will cycle through the 3 desired fields and for any of the 3 that exist, will make a multi-value field called type with any that do exist.&lt;/P&gt;&lt;P class="lia-align-left"&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Feb 2024 19:54:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-populate-a-single-column-with-dynamic-field-values/m-p/677717#M231731</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2024-02-15T19:54:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to populate a single column with dynamic field values?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-populate-a-single-column-with-dynamic-field-values/m-p/677718#M231732</link>
      <description>&lt;P&gt;What is expected for &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;? What value would I add here to get it to cycle through all 3 (or more) values extracted from the spath object?&lt;/P&gt;</description>
      <pubDate>Thu, 15 Feb 2024 20:11:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-populate-a-single-column-with-dynamic-field-values/m-p/677718#M231732</guid>
      <dc:creator>ea-2023</dc:creator>
      <dc:date>2024-02-15T20:11:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to populate a single column with dynamic field values?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-populate-a-single-column-with-dynamic-field-values/m-p/677720#M231734</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/6367"&gt;@bowesmana&lt;/a&gt;&amp;nbsp;just wanted to tag you for awareness, not sure how this community notifies on comment replies. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Feb 2024 21:01:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-populate-a-single-column-with-dynamic-field-values/m-p/677720#M231734</guid>
      <dc:creator>ea-2023</dc:creator>
      <dc:date>2024-02-15T21:01:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to populate a single column with dynamic field values?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-populate-a-single-column-with-dynamic-field-values/m-p/677728#M231739</link>
      <description>&lt;P&gt;Splunk Docs is your friend. &amp;nbsp;See&amp;nbsp;&lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Foreach" target="_blank" rel="noopener"&gt;foreach&lt;/A&gt;. &amp;nbsp;&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt; is a symbol in SPL's foreach command, not to be replaced by the user. &amp;nbsp;SPL will iterate this symbol over the field names following the command name.&lt;/P&gt;</description>
      <pubDate>Thu, 15 Feb 2024 21:53:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-populate-a-single-column-with-dynamic-field-values/m-p/677728#M231739</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2024-02-15T21:53:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to populate a single column with dynamic field values?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-populate-a-single-column-with-dynamic-field-values/m-p/677729#M231740</link>
      <description>&lt;P&gt;I get this error whether I use &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt; or &amp;lt;&amp;lt;ITEM&amp;gt;&amp;gt;.&amp;nbsp;&lt;BR /&gt;&lt;SPAN&gt;Error in 'EvalCommand': The arguments to the 'mvappend' function are invalid.&lt;BR /&gt;&lt;BR /&gt;| eval type=mvappend(if(isnotnull('&amp;lt;&amp;lt;ITEM&amp;gt;&amp;gt;'), '&amp;lt;&amp;lt;ITEM&amp;gt;&amp;gt;', type)) ] &lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Feb 2024 22:39:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-populate-a-single-column-with-dynamic-field-values/m-p/677729#M231740</guid>
      <dc:creator>ea-2023</dc:creator>
      <dc:date>2024-02-15T22:39:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to populate a single column with dynamic field values?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-populate-a-single-column-with-dynamic-field-values/m-p/677734#M231742</link>
      <description>&lt;P&gt;There's an omission in &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/6367"&gt;@bowesmana&lt;/a&gt;'s &lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/MultivalueEvalFunctions#mvappend.28.26lt.3Bvalues.26gt.3B.29" target="_blank" rel="noopener"&gt;mvappend&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| foreach "Attribute Name", "Resource Name", "ID" [ 
  | eval type=mvappend(type, if(isnotnull('&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;'), '&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;', null())) ]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Feb 2024 23:58:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-populate-a-single-column-with-dynamic-field-values/m-p/677734#M231742</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2024-02-16T23:58:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to populate a single column with dynamic field values?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-populate-a-single-column-with-dynamic-field-values/m-p/677809#M231768</link>
      <description>&lt;P&gt;Thank you&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/6367"&gt;@bowesmana&lt;/a&gt;&amp;nbsp;and&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/33901"&gt;@yuanliu&lt;/a&gt;&amp;nbsp;for helping with this!&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;This worked, but I just had to add a ) at the end to balance the parenthesis. The values when tabled out all include "event" in addition to the targeted values, which I'm guessing is somehow coming from the top element in the array. Not a huge problem for me, but figured I'd mention it.&lt;/P&gt;
&lt;P&gt;Results:&lt;BR /&gt;event&lt;BR /&gt;name-resource-121sg6fe&lt;/P&gt;
&lt;P&gt;event&lt;BR /&gt;name-resource-387762fg&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sample JSON array:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;event: {
     AccountId: xxxxxxxxxx
     CloudPlatform: CloudProvider
     CloudService: Service
     ResourceAttributes: {"key1": "value1", "key2": "value2", "key3": value3, "key4": [{"key": "value", "key": "value"}], "Resource Name": "name-resource-121sg6fe", etc}
   }&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Feb 2024 15:01:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-populate-a-single-column-with-dynamic-field-values/m-p/677809#M231768</guid>
      <dc:creator>ea-2023</dc:creator>
      <dc:date>2024-02-16T15:01:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to populate a single column with dynamic field values?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-populate-a-single-column-with-dynamic-field-values/m-p/677876#M231803</link>
      <description>&lt;P&gt;(I was just trying to clarify &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/6367"&gt;@bowesmana&lt;/a&gt;'s syntax and have not related to the original question.) &amp;nbsp;It is always a good practice to illustrate sample/mock data at the beginning. &amp;nbsp;Now, the sample JSON needs further clarification in relationship to your OP.&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Is this snippet the &lt;FONT face="courier new,courier"&gt;field3&lt;/FONT&gt; you referred to in OP? &amp;nbsp;If not, which one is field3?&lt;/LI&gt;&lt;LI&gt;This snippet contains a key "&lt;FONT face="courier new,courier"&gt;event.ResourceAttributes.Resource Name&lt;/FONT&gt;". &amp;nbsp;I assume that this is "Resource Name" you referred to in OP. &amp;nbsp;Is this correct?&lt;/LI&gt;&lt;LI&gt;Which fields correspond to "Attribute Name" and "ID" in OP?&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;Importantly, when illustrating structured data like JSON, make sure your illustration is compliant. &amp;nbsp;I tried to reconstruct a compliant JSON from your illustration. &amp;nbsp;This is what I come up with:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;{"event": {
     "AccountId": "xxxxxxxxxx",
     "CloudPlatform": "CloudProvider",
     "CloudService": "Service",
     "ResourceAttributes": {"key1": "value1", "key2": "value2", "key3": "value3", "key4": [{"key": "value", "key": "value"}], "Resource Name": "name-resource-121sg6fe", "etc": "etc"}
   }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does this truly reflect your original data structure? &amp;nbsp;If the snippet is field3, here is an emulation to check if my understanding is correct:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults
| eval field3 = "{\"event\": {
     \"AccountId\": \"xxxxxxxxxx\",
     \"CloudPlatform\": \"CloudProvider\",
     \"CloudService\": \"Service\",
     \"ResourceAttributes\": {\"key1\": \"value1\", \"key2\": \"value2\", \"key3\": \"value3\", \"key4\": [{\"key\": \"value\", \"key\": \"value\"}], \"Resource Name\": \"name-resource-121sg6fe\", \"etc\": \"etc\"}
   }
}"
| spath input=field3
| fields - field3 _*&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="129.21875px"&gt;&lt;BR /&gt;event.AccountId&lt;/TD&gt;&lt;TD width="193.734375px"&gt;event.CloudPlatform&lt;/TD&gt;&lt;TD width="65.46875px"&gt;event.CloudService&lt;/TD&gt;&lt;TD width="86.484375px"&gt;event.ResourceAttributes.Resource Name&lt;/TD&gt;&lt;TD width="54.46875px"&gt;event.ResourceAttributes.etc&lt;/TD&gt;&lt;TD width="63.953125px"&gt;event.ResourceAttributes.key1&lt;/TD&gt;&lt;TD width="63.953125px"&gt;event.ResourceAttributes.key2&lt;/TD&gt;&lt;TD width="63.953125px"&gt;event.ResourceAttributes.key3&lt;/TD&gt;&lt;TD width="69.828125px"&gt;&lt;DIV class=""&gt;event.ResourceAttributes.key4{}.key&lt;/DIV&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="129.21875px"&gt;xxxxxxxxxx&lt;/TD&gt;&lt;TD width="193.734375px"&gt;CloudProvider&lt;/TD&gt;&lt;TD width="65.46875px"&gt;Service&lt;/TD&gt;&lt;TD width="86.484375px"&gt;name-resource-121sg6fe&lt;/TD&gt;&lt;TD width="54.46875px"&gt;etc&lt;/TD&gt;&lt;TD width="63.953125px"&gt;value1&lt;/TD&gt;&lt;TD width="63.953125px"&gt;value2&lt;/TD&gt;&lt;TD width="63.953125px"&gt;value3&lt;/TD&gt;&lt;TD width="69.828125px"&gt;&lt;DIV class=""&gt;value&lt;/DIV&gt;&lt;DIV class=""&gt;value&lt;/DIV&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;Is this close?&lt;/P&gt;&lt;P&gt;Also, if you have a specific output format in mind, you should illustrate what the output should look like when using this sample data.&lt;/P&gt;</description>
      <pubDate>Sat, 17 Feb 2024 00:28:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-populate-a-single-column-with-dynamic-field-values/m-p/677876#M231803</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2024-02-17T00:28:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to populate a single column with dynamic field values?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-populate-a-single-column-with-dynamic-field-values/m-p/678010#M231866</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Edit: I realized I may have given the wrong impression by posting my example JSON object. The intention was to extract a value from any of the 3 fields into the single column.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;1. Yes, field3 is "Resource Name".&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;2. Yes&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;3.&amp;nbsp;I&amp;nbsp;used&amp;nbsp;"Attribute Name" and "ID" as placeholder values for the real data (just sanitizing the values/fields). They were just meant to give an example. In hindsight I think I should have stuck with generic names "field1-3".&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Output format:&lt;/SPAN&gt;&lt;/P&gt;&lt;TABLE border="1" width="100%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="25%" height="47px"&gt;&lt;SPAN&gt;event.AccountId&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD width="25%" height="47px"&gt;&lt;SPAN&gt;event.CloudPlatform&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD width="25%" height="47px"&gt;&lt;SPAN&gt;event.CloudService&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD width="25%" height="47px"&gt;Additional Details&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="25%" height="25px"&gt;&lt;SPAN&gt;xxxxxxxxxx&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD width="25%" height="25px"&gt;&lt;SPAN&gt;CloudProvider&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD width="25%" height="25px"&gt;&lt;SPAN&gt;Service&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD width="25%" height="25px"&gt;&lt;SPAN&gt;&lt;SPAN&gt;name-resource-121sg6fe&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;BR /&gt;ID-12132423fgrg&lt;BR /&gt;other-named-attribute&lt;/SPAN&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Mon, 19 Feb 2024 20:40:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-populate-a-single-column-with-dynamic-field-values/m-p/678010#M231866</guid>
      <dc:creator>ea-2023</dc:creator>
      <dc:date>2024-02-19T20:40:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to populate a single column with dynamic field values?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-populate-a-single-column-with-dynamic-field-values/m-p/678164#M231924</link>
      <description>&lt;P&gt;To simplify things, I will just follow your initial clue and assume that ID and Name are also part of event.ResourceAttributes.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=test field1=* field2=*

| spath input=field3
| foreach "event.ResourceAttributes.Name", "event.ResourceAttributes.Resource Name", "event.ResourceAttributes.ID" [ 
  | eval type=mvappend(type, if(isnotnull('&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;'), '&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;', null())) ]
| stats values(type) as "Additional Details" by event.AccountId event.CloudPlatform event.CloudService&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If they are in some other nodes, just rewrite the foreach list.&lt;/P&gt;&lt;P&gt;Here is a fuller emulation that I made up based on your singular mock data point.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults
| eval field3 = mvappend("{\"event\": {
     \"AccountId\": \"xxxxxxxxxx2\",
     \"CloudPlatform\": \"CloudProvider\",
     \"CloudService\": \"Service\",
     \"ResourceAttributes\": {\"key1\": \"value1\", \"ID\": \"value2\", \"key3\": \"value3\", \"key4\": [{\"key\": \"value\", \"key\": \"value\"}], \"Resource Name\": \"name-resource-121sg6fe\", \"etc\": \"etc\"}
   }
}" ``` has ID, Resource Name, no Name ```,
"{\"event\": {
     \"AccountId\": \"xxxxxxxxxx1\",
     \"CloudPlatform\": \"CloudProvider\",
     \"CloudService\": \"Service\",
     \"ResourceAttributes\": {\"key1\": \"value1\", \"key2\": \"value2\", \"key3\": \"value3\", \"key4\": [{\"key\": \"value\", \"key\": \"value\"}], \"Resource Name\": \"name-resource-121sg6fe\", \"etc\": \"etc\"}
   }
}" ``` has Resource Name, no others ```,
"{\"event\": {
     \"AccountId\": \"xxxxxxxxxx2\",
     \"CloudPlatform\": \"CloudProvider\",
     \"CloudService\": \"Service\",
     \"ResourceAttributes\": {\"Name\": \"value1\", \"key2\": \"value2\", \"ID\": \"value3\", \"key4\": [{\"key\": \"value\", \"key\": \"value\"}], \"etc\": \"etc\"}
   }
}" ``` has ID, Name, no Resource Name ```,
"{\"event\": {
     \"AccountId\": \"xxxxxxxxxx1\",
     \"CloudPlatform\": \"CloudProvider\",
     \"CloudService\": \"Service\",
     \"ResourceAttributes\": {\"key1\": \"value1\", \"key2\": \"value2\", \"key3\": \"value3\", \"key4\": [{\"key\": \"value\", \"key\": \"value\"}], \"etc\": \"etc\"}
   }
}" ``` has none of the three ```)
| mvexpand field3
``` the above sort of emulates
index=test field1=* field2=*
```
| eval type = json_object()
| spath input=field3
| foreach "event.ResourceAttributes.Name", "event.ResourceAttributes.Resource Name", "event.ResourceAttributes.ID" [ 
  | eval type=mvappend(type, if(isnotnull('&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;'), '&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;', null())) ]
| stats values(type) as "Additional Details" by event.AccountId event.CloudPlatform event.CloudService&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What this does is to add variations to which of "Name", "Resource Name", and "ID" do or do not appear in each event. &amp;nbsp;You can play with it and compare with real data. &amp;nbsp;The output is&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;event.AccountId&lt;/TD&gt;&lt;TD&gt;event.CloudPlatform&lt;/TD&gt;&lt;TD&gt;event.CloudService&lt;/TD&gt;&lt;TD&gt;&lt;DIV class=""&gt;Additional Details&lt;/DIV&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;xxxxxxxxxx1&lt;/TD&gt;&lt;TD&gt;CloudProvider&lt;/TD&gt;&lt;TD&gt;Service&lt;/TD&gt;&lt;TD&gt;&lt;DIV class=""&gt;name-resource-121sg6fe&lt;/DIV&gt;&lt;DIV class=""&gt;{}&lt;/DIV&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;xxxxxxxxxx2&lt;/TD&gt;&lt;TD&gt;CloudProvider&lt;/TD&gt;&lt;TD&gt;Service&lt;/TD&gt;&lt;TD&gt;&lt;DIV class=""&gt;name-resource-121sg6fe&lt;/DIV&gt;&lt;DIV class=""&gt;value1&lt;/DIV&gt;&lt;DIV class=""&gt;value2&lt;/DIV&gt;&lt;DIV class=""&gt;value3&lt;/DIV&gt;&lt;DIV class=""&gt;{}&lt;/DIV&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;One more suggestion:&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/6367"&gt;@bowesmana&lt;/a&gt;'s idea is just to use foreach. &amp;nbsp;The above format does not group the present or missing attributes in a very distinguishable manner. &amp;nbsp;An alternative to using mvappend inside the foreach subsearch is to also carry the input keys in addition to values in "Additional Details". &amp;nbsp;Using a JSON structure is one such method.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=test field1=* field2=*
| eval type = json_object()
| spath input=field3
| foreach "event.ResourceAttributes.Name", "event.ResourceAttributes.Resource Name", "event.ResourceAttributes.ID" [ 
  | eval type=json_set(type, replace("&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;", "event.ResourceAttributes.", ""), '&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;') ]
| stats values(type) as "Additional Details" by event.AccountId event.CloudPlatform event.CloudService&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is a full emulation:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults
| eval field3 = mvappend("{\"event\": {
     \"AccountId\": \"xxxxxxxxxx2\",
     \"CloudPlatform\": \"CloudProvider\",
     \"CloudService\": \"Service\",
     \"ResourceAttributes\": {\"key1\": \"value1\", \"ID\": \"value2\", \"key3\": \"value3\", \"key4\": [{\"key\": \"value\", \"key\": \"value\"}], \"Resource Name\": \"name-resource-121sg6fe\", \"etc\": \"etc\"}
   }
}" ``` has ID, Resource Name, no Name ```,
"{\"event\": {
     \"AccountId\": \"xxxxxxxxxx1\",
     \"CloudPlatform\": \"CloudProvider\",
     \"CloudService\": \"Service\",
     \"ResourceAttributes\": {\"key1\": \"value1\", \"key2\": \"value2\", \"key3\": \"value3\", \"key4\": [{\"key\": \"value\", \"key\": \"value\"}], \"Resource Name\": \"name-resource-121sg6fe\", \"etc\": \"etc\"}
   }
}" ``` has Resource Name, no others ```,
"{\"event\": {
     \"AccountId\": \"xxxxxxxxxx2\",
     \"CloudPlatform\": \"CloudProvider\",
     \"CloudService\": \"Service\",
     \"ResourceAttributes\": {\"Name\": \"value1\", \"key2\": \"value2\", \"ID\": \"value3\", \"key4\": [{\"key\": \"value\", \"key\": \"value\"}], \"etc\": \"etc\"}
   }
}" ``` has ID, Name, no Resource Name ```,
"{\"event\": {
     \"AccountId\": \"xxxxxxxxxx1\",
     \"CloudPlatform\": \"CloudProvider\",
     \"CloudService\": \"Service\",
     \"ResourceAttributes\": {\"key1\": \"value1\", \"key2\": \"value2\", \"key3\": \"value3\", \"key4\": [{\"key\": \"value\", \"key\": \"value\"}], \"etc\": \"etc\"}
   }
}" ``` has none of the three ```)
| mvexpand field3
``` the above sort of emulates
index=test field1=* field2=*
```
| eval type = json_object()
| spath input=field3
| foreach "event.ResourceAttributes.Name", "event.ResourceAttributes.Resource Name", "event.ResourceAttributes.ID" [ 
  | eval type=json_set(type, replace("&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;", "event.ResourceAttributes.", ""), '&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;') ]
| stats values(type) as "Additional Details" by event.AccountId event.CloudPlatform event.CloudService&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And output from this emulation.&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;event.AccountId&lt;/TD&gt;&lt;TD&gt;event.CloudPlatform&lt;/TD&gt;&lt;TD&gt;event.CloudService&lt;/TD&gt;&lt;TD&gt;&lt;DIV class=""&gt;Additional Details&lt;/DIV&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;xxxxxxxxxx1&lt;/TD&gt;&lt;TD&gt;CloudProvider&lt;/TD&gt;&lt;TD&gt;Service&lt;/TD&gt;&lt;TD&gt;&lt;DIV class=""&gt;{"Name":null,"Resource Name":"name-resource-121sg6fe","ID":null}&lt;/DIV&gt;&lt;DIV class=""&gt;{"Name":null,"Resource Name":null,"ID":null}&lt;/DIV&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;xxxxxxxxxx2&lt;/TD&gt;&lt;TD&gt;CloudProvider&lt;/TD&gt;&lt;TD&gt;Service&lt;/TD&gt;&lt;TD&gt;&lt;DIV class=""&gt;{"Name":"value1","Resource Name":null,"ID":"value3"}&lt;/DIV&gt;&lt;DIV class=""&gt;{"Name":null,"Resource Name":"name-resource-121sg6fe","ID":"value2"}&lt;/DIV&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Wed, 21 Feb 2024 07:13:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-populate-a-single-column-with-dynamic-field-values/m-p/678164#M231924</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2024-02-21T07:13:11Z</dc:date>
    </item>
  </channel>
</rss>

