<?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: tstats subsearch in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/tstats-subsearch/m-p/417748#M168595</link>
    <description>&lt;P&gt;Hi Simon,&lt;/P&gt;

&lt;P&gt;Yep when pasting the eval field value it returns values! It just doesn't appear to be setting the value to be the value of the field if that makes sense.&lt;/P&gt;

&lt;P&gt;Pete.&lt;/P&gt;</description>
    <pubDate>Wed, 04 Jul 2018 09:15:05 GMT</pubDate>
    <dc:creator>griggsy</dc:creator>
    <dc:date>2018-07-04T09:15:05Z</dc:date>
    <item>
      <title>tstats subsearch</title>
      <link>https://community.splunk.com/t5/Splunk-Search/tstats-subsearch/m-p/417735#M168582</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I have a tstats query working perfectly however I need to then cross reference a field returned with the data held in another index. Example query which I have shortened&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| tstats summariesonly=t  count FROM datamodel=Datamodel.Name WHERE earliest=@d latest=now datamodel.EventName="LOGIN_FAILED" by datamodel.EventName, datamodel.UserName 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;What I am after doing is then running some kind of subsearch to query another index to return more information about the user. I thought of doing something like &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| tstats summariesonly=t  count FROM datamodel=Datamodel.Name WHERE earliest=@d latest=now datamodel.EventName="LOGIN_FAILED" by datamodel.EventName, datamodel.UserName | [search index=ad Name=datamodel.UserName]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;However it doesn't seem to like it. Can someone point me in the correct direction I am banging my head on the wall!&lt;/P&gt;

&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Mon, 02 Jul 2018 11:43:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/tstats-subsearch/m-p/417735#M168582</guid>
      <dc:creator>griggsy</dc:creator>
      <dc:date>2018-07-02T11:43:01Z</dc:date>
    </item>
    <item>
      <title>Re: tstats subsearch</title>
      <link>https://community.splunk.com/t5/Splunk-Search/tstats-subsearch/m-p/417736#M168583</link>
      <description>&lt;P&gt;Hi, &lt;/P&gt;

&lt;P&gt;there are a few ways to do this. &lt;/P&gt;

&lt;P&gt;The first is to use a lookup with helps if you have more than 50k events that you want to link without hitting any limits. In this case you would need to use | outputlookup to create the csv with a search.&lt;/P&gt;

&lt;P&gt;otherwise you can use a join as so:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| tstats summariesonly=t  count FROM datamodel=Datamodel.Name WHERE earliest=@d latest=now 
    datamodel.EventName="LOGIN_FAILED" by datamodel.EventName, datamodel.UserName 
| join type=left datamodel.UserName
     [search index=ad 
       | rename Name=datamodel.UserName | table datamodel.UserName, (+ fields you want to return) ]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;A join might not be the most efficient way to do this if you are linking lots of records. If so it would be better to call up all the events from both indexes in the tstats command. This can be tricky using tstats though.&lt;/P&gt;

&lt;P&gt;Hope that helps,&lt;BR /&gt;
regards&lt;BR /&gt;
Simon&lt;/P&gt;</description>
      <pubDate>Mon, 02 Jul 2018 12:28:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/tstats-subsearch/m-p/417736#M168583</guid>
      <dc:creator>srichansen</dc:creator>
      <dc:date>2018-07-02T12:28:24Z</dc:date>
    </item>
    <item>
      <title>Re: tstats subsearch</title>
      <link>https://community.splunk.com/t5/Splunk-Search/tstats-subsearch/m-p/417737#M168584</link>
      <description>&lt;P&gt;ps. you will need to specify an earliest, latest in the sub search if the join data is in another time frame.&lt;/P&gt;</description>
      <pubDate>Mon, 02 Jul 2018 12:30:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/tstats-subsearch/m-p/417737#M168584</guid>
      <dc:creator>srichansen</dc:creator>
      <dc:date>2018-07-02T12:30:02Z</dc:date>
    </item>
    <item>
      <title>Re: tstats subsearch</title>
      <link>https://community.splunk.com/t5/Splunk-Search/tstats-subsearch/m-p/417738#M168585</link>
      <description>&lt;P&gt;Hi Simon,&lt;/P&gt;

&lt;P&gt;Thanks for the help.&lt;/P&gt;

