<?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 extract fields from a JSON file from Google Analytics API using spath or other options? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-fields-from-a-JSON-file-from-Google-Analytics-API/m-p/209462#M61235</link>
    <description>&lt;P&gt;Thank you somesoni2 !&lt;BR /&gt;
It worked perfectly!!&lt;BR /&gt;
Best regards!&lt;/P&gt;</description>
    <pubDate>Fri, 11 Sep 2015 13:27:29 GMT</pubDate>
    <dc:creator>guimilare</dc:creator>
    <dc:date>2015-09-11T13:27:29Z</dc:date>
    <item>
      <title>How to extract fields from a JSON file from Google Analytics API using spath or other options?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-fields-from-a-JSON-file-from-Google-Analytics-API/m-p/209460#M61233</link>
      <description>&lt;P&gt;Hi dear Splunkers&lt;/P&gt;

&lt;P&gt;I have to following JSON given by a REST calling at Google Analytics:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;{"kind":"analytics#gaData","id":"https://www.googleapis.com/analytics/v3/data/ga?ids=ga:XXXXXXXX&amp;amp;dimensions=ga:operatingSystem&amp;amp;metrics=ga:users&amp;amp;sort=-ga:users&amp;amp;start-date=30daysAgo&amp;amp;end-date=yesterday","query":{"start-date":"30daysAgo","end-date":"yesterday","ids":"ga:XXXXXXXX","dimensions":"ga:operatingSystem","metrics":["ga:users"],"sort":["-ga:users"],"start-index":1,"max-results":1000},"itemsPerPage":1000,"totalResults":9,"selfLink":"https://www.googleapis.com/analytics/v3/data/ga?ids=ga:XXXXXXXX&amp;amp;dimensions=ga:operatingSystem&amp;amp;metrics=ga:users&amp;amp;sort=-ga:users&amp;amp;start-date=30daysAgo&amp;amp;end-date=yesterday","profileInfo":{"profileId":"XXXXXXXX","accountId":"XXXXXXXX","webPropertyId":"XXXXXXXX-X","internalWebPropertyId":"XXXXXXXX","profileName":"Todos os dados do website","tableId":"ga:XXXXXXXX"},"containsSampledData":false,"columnHeaders":[{"name":"ga:operatingSystem","columnType":"DIMENSION","dataType":"STRING"},{"name":"ga:users","columnType":"METRIC","dataType":"INTEGER"}],"totalsForAllResults":{"ga:users":"17700"},"rows":[["Windows","13440"],["Android","2131"],["iOS","1439"],["Linux","281"],["Macintosh","280"],["Windows Phone","78"],["(not set)","29"],["Chrome OS","19"],["BlackBerry","3"]]}
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I'm having a hard time trying to use spath so I can break the data I need as follows:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;OS                  Number
Windows             13440
Android              2131
iOS                  1439
Linux                 281
Macintosh             280
Windows Phone          78
(not set)              29
Chrome OS              19
BlackBerry              3
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Can you guys help me?&lt;BR /&gt;
How can I use spath (or any other tool) to do this?&lt;BR /&gt;
Thanks in advance!&lt;/P&gt;</description>
      <pubDate>Thu, 10 Sep 2015 21:10:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-fields-from-a-JSON-file-from-Google-Analytics-API/m-p/209460#M61233</guid>
      <dc:creator>guimilare</dc:creator>
      <dc:date>2015-09-10T21:10:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract fields from a JSON file from Google Analytics API using spath or other options?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-fields-from-a-JSON-file-from-Google-Analytics-API/m-p/209461#M61234</link>
      <description>&lt;P&gt;Try this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Your base search | table _raw | rex mode=sed "s/\[(\"[^\"]+\"),(\"[^\"]+\")\]/{\"OS\":\1,\"Number\":\2}/g" | spath | table rows* | rename rows{}.* as * | table OS Number
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This will give you multivalued field for OS and Number. If you further split each OS as separate event, try this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; Your base search | table _raw | rex mode=sed "s/\[(\"[^\"]+\"),(\"[^\"]+\")\]/{\"OS\":\1,\"Number\":\2}/g" | spath | table rows* | rename rows{}.* as * | eval temp=mvzip(OS,Number,"##") | table temp | mvexpand temp | rex field=temp "(?&amp;lt;OS&amp;gt;.*)##(?&amp;lt;Number&amp;gt;.*)"| table OS Number
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 10 Sep 2015 21:43:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-fields-from-a-JSON-file-from-Google-Analytics-API/m-p/209461#M61234</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2015-09-10T21:43:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract fields from a JSON file from Google Analytics API using spath or other options?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-fields-from-a-JSON-file-from-Google-Analytics-API/m-p/209462#M61235</link>
      <description>&lt;P&gt;Thank you somesoni2 !&lt;BR /&gt;
It worked perfectly!!&lt;BR /&gt;
Best regards!&lt;/P&gt;</description>
      <pubDate>Fri, 11 Sep 2015 13:27:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-fields-from-a-JSON-file-from-Google-Analytics-API/m-p/209462#M61235</guid>
      <dc:creator>guimilare</dc:creator>
      <dc:date>2015-09-11T13:27:29Z</dc:date>
    </item>
  </channel>
</rss>

