<?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 Search reads first event instead of desired event in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Search-reads-first-event-instead-of-desired-event/m-p/104623#M22030</link>
    <description>&lt;P&gt;I am using the Google Analytics Data Export API to pull some data down into a log file so it can be indexed by splunk. Data is printed out in the following format:&lt;/P&gt;

&lt;P&gt;ga:eventCategory=ViewChange | ga:eventAction=Grid   ga:totalEvents=6    ga:uniqueEvents=2&lt;BR /&gt;&lt;BR /&gt;
ga:eventCategory=SessionEvent | ga:eventAction=UserLogin    ga:totalEvents=13   ga:uniqueEvents=9   &lt;/P&gt;

&lt;P&gt;My search for counting logins is:&lt;/P&gt;

&lt;P&gt;source="googleanalytics.txt" "ga:eventCategory=SessionEvent | ga:eventAction=UserLogin" | extract kvdelim="=" | timechart span=1d sum(totalEvents) as "Total Logins", sum(uniqueEvents) as "Unique Logins"&lt;/P&gt;

&lt;P&gt;The problem is that the search is taking the first occurrence of ga:totalEvents, regardless of if it is a UserLogin event or not. &lt;/P&gt;

&lt;P&gt;Edit: To be more clear, for the above example the timechart displays 6 total, 2 unique logins instead of the expected 13 total, 9 unique. The pipe inside the quotes is read as a search character, but I have removed it just to make sure, am seeing the same result when just searching for "ga:eventAction=UserLogin"&lt;/P&gt;</description>
    <pubDate>Fri, 04 Nov 2011 21:46:42 GMT</pubDate>
    <dc:creator>crobicha</dc:creator>
    <dc:date>2011-11-04T21:46:42Z</dc:date>
    <item>
      <title>Search reads first event instead of desired event</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Search-reads-first-event-instead-of-desired-event/m-p/104623#M22030</link>
      <description>&lt;P&gt;I am using the Google Analytics Data Export API to pull some data down into a log file so it can be indexed by splunk. Data is printed out in the following format:&lt;/P&gt;

&lt;P&gt;ga:eventCategory=ViewChange | ga:eventAction=Grid   ga:totalEvents=6    ga:uniqueEvents=2&lt;BR /&gt;&lt;BR /&gt;
ga:eventCategory=SessionEvent | ga:eventAction=UserLogin    ga:totalEvents=13   ga:uniqueEvents=9   &lt;/P&gt;

&lt;P&gt;My search for counting logins is:&lt;/P&gt;

&lt;P&gt;source="googleanalytics.txt" "ga:eventCategory=SessionEvent | ga:eventAction=UserLogin" | extract kvdelim="=" | timechart span=1d sum(totalEvents) as "Total Logins", sum(uniqueEvents) as "Unique Logins"&lt;/P&gt;

&lt;P&gt;The problem is that the search is taking the first occurrence of ga:totalEvents, regardless of if it is a UserLogin event or not. &lt;/P&gt;

&lt;P&gt;Edit: To be more clear, for the above example the timechart displays 6 total, 2 unique logins instead of the expected 13 total, 9 unique. The pipe inside the quotes is read as a search character, but I have removed it just to make sure, am seeing the same result when just searching for "ga:eventAction=UserLogin"&lt;/P&gt;</description>
      <pubDate>Fri, 04 Nov 2011 21:46:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Search-reads-first-event-instead-of-desired-event/m-p/104623#M22030</guid>
      <dc:creator>crobicha</dc:creator>
      <dc:date>2011-11-04T21:46:42Z</dc:date>
    </item>
    <item>
      <title>Re: Search reads first event instead of desired event</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Search-reads-first-event-instead-of-desired-event/m-p/104624#M22031</link>
      <description>&lt;P&gt;You must have mispasted your search - the "|ga:eventAction" would be a syntax error as Splunk would try to interpret that as a search command. Please check.&lt;/P&gt;</description>
      <pubDate>Sat, 05 Nov 2011 08:47:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Search-reads-first-event-instead-of-desired-event/m-p/104624#M22031</guid>
      <dc:creator>Ayn</dc:creator>
      <dc:date>2011-11-05T08:47:33Z</dc:date>
    </item>
    <item>
      <title>Re: Search reads first event instead of desired event</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Search-reads-first-event-instead-of-desired-event/m-p/104625#M22032</link>
      <description>&lt;P&gt;Why don't you try this instead:&lt;/P&gt;