&lt;P&gt;Here is where I am at:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| tstats summariesonly=t  count FROM datamodel=Datamodel.Name WHERE earliest=@d latest=now 
     datamodel.EventName="LOGIN_FAILED" by datamodel.EventName, datamodel.UserName 
| rename datamodel.* as * 
|  join type=left UserNameSplit [ search index=ad SamAccountName=UserNameSplit | table lastLogon]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But I don't appear to get anything being returned. the field lastLogon is being created in the table view but is just blank. Pulling my hair our with it now!&lt;/P&gt;</description>
      <pubDate>Tue, 03 Jul 2018 09:36:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/tstats-subsearch/m-p/417738#M168585</guid>
      <dc:creator>griggsy</dc:creator>
      <dc:date>2018-07-03T09:36:01Z</dc:date>
    </item>
    <item>
      <title>Re: tstats subsearch</title>
      <link>https://community.splunk.com/t5/Splunk-Search/tstats-subsearch/m-p/417739#M168586</link>
      <description>&lt;P&gt;are you trying to filter your search to where field SamAccountName=UserNameSplit or are you trying to rename it?  if you want to rename it you will need to add "| rename SamAccountName as UserNameSplit":&lt;/P&gt;

&lt;P&gt;further i think you need to have the join field in your table results as below:&lt;/P&gt;

&lt;P&gt;| tstats summariesonly=t  count FROM datamodel=Datamodel.Name WHERE earliest=@d latest=now &lt;BR /&gt;
      datamodel.EventName="LOGIN_FAILED" by datamodel.EventName, datamodel.UserName &lt;BR /&gt;
 | rename datamodel.* as * &lt;BR /&gt;
 |  join type=left UserNameSplit [ search index=ad | rename SamAccountName as UserNameSplit | table UserNameSplit, lastLogon]&lt;/P&gt;

&lt;P&gt;hopefully that will give results.&lt;/P&gt;</description>
      <pubDate>Tue, 03 Jul 2018 09:44:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/tstats-subsearch/m-p/417739#M168586</guid>
      <dc:creator>srichansen</dc:creator>
      <dc:date>2018-07-03T09:44:48Z</dc:date>
    </item>
    <item>
      <title>Re: tstats subsearch</title>
      <link>https://community.splunk.com/t5/Splunk-Search/tstats-subsearch/m-p/417740#M168587</link>
      <description>&lt;P&gt;Hi Simon.&lt;/P&gt;

&lt;P&gt;UserNameSplit is an eval field to drop the domain name etc from the value. I want to search for SamAccountName where the value is UserNameSplit if that makes sense?&lt;/P&gt;

&lt;P&gt;So instead of SamAccountName="JoeBloggs" UserNameSplit would = "JoeBloggs" and we would use UserNameSplit to do the search?&lt;/P&gt;

&lt;P&gt;I need coffee&lt;/P&gt;</description>
      <pubDate>Tue, 03 Jul 2018 10:05:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/tstats-subsearch/m-p/417740#M168587</guid>
      <dc:creator>griggsy</dc:creator>
      <dc:date>2018-07-03T10:05:08Z</dc:date>
    </item>
    <item>
      <title>Re: tstats subsearch</title>
      <link>https://community.splunk.com/t5/Splunk-Search/tstats-subsearch/m-p/417741#M168588</link>
      <description>&lt;P&gt;Ok,  so join works by having two fields with the same field name and values.&lt;/P&gt;

&lt;P&gt;If your field with users is the following:&lt;BR /&gt;
tstats search its "UserNameSplit"   and&lt;BR /&gt;
sub search its "SamAccountName"&lt;/P&gt;

&lt;P&gt;you will need to rename one of them to match the other.&lt;/P&gt;

&lt;P&gt;in my example I renamed the sub search field with  "| rename SamAccountName as UserNameSplit"&lt;/P&gt;

&lt;P&gt;the part of the join statement "| join type=left &lt;STRONG&gt;UserNameSplit&lt;/STRONG&gt;" tells splunk on which field to link. As long as you have renamed the fields and the values are the same it should return values.&lt;/P&gt;

&lt;P&gt;You can check if anything is linking by removing the "type=left" from the join. This will make the join only return matched record as apposed to all tstats records. &lt;/P&gt;

