<?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 Extract multiple jsons from array in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Extract-multiple-jsons-from-array/m-p/393790#M70301</link>
    <description>&lt;P&gt;Hi all . &lt;/P&gt;

&lt;P&gt;This is an example of a json i'm sending to my Splunk cloud.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;{   "workers": [
    {
      "UserID": 100000906,
      "ActiveShiftName": "learning sports",
      "WorkerName": "tim",
      "CurrentRoleInShift": "Tagger",
      "IsLogged": true,
      "TimeFromLastEventSaved": "00:00:13.2323651",
      "TimeFromLastEventApproved": null,
      "TotalEventsSavedInPast30Min": 68,
      "TotalEventsApprovedInPast30Min": 0
    },
    {
      "UserID": 100002137,
      "ActiveShiftName": "learning sports",
      "WorkerName": "liverpool2",
      "CurrentRoleInShift": null,
      "IsLogged": false,
      "TimeFromLastEventSaved": null,
      "TimeFromLastEventApproved": null,
      "TotalEventsSavedInPast30Min": 0,
      "TotalEventsApprovedInPast30Min": 0
    }   ] }
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I would like to build a table with this fields : &lt;BR /&gt;
workers{}.active_shift_name&lt;BR /&gt;
workers{}.worker_name &lt;BR /&gt;
workers{}.worker_id CurrentRoleInShift &lt;BR /&gt;
workers{}.TimeFromLastEventSaved &lt;BR /&gt;
workers{}.TimeFromLastEventApproved &lt;BR /&gt;
workers{}.IsLogged&lt;/P&gt;

&lt;P&gt;I tried multiple commands with no success&lt;BR /&gt;
For an example I tried this command :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="Test1" | spath input=_raw path="workers{}.ActiveShiftName" output=active_shift_name | spath input=_raw path="workers{}.WorkerName" output=worker_name |spath input=_raw path="workers{}.UserID" output=worker_id |spath input=_raw path="workers{}.CurrentRoleInShift" output=CurrentRoleInShift |spath input=_raw path="workers{}.TimeFromLastEventSaved" output=TimeFromLastEventSaved |spath input=_raw path="workers{}.TimeFromLastEventApproved" output=TimeFromLastEventApproved |spath input=_raw path="workers{}.TotalEventsSavedInPast30Min" output=TotalEventsSavedInPast30Min |spath input=_raw path="workers{}.TotalEventsApprovedInPast30Min" output=TotalEventsApprovedInPast30Min |spath input=_raw path="workers{}.IsLogged" output=IsLogged  | table active_shift_name worker_name worker_id CurrentRoleInShift TimeFromLastEventSaved TimeFromLastEventApproved IsLogged
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Can you please help ?&lt;/P&gt;

&lt;P&gt;Thank you!&lt;BR /&gt;
Amit&lt;/P&gt;</description>
    <pubDate>Wed, 30 Sep 2020 01:21:20 GMT</pubDate>
    <dc:creator>amitdaniel</dc:creator>
    <dc:date>2020-09-30T01:21:20Z</dc:date>
    <item>
      <title>Extract multiple jsons from array</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Extract-multiple-jsons-from-array/m-p/393790#M70301</link>
      <description>&lt;P&gt;Hi all . &lt;/P&gt;

&lt;P&gt;This is an example of a json i'm sending to my Splunk cloud.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;{   "workers": [
    {
      "UserID": 100000906,
      "ActiveShiftName": "learning sports",
      "WorkerName": "tim",
      "CurrentRoleInShift": "Tagger",
      "IsLogged": true,
      "TimeFromLastEventSaved": "00:00:13.2323651",
      "TimeFromLastEventApproved": null,
      "TotalEventsSavedInPast30Min": 68,
      "TotalEventsApprovedInPast30Min": 0
    },
    {
      "UserID": 100002137,
      "ActiveShiftName": "learning sports",
      "WorkerName": "liverpool2",
      "CurrentRoleInShift": null,
      "IsLogged": false,
      "TimeFromLastEventSaved": null,
      "TimeFromLastEventApproved": null,
      "TotalEventsSavedInPast30Min": 0,
      "TotalEventsApprovedInPast30Min": 0
    }   ] }
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I would like to build a table with this fields : &lt;BR /&gt;
workers{}.active_shift_name&lt;BR /&gt;
workers{}.worker_name &lt;BR /&gt;
workers{}.worker_id CurrentRoleInShift &lt;BR /&gt;
workers{}.TimeFromLastEventSaved &lt;BR /&gt;
workers{}.TimeFromLastEventApproved &lt;BR /&gt;
workers{}.IsLogged&lt;/P&gt;

