<?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: Multiple Stats Multiple Indexes in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Multiple-Stats-Multiple-Indexes/m-p/538552#M152269</link>
    <description>&lt;P&gt;I am testing using source instead, but trying to figure out an issue wherein it doesn't recognise the field name.&amp;nbsp; I confirmed this with the eval and instead of "" did a "0" and this returns the "0" not the actual values of that field.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Will feedback once I work my way around it.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 04 Feb 2021 05:21:30 GMT</pubDate>
    <dc:creator>willadams</dc:creator>
    <dc:date>2021-02-04T05:21:30Z</dc:date>
    <item>
      <title>Multiple Stats Multiple Indexes</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Multiple-Stats-Multiple-Indexes/m-p/538411#M152202</link>
      <description>&lt;P&gt;I have 3 data sets that I need to combine with 1 data set not having a field to perform a compare.&amp;nbsp; I initially started with a join but moved away from that given the limited results returned and also to save on processing time of running the query.&amp;nbsp; My data sets are:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Users Index&lt;/STRONG&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=users sourcetype=userlist

This has the following fields

user_id
user_title
user_name&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Workstations Index&lt;/STRONG&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=workstations sourcetype=machines

This has the following fields

pc_id
pc_type
user_name&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I can then do a stats instead of join on this data using user_name as the "join".&amp;nbsp; So my query is as follows (note a user can have more than 1 PC hence the mvexpand to break into individual entries)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;(index=users sourcetype=userlist) OR (index=workstations sourcetype=machines)
| stats values(*) as * by user_name
| mvexpand pc_id
| table pc_id pc_type user_name&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I now want to take the information I have from this search with various other filters from another source (for example&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=windows sourcetype=connections which has lots of fields but I am only interested in the following

device_name
last_activity_time&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to be able to match the results from my combined search and extend this to check against the 3rd index, matching on device_name against pc_id.&amp;nbsp; I am thinking that my query might add another statement into the first line of my SPL for example&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;(i.e. index=users ...) OR (index=workstations .....) OR (index=windows | fields device_name last_activity_time)
| stats values(*) as * by user_name&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;however I don't think this will work as user_name is not a field in the "windows" index.&amp;nbsp; I am not sure how to now extend this to then look into another index without then doing a join.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Feb 2021 10:59:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Multiple-Stats-Multiple-Indexes/m-p/538411#M152202</guid>
      <dc:creator>willadams</dc:creator>
      <dc:date>2021-02-03T10:59:24Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple Stats Multiple Indexes</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Multiple-Stats-Multiple-Indexes/m-p/538459#M152225</link>
      <description>&lt;P&gt;hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/79922"&gt;@willadams&lt;/a&gt;,&lt;BR /&gt;Use&amp;nbsp;&lt;STRONG&gt;coalesce&lt;/STRONG&gt; function on fields&amp;nbsp;&lt;STRONG&gt;pc_id&lt;/STRONG&gt; and&amp;nbsp;&lt;STRONG&gt;device_name&lt;/STRONG&gt;, then do stats on &lt;STRONG&gt;pc_id&lt;/STRONG&gt; and &lt;STRONG&gt;user_name.&lt;/STRONG&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;(index=users sourcetype=userlist) OR (index=workstations sourcetype=machines) OR index=windows sourcetype=connections 
| fields user_id, user_title, user_name, pc_id, pc_type, device_name, last_activity_time
| eval pc_id=coalesce(pc_id, device_name)
| stats values(*) as * by pc_id, user_name
| mvexpand pc_id&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 03 Feb 2021 13:34:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Multiple-Stats-Multiple-Indexes/m-p/538459#M152225</guid>
      <dc:creator>manjunathmeti</dc:creator>
      <dc:date>2021-02-03T13:34:11Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple Stats Multiple Indexes</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Multiple-Stats-Multiple-Indexes/m-p/538538#M152257</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/129090"&gt;@manjunathmeti&lt;/a&gt;&amp;nbsp;thanks.&amp;nbsp; I have run into a problem though and realised that 2 of my indexers have the same field "names" in the index but different values.&amp;nbsp; Do you know if there is anyway to do a rename of the fields before stats based on the source of the data and then to do values as post processing?&amp;nbsp; For example&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=users sourcetype=userlist) OR (index=workstations sourcetype=machines) OR (index=windows sourcetype=connections | rename last_activity_time AS win_last_activity)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This will generate a error in search (unable to parse the search: unbalanced parentheses). I have tried adjusting to something similar such as&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=users sourcetype=userlist) OR (index=workstations sourcetype=machines) OR (index=windows sourcetype=connections [| rename last_activity_time AS win_last_activity])

or even

index=users sourcetype=userlist) OR (index=workstations sourcetype=machines) OR (index=windows sourcetype=connections (| rename last_activity_time AS win_last_activity))&lt;/LI-CODE&gt;&lt;P&gt;but have no luck so far. The only solution so far would suggest a change to my data source which would be a massive undertaking.&amp;nbsp; My only other thoughts may be to have a lookup table done from my last data set and change the values and then update this query using something like&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=users sourcetype=userlist) OR (index=workstations sourcetype=machines) OR (lookup pc_activity_log.csv)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;but would much prefer to keep it in a single query if at all possible.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Feb 2021 00:31:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Multiple-Stats-Multiple-Indexes/m-p/538538#M152257</guid>
      <dc:creator>willadams</dc:creator>
      <dc:date>2021-02-04T00:31:54Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple Stats Multiple Indexes</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Multiple-Stats-Multiple-Indexes/m-p/538542#M152260</link>
      <description>&lt;P&gt;I found a "dirty" way to then use the existing query and then run a join after to the additional data source&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Feb 2021 02:59:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Multiple-Stats-Multiple-Indexes/m-p/538542#M152260</guid>
      <dc:creator>willadams</dc:creator>
      <dc:date>2021-02-04T02:59:11Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple Stats Multiple Indexes</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Multiple-Stats-Multiple-Indexes/m-p/538548#M152266</link>
      <description>&lt;P&gt;You can create a new field based on the field name and assign value only if a particular index name matches.&lt;BR /&gt;Try this,&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=users sourcetype=userlist) OR (index=workstations sourcetype=machines) OR (index=windows sourcetype=connections) | eval win_last_activity=if(index="windows", last_activity_time, ""), work_last_activity=if(index="workstations", last_activity_time, "")&lt;/LI-CODE&gt;&lt;P&gt;And use win_last_activity and&amp;nbsp;work_last_activity&amp;nbsp;fields for the next operations.&lt;/P&gt;</description>
      <pubDate>Thu, 04 Feb 2021 04:50:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Multiple-Stats-Multiple-Indexes/m-p/538548#M152266</guid>
      <dc:creator>manjunathmeti</dc:creator>
      <dc:date>2021-02-04T04:50:47Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple Stats Multiple Indexes</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Multiple-Stats-Multiple-Indexes/m-p/538550#M152268</link>
      <description>&lt;P&gt;Thanks again&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/129090"&gt;@manjunathmeti&lt;/a&gt;.&amp;nbsp; Did consider the eval but was trying to do it in line with the multi-index search, however never considered to use eval with the if statement.&amp;nbsp; Will give it a crack and see what differences I have when my query has run.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Feb 2021 05:01:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Multiple-Stats-Multiple-Indexes/m-p/538550#M152268</guid>
      <dc:creator>willadams</dc:creator>
      <dc:date>2021-02-04T05:01:08Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple Stats Multiple Indexes</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Multiple-Stats-Multiple-Indexes/m-p/538552#M152269</link>
      <description>&lt;P&gt;I am testing using source instead, but trying to figure out an issue wherein it doesn't recognise the field name.&amp;nbsp; I confirmed this with the eval and instead of "" did a "0" and this returns the "0" not the actual values of that field.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Will feedback once I work my way around it.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Feb 2021 05:21:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Multiple-Stats-Multiple-Indexes/m-p/538552#M152269</guid>
      <dc:creator>willadams</dc:creator>
      <dc:date>2021-02-04T05:21:30Z</dc:date>
    </item>
  </channel>
</rss>

