<?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: Should I use Lookup or mvexpand in the following search? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Should-I-use-Lookup-or-mvexpand-in-the-following-search/m-p/422059#M121219</link>
    <description>&lt;P&gt;No, that will not work.&lt;/P&gt;</description>
    <pubDate>Mon, 18 Feb 2019 23:24:36 GMT</pubDate>
    <dc:creator>woodcock</dc:creator>
    <dc:date>2019-02-18T23:24:36Z</dc:date>
    <item>
      <title>Should I use Lookup or mvexpand in the following search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Should-I-use-Lookup-or-mvexpand-in-the-following-search/m-p/422035#M121195</link>
      <description>&lt;P&gt;I have a search that returns a list of namespace values. &lt;/P&gt;

&lt;P&gt;I want to take each one of those namespace values and run streamstats on it by doing a &lt;CODE&gt;...|search namespace=&amp;lt;namespace&amp;gt; | streamstats...&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;I tried doing a by namespace in my streamstats, but for some reason, it doesn't work and the only way it seems to work is with the pre-search by a single namespace  ahead of time... &lt;/P&gt;

&lt;P&gt;How do I accomplish this? &lt;/P&gt;

&lt;P&gt;current search&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;source="/var/log/lag/stats.txt" d=* 
| eval namespace=trim(replace(namespace,"sample-text.",""))
| eval Processed_time=_time
| search namespace=HeartBeat
| streamstats current=false window=500 last(count) as prev_count earliest(Processed_time) as time_of_last_change by namespace 
| where prev_count != count
| eval actualchange=prev_count-count
| streamstats current=false window=2 range(Processed_time) AS diffoflastchange by namespace
| eval diffoflastchange=round(diffoflastchange)
| eval changeformatted=tostring(diffoflastchange,"duration")
| stats range(diffoflastchange) as totalrange by namespace
| eval totalrangeformat=tostring(totalrange,"duration")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Sure thing! events are really super basic....&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;d=12/14/18 02:15:01 PM UTC namespace=Sample,count=5400315
d=12/14/18 02:18:01 PM UTC namespace=HeartBeat,count=5400610
d=12/14/18 02:21:01 PM UTC namespace=Sample,count=5400927
d=12/14/18 02:24:01 PM UTC namespace=HeartBeat,count=5400815
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;So I'd expect my output to be&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;HeartBeat Avg Update Span = Sample Avg&lt;BR /&gt;
Update Span =&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Mon, 03 Dec 2018 20:18:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Should-I-use-Lookup-or-mvexpand-in-the-following-search/m-p/422035#M121195</guid>
      <dc:creator>tb5821</dc:creator>
      <dc:date>2018-12-03T20:18:35Z</dc:date>
    </item>
    <item>
      <title>Re: Should I use Lookup or mvexpand in the following search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Should-I-use-Lookup-or-mvexpand-in-the-following-search/m-p/422036#M121196</link>
      <description>&lt;P&gt;Please provide your current search.&lt;/P&gt;</description>
      <pubDate>Mon, 03 Dec 2018 22:08:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Should-I-use-Lookup-or-mvexpand-in-the-following-search/m-p/422036#M121196</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2018-12-03T22:08:26Z</dc:date>
    </item>
    <item>
      <title>Re: Should I use Lookup or mvexpand in the following search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Should-I-use-Lookup-or-mvexpand-in-the-following-search/m-p/422037#M121197</link>
      <description>&lt;P&gt;updated original question&lt;/P&gt;</description>
      <pubDate>Fri, 07 Dec 2018 16:42:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Should-I-use-Lookup-or-mvexpand-in-the-following-search/m-p/422037#M121197</guid>
      <dc:creator>tb5821</dc:creator>
      <dc:date>2018-12-07T16:42:37Z</dc:date>
    </item>
    <item>
      <title>Re: Should I use Lookup or mvexpand in the following search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Should-I-use-Lookup-or-mvexpand-in-the-following-search/m-p/422038#M121198</link>
      <description>&lt;P&gt;&lt;CODE&gt;lookup&lt;/CODE&gt; and &lt;CODE&gt;mvexpand&lt;/CODE&gt; are very different commands, ones not typically used interchangeably.  To help with your search it's important to know what your end goal is.  Don't tell us what commands you want to run, tell us in normal language what results you want.  Then we'll try to help you get there.&lt;/P&gt;</description>
      <pubDate>Thu, 13 Dec 2018 11:19:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Should-I-use-Lookup-or-mvexpand-in-the-following-search/m-p/422038#M121198</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2018-12-13T11:19:47Z</dc:date>
    </item>
    <item>
      <title>Re: Should I use Lookup or mvexpand in the following search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Should-I-use-Lookup-or-mvexpand-in-the-following-search/m-p/422039#M121199</link>
      <description>&lt;P&gt;what I want is by the field NAMESPACE to get the average timebetween updates for the last x days &lt;/P&gt;</description>
      <pubDate>Thu, 13 Dec 2018 14:13:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Should-I-use-Lookup-or-mvexpand-in-the-following-search/m-p/422039#M121199</guid>
      <dc:creator>tb5821</dc:creator>
      <dc:date>2018-12-13T14:13:17Z</dc:date>
    </item>
    <item>
      <title>Re: Should I use Lookup or mvexpand in the following search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Should-I-use-Lookup-or-mvexpand-in-the-following-search/m-p/422040#M121200</link>
      <description>&lt;P&gt;Can you paste some sample events here ? I do similar thing in my env, calculating the difference between two similar events. I can help you with this one.&lt;/P&gt;</description>
      <pubDate>Fri, 14 Dec 2018 05:42:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Should-I-use-Lookup-or-mvexpand-in-the-following-search/m-p/422040#M121200</guid>
      <dc:creator>macadminrohit</dc:creator>
      <dc:date>2018-12-14T05:42:27Z</dc:date>
    </item>
    <item>
      <title>Re: Should I use Lookup or mvexpand in the following search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Should-I-use-Lookup-or-mvexpand-in-the-following-search/m-p/422041#M121201</link>
      <description>&lt;P&gt;updated main question with samples etc&lt;/P&gt;</description>
      <pubDate>Fri, 14 Dec 2018 14:54:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Should-I-use-Lookup-or-mvexpand-in-the-following-search/m-p/422041#M121201</guid>
      <dc:creator>tb5821</dc:creator>
      <dc:date>2018-12-14T14:54:21Z</dc:date>
    </item>
    <item>
      <title>Re: Should I use Lookup or mvexpand in the following search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Should-I-use-Lookup-or-mvexpand-in-the-following-search/m-p/422042#M121202</link>
      <description>&lt;P&gt;So you want something like this?&lt;/P&gt;

