<?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: Json key value mapping in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Json-key-value-mapping/m-p/569421#M100984</link>
    <description>&lt;P&gt;Thanks for the response.&lt;/P&gt;&lt;P&gt;My SPL may not be right. You can find the raw data:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;{"delete_me": "True", "vendor": "Dbruzy", "site": "India", "type": "Sales", "name": "Rahul", "date": ["10-jan-2022", "30-dec-2022"], "count_target": ["1700", "300"]}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;SPL I corrected in below way:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;my index
| rename count_target{} as target
| rename Date{} as voltage
| foreach voltage*
[ eval voltage=mvappend(voltage, '&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;')]
| foreach target*
[ eval target=mvappend(target, '&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;')] | mvexpand target| mvexpand voltage
| stats values(voltage) as Date values(target) as Count_Target by Vendor, Name,Site,Type&lt;/LI-CODE&gt;</description>
    <pubDate>Sat, 02 Oct 2021 05:20:55 GMT</pubDate>
    <dc:creator>vivekkumarkk</dc:creator>
    <dc:date>2021-10-02T05:20:55Z</dc:date>
    <item>
      <title>Json key value mapping</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Json-key-value-mapping/m-p/569374#M100975</link>
      <description>&lt;P&gt;I have my splunk Jason in below format&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;{ [-]
delete_me: True
vendor: Dbruzy
name: Rahul
date: [ [-]
10-jan-2022
30-dec-2022
]
count_target: [ [-]
1700
300
]
site: India
type: Sales
}&lt;/LI-CODE&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;&lt;P&gt;I am looking for a query to get output like this:&lt;/P&gt;&lt;TABLE border="1" width="100%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="16.666666666666668%" height="25px"&gt;Vendor&lt;/TD&gt;&lt;TD width="16.666666666666668%" height="25px"&gt;Name&lt;/TD&gt;&lt;TD width="16.666666666666668%" height="25px"&gt;Date&lt;/TD&gt;&lt;TD width="16.666666666666668%" height="25px"&gt;Count_Target&lt;/TD&gt;&lt;TD width="16.666666666666668%" height="25px"&gt;Site&lt;/TD&gt;&lt;TD width="16.666666666666668%" height="25px"&gt;Type&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="16.666666666666668%" height="25px"&gt;Dbruzy&lt;/TD&gt;&lt;TD width="16.666666666666668%" height="25px"&gt;Rahul&lt;/TD&gt;&lt;TD width="16.666666666666668%" height="25px"&gt;10-jan-2022&lt;/TD&gt;&lt;TD width="16.666666666666668%" height="25px"&gt;1700&lt;/TD&gt;&lt;TD width="16.666666666666668%" height="25px"&gt;India&lt;/TD&gt;&lt;TD width="16.666666666666668%" height="25px"&gt;Sales&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD height="25px"&gt;Dbruzy&lt;/TD&gt;&lt;TD height="25px"&gt;Rahul&lt;/TD&gt;&lt;TD height="25px"&gt;30-dec-2022&lt;/TD&gt;&lt;TD height="25px"&gt;300&lt;/TD&gt;&lt;TD height="25px"&gt;India&lt;/TD&gt;&lt;TD height="25px"&gt;Sales&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But I am getting as below:&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="16.666666666666668%" height="25px"&gt;Vendor&lt;/TD&gt;&lt;TD width="16.666666666666668%" height="25px"&gt;Name&lt;/TD&gt;&lt;TD width="16.666666666666668%" height="25px"&gt;Date&lt;/TD&gt;&lt;TD width="16.666666666666668%" height="25px"&gt;Count_Target&lt;/TD&gt;&lt;TD width="16.666666666666668%" height="25px"&gt;Site&lt;/TD&gt;&lt;TD width="16.666666666666668%" height="25px"&gt;Type&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="16.666666666666668%" height="25px"&gt;Dbruzy&lt;/TD&gt;&lt;TD width="16.666666666666668%" height="25px"&gt;Rahul&lt;/TD&gt;&lt;TD width="16.666666666666668%" height="25px"&gt;&lt;P&gt;10-jan-2022&lt;/P&gt;&lt;P&gt;30-dec-2022&lt;/P&gt;&lt;/TD&gt;&lt;TD width="16.666666666666668%" height="25px"&gt;&lt;P&gt;1700&lt;/P&gt;&lt;P&gt;300&lt;/P&gt;&lt;/TD&gt;&lt;TD width="16.666666666666668%" height="25px"&gt;India&lt;/TD&gt;&lt;TD width="16.666666666666668%" height="25px"&gt;Sales&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD height="25px"&gt;Dbruzy&lt;/TD&gt;&lt;TD height="25px"&gt;Rahul&lt;/TD&gt;&lt;TD height="25px"&gt;&lt;P&gt;10-jan-2022&lt;/P&gt;&lt;P&gt;30-dec-2022&lt;/P&gt;&lt;/TD&gt;&lt;TD height="25px"&gt;&lt;P&gt;1700&lt;/P&gt;&lt;P&gt;300&lt;/P&gt;&lt;/TD&gt;&lt;TD height="25px"&gt;India&lt;/TD&gt;&lt;TD height="25px"&gt;Sales&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Query I am using:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;my index
| rename count_target{} as target
| rename Date{} as voltage
| spath input=voltage path=voltage output=someOtherField
| spath input=someOtherField
| foreach voltage*
[ eval voltage=mvappend(voltage, '&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;')] | spath input=target path=target output=someOtherField1
| spath input=someOtherField1
| foreach target*
[ eval target=mvappend(target, '&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;')] | mvexpand target| mvexpand voltage
| stats values(voltage) as Date values(target) as Count_Target by Vendor, Name,Site,Type&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can you please help?&lt;/P&gt;</description>
      <pubDate>Fri, 01 Oct 2021 17:04:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Json-key-value-mapping/m-p/569374#M100975</guid>
      <dc:creator>vivekkumarkk</dc:creator>
      <dc:date>2021-10-01T17:04:59Z</dc:date>
    </item>
    <item>
      <title>Re: Json key value mapping</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Json-key-value-mapping/m-p/569384#M100977</link>
      <description>&lt;P&gt;I don't see how your SPL matches the example json you shared. Please can you share the raw json in a code block &amp;lt;/&amp;gt;&lt;/P&gt;</description>
      <pubDate>Fri, 01 Oct 2021 18:02:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Json-key-value-mapping/m-p/569384#M100977</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2021-10-01T18:02:08Z</dc:date>
    </item>
    <item>
      <title>Re: Json key value mapping</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Json-key-value-mapping/m-p/569421#M100984</link>
      <description>&lt;P&gt;Thanks for the response.&lt;/P&gt;&lt;P&gt;My SPL may not be right. You can find the raw data:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;{"delete_me": "True", "vendor": "Dbruzy", "site": "India", "type": "Sales", "name": "Rahul", "date": ["10-jan-2022", "30-dec-2022"], "count_target": ["1700", "300"]}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;SPL I corrected in below way:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;my index
