<?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: Combine Json elements in array in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-combine-JSON-elements-in-array/m-p/593814#M206691</link>
    <description>&lt;P&gt;That explains why the number of events jumped up. Is there anyway to display the stats as unique events?&lt;/P&gt;</description>
    <pubDate>Thu, 14 Apr 2022 16:16:39 GMT</pubDate>
    <dc:creator>jbourne89</dc:creator>
    <dc:date>2022-04-14T16:16:39Z</dc:date>
    <item>
      <title>How to combine JSON elements in array?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-combine-JSON-elements-in-array/m-p/593746#M206670</link>
      <description>&lt;P&gt;I have created a query similar to the below&lt;/P&gt;
&lt;P&gt;host=nftHost index=paymeNow&lt;BR /&gt;source="\\\\epamjhost\Logs\*"&lt;/P&gt;
&lt;P&gt;| rex "(Message content+\s+:+\s+|\[Handling message+\s+:+\s+|\[Handling command of type CheckCommand:+\s+)(?&amp;lt;json&amp;gt;\{.*)"&lt;/P&gt;
&lt;P&gt;| spath input=json&lt;BR /&gt;| table _time, MessageTypeDesc, CurrentState, CaseId, TaskType, Attributes{}.AttributeName, Attributes{}.JsonValue, _raw&lt;/P&gt;
&lt;P&gt;The below json is obtained from the rex expression and spath is used to parse it.&lt;/P&gt;
&lt;P&gt;{&lt;BR /&gt;"TaskId" : "1",&lt;BR /&gt;"CurrentState" : "COMPLETED",&lt;BR /&gt;"RequestedAction" : null,&lt;BR /&gt;"User" : "NFTPAYME",&lt;BR /&gt;"Attributes" : [{&lt;BR /&gt;"AttributeName" : "transactionId",&lt;BR /&gt;"AttributeType" : "int",&lt;BR /&gt;"JsonValue" : "4"&lt;BR /&gt;}, {&lt;BR /&gt;"AttributeName" : "Enabled",&lt;BR /&gt;"AttributeType" : "boolean",&lt;BR /&gt;"JsonValue" : "false"&lt;BR /&gt;}, {&lt;BR /&gt;"AttributeName" : "holdType",&lt;BR /&gt;"AttributeType" : "string",&lt;BR /&gt;"JsonValue" : ""&lt;BR /&gt;}, {&lt;BR /&gt;"AttributeName" : "isSettlement",&lt;BR /&gt;"AttributeType" : "boolean",&lt;BR /&gt;"JsonValue" : "false"&lt;BR /&gt;}, {&lt;BR /&gt;"AttributeName" : "isIntraday",&lt;BR /&gt;"AttributeType" : "boolean",&lt;BR /&gt;"JsonValue" : "false"&lt;BR /&gt;}, {&lt;BR /&gt;"AttributeName" : "isReleaseReady",&lt;BR /&gt;"AttributeType" : "boolean",&lt;BR /&gt;"JsonValue" : "false"&lt;BR /&gt;}, {&lt;BR /&gt;"AttributeName" : "isStat",&lt;BR /&gt;"AttributeType" : "boolean",&lt;BR /&gt;"JsonValue" : "false"&lt;BR /&gt;}, {&lt;BR /&gt;"AttributeName" : "StatusList",&lt;BR /&gt;"AttributeType" : "string",&lt;BR /&gt;"JsonValue" : ""&lt;BR /&gt;},&lt;BR /&gt;],&lt;BR /&gt;"TaskType" : "Settle",&lt;BR /&gt;"CaseId" : "1",&lt;BR /&gt;}&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Attributes contains an array of objects so my question is how to take the attributes and create a single string from the whole array?&lt;/P&gt;
&lt;TABLE border="1" width="76.5625%"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="12.5%"&gt;_time&lt;/TD&gt;
&lt;TD width="12.5%"&gt;MessageTypeDesc&lt;/TD&gt;
&lt;TD width="12.5%"&gt;CurrentState&lt;/TD&gt;
&lt;TD width="12.5%"&gt;CaseId&lt;/TD&gt;
&lt;TD width="12.5%"&gt;TaskType&lt;/TD&gt;
&lt;TD width="12.5%"&gt;Attributes&lt;/TD&gt;
&lt;TD width="12.5%"&gt;_raw&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="12.5%"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="12.5%"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="12.5%"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="12.5%"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="12.5%"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="12.5%"&gt;
&lt;P&gt;transactionId:4&lt;BR /&gt;&lt;SPAN&gt;Enabled:true&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;holdType:&lt;/P&gt;
&lt;P&gt;isSettlement:false&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD width="12.5%"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="12.5%"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="12.5%"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="12.5%"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="12.5%"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="12.5%"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="12.5%"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD width="12.5%"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Apr 2022 16:20:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-combine-JSON-elements-in-array/m-p/593746#M206670</guid>
      <dc:creator>jbourne89</dc:creator>
      <dc:date>2022-04-14T16:20:53Z</dc:date>
    </item>
    <item>
      <title>Re: Combine Json elements in array</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-combine-JSON-elements-in-array/m-p/593764#M206675</link>
      <description>&lt;LI-CODE lang="markup"&gt;| streamstats count as row