&lt;P&gt;namespace avg(Count) last(Update _time)  duration(between the same namespace events)&lt;/P&gt;</description>
      <pubDate>Fri, 14 Dec 2018 15:59:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Should-I-use-Lookup-or-mvexpand-in-the-following-search/m-p/422042#M121202</guid>
      <dc:creator>macadminrohit</dc:creator>
      <dc:date>2018-12-14T15:59:14Z</dc:date>
    </item>
    <item>
      <title>Re: Should I use Lookup or mvexpand in the following search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Should-I-use-Lookup-or-mvexpand-in-the-following-search/m-p/422043#M121203</link>
      <description>&lt;P&gt;Try something like this , I am not sure what is &lt;CODE&gt;update&lt;/CODE&gt; in your final results . I am assuming your fields correspond to :&lt;/P&gt;

&lt;P&gt;Avg=Average of count of same namespace events.&lt;BR /&gt;
Update= ?&lt;BR /&gt;
Span= duration between same namespace events.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval DATA="d=12/14/18 02:15:01 PM UTC namespace=Sample count=5400315,d=12/14/18 02:18:01 PM UTC namespace=HeartBeat count=5400610,d=12/14/18 02:21:01 PM UTC namespace=Sample count=5400927,d=12/14/18 02:24:01 PM UTC namespace=HeartBeat count=5400815" 
| makemv DATA delim="," 
| mvexpand DATA 
| rex field=DATA "namespace\=(?&amp;lt;namespace&amp;gt;\w+)\scount\=(?&amp;lt;count&amp;gt;\d+)" 
| table _time count namespace 
| streamstats count as nb 
| eval _time = _time + 120*nb 
| sort 0 namespace 
| table _time namespace count 
| streamstats count as RecordNumber by namespace reset_on_change=true 
| streamstats current=f last(_time) as LastTime last(RecordNumber) As previousRecord 
| eval change = if(RecordNumber-previousRecord!=1,"Yes","No")
| eval span=case(change="No",(_time-LastTime))
| fillnull span Value=0 | eventstats avg(count) as Avg_Count by namespace 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 14 Dec 2018 16:36:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Should-I-use-Lookup-or-mvexpand-in-the-following-search/m-p/422043#M121203</guid>
      <dc:creator>macadminrohit</dc:creator>
      <dc:date>2018-12-14T16:36:11Z</dc:date>
    </item>
    <item>
      <title>Re: Should I use Lookup or mvexpand in the following search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Should-I-use-Lookup-or-mvexpand-in-the-following-search/m-p/422044#M121204</link>
      <description>&lt;P&gt;I have intentionally added a gap of 2 minutes between the events to test this.&lt;/P&gt;</description>
      <pubDate>Fri, 14 Dec 2018 16:37:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Should-I-use-Lookup-or-mvexpand-in-the-following-search/m-p/422044#M121204</guid>
      <dc:creator>macadminrohit</dc:creator>
      <dc:date>2018-12-14T16:37:49Z</dc:date>
    </item>
    <item>
      <title>Re: Should I use Lookup or mvexpand in the following search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Should-I-use-Lookup-or-mvexpand-in-the-following-search/m-p/422045#M121205</link>
      <description>&lt;P&gt;There is no reason to filter at all if you can use &lt;CODE&gt;streamstats&lt;/CODE&gt;, just make sure that you use the &lt;CODE&gt;BY&lt;/CODE&gt; clause appropriately.  You are definitely doing some things in your search that don't fit (i.e. &lt;CODE&gt;| eval changeformatted=tostring(diffoflastchange,"duration") &lt;BR /&gt;