&lt;P&gt;If you are still not seeing anything then it might be that your sub search time frame is not right. In you tstats you are searching "earliest=@d latest=now". Is the data in you sub search for the same period?&lt;/P&gt;</description>
      <pubDate>Tue, 03 Jul 2018 10:21:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/tstats-subsearch/m-p/417741#M168588</guid>
      <dc:creator>srichansen</dc:creator>
      <dc:date>2018-07-03T10:21:24Z</dc:date>
    </item>
    <item>
      <title>Re: tstats subsearch</title>
      <link>https://community.splunk.com/t5/Splunk-Search/tstats-subsearch/m-p/417742#M168589</link>
      <description>&lt;P&gt;Hi Simon,&lt;/P&gt;

&lt;P&gt;Thanks again for the help.&lt;/P&gt;

&lt;P&gt;I have updated the eval command to be SamAccountName instead of UserNameSplit so the last line of the search is:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval SameAccountName=mvindex(split(UserName,"\\"),-1) | join type-left SamAccountName [search index=ad SamAccountName earliest=@d latest=now | table SamAccountName, lastLogon]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;and just don't appear to be pulling any data in from the AD index. I know the data is there and field names are correct as can run a normal search on the index with one of the username as:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=ad SamAccountName="JoeBloggs" | table SamAccountName, lastLogon
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Sorry to be a pain!&lt;/P&gt;</description>
      <pubDate>Tue, 03 Jul 2018 10:46:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/tstats-subsearch/m-p/417742#M168589</guid>
      <dc:creator>griggsy</dc:creator>
      <dc:date>2018-07-03T10:46:37Z</dc:date>
    </item>
    <item>
      <title>Re: tstats subsearch</title>
      <link>https://community.splunk.com/t5/Splunk-Search/tstats-subsearch/m-p/417743#M168590</link>
      <description>&lt;P&gt;it is probably your sub search time period.&lt;/P&gt;

&lt;P&gt;when you get a result using  &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=ad SamAccountName="JoeBloggs" | table SamAccountName, lastLogon
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;what is the event time? Is it the within the day periode and does it give the same result as &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=ad SamAccountName="JoeBloggs" earliest=@d latest=now | table SamAccountName, lastLogon
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Do you get results if you change it to the following:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| tstats summariesonly=t  count FROM datamodel=Datamodel.Name WHERE earliest=@d latest=now 
      datamodel.EventName="LOGIN_FAILED" by datamodel.EventName, datamodel.UserName 
 | rename datamodel.* as * 
 | eval SameAccountName=mvindex(split(UserName,"\\"),-1)
 | join type=left SamAccountName
     [search index=ad earliest=-1 latest=now | stats latest(lastLogon) as lastLogon by SamAccountName]
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 03 Jul 2018 11:35:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/tstats-subsearch/m-p/417743#M168590</guid>
      <dc:creator>srichansen</dc:creator>
      <dc:date>2018-07-03T11:35:11Z</dc:date>
    </item>
    <item>
      <title>Re: tstats subsearch</title>
      <link>https://community.splunk.com/t5/Splunk-Search/tstats-subsearch/m-p/417744#M168591</link>
      <description>&lt;P&gt;Hi Simon,&lt;/P&gt;

&lt;P&gt;I have tried with the time range in the AD search straight from the index and get the same result.&lt;/P&gt;

&lt;P&gt;However still nothing on the tstats query with the above changes - thanks for all your help by the way!&lt;/P&gt;</description>
      <pubDate>Tue, 03 Jul 2018 11:43:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/tstats-subsearch/m-p/417744#M168591</guid>
      <dc:creator>griggsy</dc:creator>
      <dc:date>2018-07-03T11:43:44Z</dc:date>
    </item>
    <item>
      <title>Re: tstats subsearch</title>
      <link>https://community.splunk.com/t5/Splunk-Search/tstats-subsearch/m-p/417745#M168592</link>
      <description>&lt;P&gt;I tried to clean it up a bit and found a type-o in the field names. Does this work?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| tstats summariesonly=t count FROM datamodel=Datamodel.Name WHERE earliest=@d latest=now AND datamodel.EventName="LOGIN_FAILED" by datamodel.UserName 