| rename count_target{} as target
| rename Date{} as voltage
| foreach voltage*
[ eval voltage=mvappend(voltage, '&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;')]
| foreach target*
[ eval target=mvappend(target, '&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;')] | mvexpand target| mvexpand voltage
| stats values(voltage) as Date values(target) as Count_Target by Vendor, Name,Site,Type&lt;/LI-CODE&gt;</description>
      <pubDate>Sat, 02 Oct 2021 05:20:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Json-key-value-mapping/m-p/569421#M100984</guid>
      <dc:creator>vivekkumarkk</dc:creator>
      <dc:date>2021-10-02T05:20:55Z</dc:date>
    </item>
    <item>
      <title>Re: Json key value mapping</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Json-key-value-mapping/m-p/569428#M100986</link>
      <description>&lt;P&gt;You are using foreach incorrectly - you only have one field that matches voltage* and target* - foreach doesn't iterate through the multivalues in the field - you could use mvmap to do that but I am not sure that would help you in this instance. From your SPL, it looks like you already have the fields extracted from the json, but I have used spath in this runanywhere example&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults 
| eval _raw="{\"delete_me\": \"True\", \"vendor\": \"Dbruzy\", \"site\": \"India\", \"type\": \"Sales\", \"name\": \"Rahul\", \"date\": [\"10-jan-2022\", \"30-dec-2022\"], \"count_target\": [\"1700\", \"300\"]}"
| table _raw
| spath



| rename count_target{} as target
| rename date{} as voltage
| mvexpand target
| streamstats count as row by name site type vendor
| eval voltage=mvindex(voltage,row-1)
| fields - row&lt;/LI-CODE&gt;</description>
      <pubDate>Sat, 02 Oct 2021 08:53:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Json-key-value-mapping/m-p/569428#M100986</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2021-10-02T08:53:11Z</dc:date>
    </item>
    <item>
      <title>Re: Json key value mapping</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Json-key-value-mapping/m-p/569466#M100987</link>
      <description>&lt;P&gt;Thank You&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/225168"&gt;@ITWhisperer&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-unicode-emoji" title=":relieved_face:"&gt;😌&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 03 Oct 2021 05:53:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Json-key-value-mapping/m-p/569466#M100987</guid>
      <dc:creator>vivekkumarkk</dc:creator>
      <dc:date>2021-10-03T05:53:34Z</dc:date>
    </item>
  </channel>
</rss>