&lt;/CODE&gt;, which creates a field that is not used by and is discarded by the following &lt;CODE&gt;| stats&lt;/CODE&gt;).  Also, your &lt;CODE&gt;window=500&lt;/CODE&gt; seems misplaced.  Does this do pretty much what you'd expect?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=_* count=*
| rename sourcetype AS namespace 
| replace splunkd WITH "HeartBeat" IN namespace 
| eval Processed_time=_time 
| streamstats current=false last(count) as prev_count earliest(Processed_time) as time_of_last_change by namespace 
| where prev_count != count 
| eval actualchange=prev_count-count 
| streamstats current=false window=2 range(Processed_time) AS diffoflastchange by namespace 
| eval diffoflastchange=round(diffoflastchange) 
| stats range(diffoflastchange) as totalrange by namespace 
| eval totalrangeformat=tostring(totalrange,"duration")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 14 Dec 2018 18:13:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Should-I-use-Lookup-or-mvexpand-in-the-following-search/m-p/422045#M121205</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2018-12-14T18:13:37Z</dc:date>
    </item>
    <item>
      <title>Re: Should I use Lookup or mvexpand in the following search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Should-I-use-Lookup-or-mvexpand-in-the-following-search/m-p/422046#M121206</link>
      <description>&lt;P&gt;hmmm haven't tried this YET but can you explain what this is doing and how its helping? &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rename sourcetype AS namespace 
 | replace splunkd WITH "HeartBeat" IN namespace 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I'm not looking at souretype as a field nor splunkd ? &lt;/P&gt;</description>
      <pubDate>Fri, 14 Dec 2018 20:21:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Should-I-use-Lookup-or-mvexpand-in-the-following-search/m-p/422046#M121206</guid>
      <dc:creator>tb5821</dc:creator>
      <dc:date>2018-12-14T20:21:43Z</dc:date>
    </item>
    <item>
      <title>Re: Should I use Lookup or mvexpand in the following search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Should-I-use-Lookup-or-mvexpand-in-the-following-search/m-p/422047#M121207</link>
      <description>&lt;P&gt;I don't have your data so I munged some data that everybody has and forced it to look like your data so that I could see what your search is doing.  Obviously, you don't need those lines.&lt;/P&gt;</description>
      <pubDate>Fri, 14 Dec 2018 20:33:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Should-I-use-Lookup-or-mvexpand-in-the-following-search/m-p/422047#M121207</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2018-12-14T20:33:48Z</dc:date>
    </item>
    <item>
      <title>Re: Should I use Lookup or mvexpand in the following search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Should-I-use-Lookup-or-mvexpand-in-the-following-search/m-p/422048#M121208</link>
      <description>&lt;P&gt;SO running this query - aside from the rename/replace commands on my statistics tab only gives me a list of namespaces with a blank column for totalrange which is the exact problem I was having earlier - thus adding a secondary search right before the streamstats command that only looks at ONE namespace will work for that one but why can't I get this to work for all of them? &lt;/P&gt;</description>
      <pubDate>Fri, 14 Dec 2018 20:52:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Should-I-use-Lookup-or-mvexpand-in-the-following-search/m-p/422048#M121208</guid>
      <dc:creator>tb5821</dc:creator>
      <dc:date>2018-12-14T20:52:51Z</dc:date>
    </item>
    <item>
      <title>Re: Should I use Lookup or mvexpand in the following search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Should-I-use-Lookup-or-mvexpand-in-the-following-search/m-p/422049#M121209</link>
      <description>&lt;P&gt;But my search does not have blanks.  That is the point.  It must be that your data for some/all of the other namespace values do not have the fields necessary to generate the values that you are needed.&lt;/P&gt;</description>
      <pubDate>Fri, 14 Dec 2018 21:47:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Should-I-use-Lookup-or-mvexpand-in-the-following-search/m-p/422049#M121209</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2018-12-14T21:47:11Z</dc:date>
    </item>
    <item>
      <title>Re: Should I use Lookup or mvexpand in the following search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Should-I-use-Lookup-or-mvexpand-in-the-following-search/m-p/422050#M121210</link>
      <description>&lt;P&gt;What do you get from just:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;source="/var/log/lag/stats.txt" d=* 
 | eval namespace=trim(replace(namespace,"sample-text.",""))
 | eval Processed_time=_time
 | stats count by namespace
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Are you getting all the namespace values you expect?&lt;/P&gt;</description>
      <pubDate>Fri, 21 Dec 2018 22:14:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Should-I-use-Lookup-or-mvexpand-in-the-following-search/m-p/422050#M121210</guid>
      <dc:creator>cpetterborg</dc:creator>
      <dc:date>2018-12-21T22:14:17Z</dc:date>
    </item>
    <item>
      <title>Re: Should I use Lookup or mvexpand in the following search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Should-I-use-Lookup-or-mvexpand-in-the-following-search/m-p/422051#M121211</link>
      <description>&lt;P&gt;Sorry, finally getting back to this! &lt;/P&gt;