| eval SameAccountName=mvindex(split(datamodel.UserName,"\\"),-1) 
| join type=left SameAccountName 
    [ search index=ad earliest=-1 latest=now 
    | stats latest(lastLogon) as lastLogon by SameAccountName]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Glad to help, hopefully we can get it working.&lt;/P&gt;</description>
      <pubDate>Tue, 03 Jul 2018 11:53:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/tstats-subsearch/m-p/417745#M168592</guid>
      <dc:creator>srichansen</dc:creator>
      <dc:date>2018-07-03T11:53:00Z</dc:date>
    </item>
    <item>
      <title>Re: tstats subsearch</title>
      <link>https://community.splunk.com/t5/Splunk-Search/tstats-subsearch/m-p/417746#M168593</link>
      <description>&lt;P&gt;Hi Simon,&lt;/P&gt;

&lt;P&gt;Unfortunately not - the field is called SamAccountName (it's an AD field) &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;I now have it running and returning fields if I manually set the eval field as &lt;CODE&gt;eval SamAccountName=JoeBloggs&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;So the last line of query looks like:&lt;/P&gt;

&lt;P&gt;|eval SamAccountName="JoeBloggs" | join type=left SamAccountName [ search index=ad SamAccountName="JoeBloggs" ]&lt;/P&gt;

&lt;P&gt;If I put | table lastLogon or any other fields I don't get the data back from the index.&lt;/P&gt;

&lt;P&gt;So my problem at moment is getting the search to set SamAccountName to be SamAccountName and then just returning certain fields. If I have to return them all its not end of world but want it to be clean really.&lt;/P&gt;

&lt;P&gt;I have tried using the field selector and this also stops it returning data. Cheers again!&lt;/P&gt;</description>
      <pubDate>Tue, 03 Jul 2018 13:25:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/tstats-subsearch/m-p/417746#M168593</guid>
      <dc:creator>griggsy</dc:creator>
      <dc:date>2018-07-03T13:25:11Z</dc:date>
    </item>
    <item>
      <title>Re: tstats subsearch</title>
      <link>https://community.splunk.com/t5/Splunk-Search/tstats-subsearch/m-p/417747#M168594</link>
      <description>&lt;P&gt;That is strange.&lt;/P&gt;

&lt;P&gt;The only think i can think of is that the format of the user names is not the same.&lt;/P&gt;

&lt;P&gt;I would suggest running &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| tstats summariesonly=t count FROM datamodel=Datamodel.Name WHERE earliest=@d latest=now AND datamodel.EventName="LOGIN_FAILED" by datamodel.UserName 
 | eval SamAccountName=mvindex(split(datamodel.UserName,"\\"),-1)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;then copying a name out the SamAccountName field and pasting it in the following to see if you get a result.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=tfl_ad SamAccountName="*pasteduser*"  | stats latest(lastLogon) as lastLogon by SamAccountName
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 04 Jul 2018 07:41:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/tstats-subsearch/m-p/417747#M168594</guid>
      <dc:creator>srichansen</dc:creator>
      <dc:date>2018-07-04T07:41:11Z</dc:date>
    </item>
    <item>
      <title>Re: tstats subsearch</title>
      <link>https://community.splunk.com/t5/Splunk-Search/tstats-subsearch/m-p/417748#M168595</link>
      <description>&lt;P&gt;Hi Simon,&lt;/P&gt;

&lt;P&gt;Yep when pasting the eval field value it returns values! It just doesn't appear to be setting the value to be the value of the field if that makes sense.&lt;/P&gt;

&lt;P&gt;Pete.&lt;/P&gt;</description>
      <pubDate>Wed, 04 Jul 2018 09:15:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/tstats-subsearch/m-p/417748#M168595</guid>
      <dc:creator>griggsy</dc:creator>
      <dc:date>2018-07-04T09:15:05Z</dc:date>
    </item>
    <item>
      <title>Re: tstats subsearch</title>
      <link>https://community.splunk.com/t5/Splunk-Search/tstats-subsearch/m-p/417749#M168596</link>
      <description>&lt;P&gt;That is strange, there must be something that is causeing it to fail in the syntax&lt;/P&gt;

&lt;P&gt;Is it possible to paste the exact search you are running?&lt;/P&gt;</description>
      <pubDate>Thu, 05 Jul 2018 08:00:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/tstats-subsearch/m-p/417749#M168596</guid>
      <dc:creator>srichansen</dc:creator>
      <dc:date>2018-07-05T08:00:41Z</dc:date>
    </item>
  </channel>
</rss>