&lt;P&gt;I tried multiple commands with no success&lt;BR /&gt;
For an example I tried this command :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="Test1" | spath input=_raw path="workers{}.ActiveShiftName" output=active_shift_name | spath input=_raw path="workers{}.WorkerName" output=worker_name |spath input=_raw path="workers{}.UserID" output=worker_id |spath input=_raw path="workers{}.CurrentRoleInShift" output=CurrentRoleInShift |spath input=_raw path="workers{}.TimeFromLastEventSaved" output=TimeFromLastEventSaved |spath input=_raw path="workers{}.TimeFromLastEventApproved" output=TimeFromLastEventApproved |spath input=_raw path="workers{}.TotalEventsSavedInPast30Min" output=TotalEventsSavedInPast30Min |spath input=_raw path="workers{}.TotalEventsApprovedInPast30Min" output=TotalEventsApprovedInPast30Min |spath input=_raw path="workers{}.IsLogged" output=IsLogged  | table active_shift_name worker_name worker_id CurrentRoleInShift TimeFromLastEventSaved TimeFromLastEventApproved IsLogged
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Can you please help ?&lt;/P&gt;

&lt;P&gt;Thank you!&lt;BR /&gt;
Amit&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 01:21:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Extract-multiple-jsons-from-array/m-p/393790#M70301</guid>
      <dc:creator>amitdaniel</dc:creator>
      <dc:date>2020-09-30T01:21:20Z</dc:date>
    </item>
    <item>
      <title>Re: Extract multiple jsons from array</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Extract-multiple-jsons-from-array/m-p/393791#M70302</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;

&lt;P&gt;Try this and rename the columns as required &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval test=" {   \"workers\": [
     {
       \"UserID\": 100000906,
       \"ActiveShiftName\": \"learning sports\",
       \"WorkerName\": \"tim\",
       \"CurrentRoleInShift\": \"Tagger\",
       \"IsLogged\": true,
       \"TimeFromLastEventSaved\": \"00:00:13.2323651\",
       \"TimeFromLastEventApproved\": null,
       \"TotalEventsSavedInPast30Min\": 68,
       \"TotalEventsApprovedInPast30Min\": 0
     },
     {
       \"UserID\": 100002137,
       \"ActiveShiftName\": \"learning sports\",
       \"WorkerName\": \"liverpool2\",
       \"CurrentRoleInShift\": null,
       \"IsLogged\": false,
       \"TimeFromLastEventSaved\": null,
       \"TimeFromLastEventApproved\": null,
       \"TotalEventsSavedInPast30Min\": 0,
       \"TotalEventsApprovedInPast30Min\": 0
     }   ] }" 
| spath input=test 
| table workers{}.ActiveShiftName, workers{}.WorkerName,workers{}.CurrentRoleInShift,workers{}.TimeFromLastEventSaved,workers{}.TimeFromLastEventApproved,workers{}.IsLogged
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 22 Jul 2019 07:24:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Extract-multiple-jsons-from-array/m-p/393791#M70302</guid>
      <dc:creator>vnravikumar</dc:creator>
      <dc:date>2019-07-22T07:24:51Z</dc:date>
    </item>
    <item>
      <title>Re: Extract multiple jsons from array</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Extract-multiple-jsons-from-array/m-p/393792#M70303</link>
      <description>&lt;P&gt;path="workers{}.ActiveShiftName"&lt;/P&gt;

&lt;P&gt;Use need to enclose each field in quotes. See attachment.&lt;/P&gt;

&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/7352i001C104D81805C96/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jul 2019 07:48:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Extract-multiple-jsons-from-array/m-p/393792#M70303</guid>
      <dc:creator>chinmoya</dc:creator>
      <dc:date>2019-07-22T07:48:54Z</dc:date>
    </item>
    <item>
      <title>Re: Extract multiple jsons from array</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Extract-multiple-jsons-from-array/m-p/393793#M70304</link>
      <description>&lt;P&gt;Thank you @chinmoya !!!&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jul 2019 08:43:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Extract-multiple-jsons-from-array/m-p/393793#M70304</guid>
      <dc:creator>amitdaniel</dc:creator>
      <dc:date>2019-07-22T08:43:32Z</dc:date>
    </item>
  </channel>
</rss>