&lt;P&gt;source="googleanalytics.txt" (ga:eventCategory="SessionEvent" OR ga:eventAction="UserLogin") | extract kvdelim="=" | timechart span=1d sum(totalEvents) as "Total Logins", sum(uniqueEvents) as "Unique Logins"&lt;/P&gt;</description>
      <pubDate>Sun, 06 Nov 2011 21:17:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Search-reads-first-event-instead-of-desired-event/m-p/104625#M22032</guid>
      <dc:creator>tgow</dc:creator>
      <dc:date>2011-11-06T21:17:19Z</dc:date>
    </item>
    <item>
      <title>Re: Search reads first event instead of desired event</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Search-reads-first-event-instead-of-desired-event/m-p/104626#M22033</link>
      <description>&lt;P&gt;I've run this in the search window and it does work, because it is in quotes splunk must recognize that it is a literal string and not a pipe&lt;/P&gt;</description>
      <pubDate>Mon, 07 Nov 2011 15:39:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Search-reads-first-event-instead-of-desired-event/m-p/104626#M22033</guid>
      <dc:creator>crobicha</dc:creator>
      <dc:date>2011-11-07T15:39:59Z</dc:date>
    </item>
    <item>
      <title>Re: Search reads first event instead of desired event</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Search-reads-first-event-instead-of-desired-event/m-p/104627#M22034</link>
      <description>&lt;P&gt;I may switch to this syntax since it is more clear and doesn't use the pipe, but this doesn't fix my issue.&lt;/P&gt;</description>
      <pubDate>Mon, 07 Nov 2011 15:49:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Search-reads-first-event-instead-of-desired-event/m-p/104627#M22034</guid>
      <dc:creator>crobicha</dc:creator>
      <dc:date>2011-11-07T15:49:40Z</dc:date>
    </item>
    <item>
      <title>Re: Search reads first event instead of desired event</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Search-reads-first-event-instead-of-desired-event/m-p/104628#M22035</link>
      <description>&lt;P&gt;I ended up using a regex after spending way too much time messing with sourcetypes and props.conf, this is my final search:&lt;/P&gt;

&lt;P&gt;source="googleanalytics.txt" "ga:eventCategory=SessionEvent | ga:eventAction=UserLogin" | rex field=_raw "ga:eventAction=UserLogin[\s]&lt;EM&gt;ga:totalEvents=(?&lt;TOTALEVENTS&gt;.&lt;/TOTALEVENTS&gt;&lt;/EM&gt;)[\s]&lt;EM&gt;ga:uniqueEvents=(?&lt;UNIQUEEVENTS&gt;.&lt;/UNIQUEEVENTS&gt;&lt;/EM&gt;)" | eval _time = _time - 172800 | timechart span=1d sum(totalEvents) as "Total Logins", sum(uniqueEvents) as "Unique Logins"&lt;/P&gt;

&lt;P&gt;The eval _time statement is because I haven't gotten splunk to pick up the timestamp in the log file properly, instead it timestamps the date when the script is run. GA data isnt guaranteed accurate until 48 hours later so the script pulls from the 24 period starting 3 days ago.&lt;/P&gt;</description>
      <pubDate>Fri, 18 Nov 2011 17:10:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Search-reads-first-event-instead-of-desired-event/m-p/104628#M22035</guid>
      <dc:creator>crobicha</dc:creator>
      <dc:date>2011-11-18T17:10:36Z</dc:date>
    </item>
  </channel>
</rss>