| spath input=json Attributes{} output=Attributes
| mvexpand Attributes
| spath input=Attributes
| eval Attribute=AttributeName.": ".JsonValue
| stats values(*) as * by row&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 14 Apr 2022 11:19:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-combine-JSON-elements-in-array/m-p/593764#M206675</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2022-04-14T11:19:21Z</dc:date>
    </item>
    <item>
      <title>Re: Combine Json elements in array</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-combine-JSON-elements-in-array/m-p/593768#M206677</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/244901"&gt;@jbourne89&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;not sure if i got the understanding correct are you looking to combine all the values in the attributes field to create a single string&amp;nbsp; try the below search you can join them using , | or space based on your requirement in between quotes " " in mvjoin function&lt;/P&gt;&lt;P&gt;|rename Attributes{}.AttributeName AS attributes| eval Exception=mvjoin(attributes," ") |table attributes Exception&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="venky1544_0-1649936056113.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/19069i2DB6F4D8CC617C80/image-size/medium?v=v2&amp;amp;px=400" role="button" title="venky1544_0-1649936056113.png" alt="venky1544_0-1649936056113.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Note :- if this help karma points are&amp;nbsp; appreciated /and please accept the solution if it worked for you&amp;nbsp; it might help others as well&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Apr 2022 11:35:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-combine-JSON-elements-in-array/m-p/593768#M206677</guid>
      <dc:creator>venky1544</dc:creator>
      <dc:date>2022-04-14T11:35:30Z</dc:date>
    </item>
    <item>
      <title>Re: Combine Json elements in array</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-combine-JSON-elements-in-array/m-p/593798#M206682</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/137142"&gt;@venky1544&lt;/a&gt;&amp;nbsp;Thank you for replying. This is very close to what I want combine the values in the AttributeName field with the value in the JsonValue field. Currently the JsonValue items are appended at the bottom of the AttributeName list.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I would like is a single string containing AttributeName:JsonValue&lt;/P&gt;</description>
      <pubDate>Thu, 14 Apr 2022 14:44:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-combine-JSON-elements-in-array/m-p/593798#M206682</guid>
      <dc:creator>jbourne89</dc:creator>
      <dc:date>2022-04-14T14:44:28Z</dc:date>
    </item>
    <item>
      <title>Re: Combine Json elements in array</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-combine-JSON-elements-in-array/m-p/593800#M206683</link>
      <description>&lt;P&gt;This output is correct but I have a few questions. What is the purpose of streamstats count as row and stats values(*) by row?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Apr 2022 14:49:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-combine-JSON-elements-in-array/m-p/593800#M206683</guid>
      <dc:creator>jbourne89</dc:creator>
      <dc:date>2022-04-14T14:49:46Z</dc:date>
    </item>
    <item>
      <title>Re: Combine Json elements in array</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-combine-JSON-elements-in-array/m-p/593805#M206688</link>
      <description>&lt;P&gt;The streamstats tags the events with a unique number because the mvexpand creates multiple events for each attribute, and the stats brings them back together using the unique number to ensure they are collected together correctly.&lt;/P&gt;</description>
      <pubDate>Thu, 14 Apr 2022 15:28:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-combine-JSON-elements-in-array/m-p/593805#M206688</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2022-04-14T15:28:51Z</dc:date>
    </item>
    <item>
      <title>Re: Combine Json elements in array</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-combine-JSON-elements-in-array/m-p/593814#M206691</link>
      <description>&lt;P&gt;That explains why the number of events jumped up. Is there anyway to display the stats as unique events?&lt;/P&gt;</description>
      <pubDate>Thu, 14 Apr 2022 16:16:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-combine-JSON-elements-in-array/m-p/593814#M206691</guid>
      <dc:creator>jbourne89</dc:creator>
      <dc:date>2022-04-14T16:16:39Z</dc:date>
    </item>
    <item>
      <title>Re: Combine Json elements in array</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-combine-JSON-elements-in-array/m-p/593834#M206695</link>
      <description>&lt;P&gt;Do you mean something like this?&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| streamstats count as row
| spath input=json Attributes{} output=Attributes
| mvexpand Attributes
| spath input=Attributes
| eval {AttributeName}=JsonValue
| stats values(*) as * by row&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 14 Apr 2022 16:50:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-combine-JSON-elements-in-array/m-p/593834#M206695</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2022-04-14T16:50:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to combine JSON elements in array?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-combine-JSON-elements-in-array/m-p/593837#M206697</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/225168"&gt;@ITWhisperer&lt;/a&gt;&amp;nbsp;and&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/137142"&gt;@venky1544&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Apr 2022 17:34:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-combine-JSON-elements-in-array/m-p/593837#M206697</guid>
      <dc:creator>jbourne89</dc:creator>
      <dc:date>2022-04-14T17:34:31Z</dc:date>
    </item>
  </channel>
</rss>