&lt;P&gt;that query above produces all the namespaces each one has the same count. &lt;/P&gt;

&lt;P&gt;Thoughts?? &lt;/P&gt;</description>
      <pubDate>Sat, 05 Jan 2019 18:15:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Should-I-use-Lookup-or-mvexpand-in-the-following-search/m-p/422051#M121211</guid>
      <dc:creator>tb5821</dc:creator>
      <dc:date>2019-01-05T18:15:56Z</dc:date>
    </item>
    <item>
      <title>Re: Should I use Lookup or mvexpand in the following search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Should-I-use-Lookup-or-mvexpand-in-the-following-search/m-p/422052#M121212</link>
      <description>&lt;P&gt;maybe adding a fillnull if thats the case? hmmm &lt;/P&gt;</description>
      <pubDate>Sat, 05 Jan 2019 18:16:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Should-I-use-Lookup-or-mvexpand-in-the-following-search/m-p/422052#M121212</guid>
      <dc:creator>tb5821</dc:creator>
      <dc:date>2019-01-05T18:16:39Z</dc:date>
    </item>
    <item>
      <title>Re: Should I use Lookup or mvexpand in the following search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Should-I-use-Lookup-or-mvexpand-in-the-following-search/m-p/422053#M121213</link>
      <description>&lt;P&gt;uhhh nope - that didn't work &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt; &lt;/P&gt;</description>
      <pubDate>Sat, 05 Jan 2019 18:23:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Should-I-use-Lookup-or-mvexpand-in-the-following-search/m-p/422053#M121213</guid>
      <dc:creator>tb5821</dc:creator>
      <dc:date>2019-01-05T18:23:03Z</dc:date>
    </item>
    <item>
      <title>Re: Should I use Lookup or mvexpand in the following search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Should-I-use-Lookup-or-mvexpand-in-the-following-search/m-p/422054#M121214</link>
      <description>&lt;P&gt;following back up here @woodcock @cpetterborg &lt;/P&gt;</description>
      <pubDate>Fri, 11 Jan 2019 14:23:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Should-I-use-Lookup-or-mvexpand-in-the-following-search/m-p/422054#M121214</guid>
      <dc:creator>tb5821</dc:creator>
      <dc:date>2019-01-11T14:23:43Z</dc:date>
    </item>
  </channel>
</rss>

