<?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 get fields across different events - via eval and search/where? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-fields-across-different-events-via-eval-and-search/m-p/641455#M222225</link>
    <description>&lt;P&gt;The &lt;FONT face="courier new,courier"&gt;append&lt;/FONT&gt; command adds its results to the bottom of the current result set.&amp;nbsp; If the main search returns results "foo" and "bar" and the &lt;FONT face="courier new,courier"&gt;append&lt;/FONT&gt; returns "baz" and "bat" then the final resullt will be&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;foo
bar
baz
bat&lt;/LI-CODE&gt;&lt;P&gt;No relationship is made among any of the results.&amp;nbsp; You need to do that yourself.&amp;nbsp; Usually, that's done with the &lt;FONT face="courier new,courier"&gt;stats&lt;/FONT&gt; command using any field(s) common to all results.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;&amp;lt;main search&amp;gt;&amp;gt;
| append [ &amp;lt;&amp;lt;some other search&amp;gt;&amp;gt; ]
| stats values(*) as * by blah&lt;/LI-CODE&gt;</description>
    <pubDate>Wed, 26 Apr 2023 14:42:20 GMT</pubDate>
    <dc:creator>richgalloway</dc:creator>
    <dc:date>2023-04-26T14:42:20Z</dc:date>
    <item>
      <title>How to get fields across different events - via eval and search/where?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-fields-across-different-events-via-eval-and-search/m-p/641335#M222191</link>
      <description>&lt;P&gt;Is there an easy way of capturing the fields across different events?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;example:&lt;/P&gt;
&lt;P&gt;event 1)&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;abc: {&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;build: 123&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;duration: 1.1&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;sw: gen1&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;hardware: h1&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;event 2)&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; def: {&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;build: 124&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;duration: 1.4&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;sw: gen2&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;hardware: h2&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;
&lt;P&gt;|rename abc.duration as a_duration, def.duration as d_duration&lt;/P&gt;
&lt;P&gt;| stats avg(d_duration) as avg_d_duration, avg(a_duration) as avg_a_duration by def.build, def.hardware&lt;BR /&gt;| eval avg_d_duration = round(avg(avg_d_duration),3)&lt;/P&gt;
&lt;P&gt;| eval avg_a_duration=abc.duration &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;= this is a limit line I want to implement based on the next search&amp;nbsp;&lt;/P&gt;
&lt;P&gt;| search abc.build="123", &amp;nbsp;abc.hardware="h1"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;NOTE:&lt;/P&gt;
&lt;P&gt;There's multiple events similar to event1 &amp;amp; event2. &amp;nbsp;the differences between event1 &amp;amp; event2 are the different sw versions.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Problem:&lt;/P&gt;
&lt;P&gt;I am not able to specify a search/where to get the abc.duration. &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Question:&lt;/P&gt;
&lt;P&gt;1) How can I add a search at the end, so I can query the data from a different event?&lt;/P&gt;</description>
      <pubDate>Tue, 25 Apr 2023 19:30:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-fields-across-different-events-via-eval-and-search/m-p/641335#M222191</guid>
      <dc:creator>GaryZ</dc:creator>
      <dc:date>2023-04-25T19:30:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to get fields across different events - via eval and search/where?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-fields-across-different-events-via-eval-and-search/m-p/641345#M222193</link>
      <description>&lt;P&gt;The abc.duration and abc.hardware fields were discarded by the &lt;FONT face="courier new,courier"&gt;stats&lt;/FONT&gt; command so they are not available to any commands that follow.&amp;nbsp; This is the nature of transforming commands like &lt;FONT face="courier new,courier"&gt;stats&lt;/FONT&gt;.&lt;/P&gt;&lt;P&gt;If you need to add data from another event then use the &lt;FONT face="courier new,courier"&gt;append&lt;/FONT&gt; command to add on a query for the desired event.&amp;nbsp; You then will need to merge the results based on shared field(s).&lt;/P&gt;</description>
      <pubDate>Tue, 25 Apr 2023 20:50:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-fields-across-different-events-via-eval-and-search/m-p/641345#M222193</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2023-04-25T20:50:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to get fields across different events - via eval and search/where?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-fields-across-different-events-via-eval-and-search/m-p/641347#M222195</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/213957"&gt;@richgalloway&lt;/a&gt;&amp;nbsp;If I want a single value from one of the event, but I want to extend this for all the results captured from the later stats, how would I do that? &amp;nbsp;&lt;/P&gt;&lt;P&gt;At the moment, when I use append, that only appends the first result with the latter result. &amp;nbsp;This is still the case even if I specify the same variable in both stats.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ie.&amp;nbsp;&lt;/P&gt;&lt;P&gt;example1&lt;/P&gt;&lt;P&gt;| stats avg(avg(a_duration) as avg_a_duration by def.build, def.hardware&lt;/P&gt;&lt;P&gt;| append [ ...&lt;/P&gt;&lt;P&gt;| stats avg(d_duration) as avg_d_duration, avg(avg_a_duration) &amp;nbsp;by def.build, def.hardwareeval avg_d_duration = round(avg(avg_d_duration),3)&lt;/P&gt;&lt;P&gt;]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;example2&lt;/P&gt;&lt;P&gt;| stats avg(avg(a_duration) as avg_a_duration by def.build, def.hardware&lt;/P&gt;&lt;P&gt;|eval avg_a_duration = round(avg(avg_a_duration),2)&lt;/P&gt;&lt;P&gt;| append [ ...&lt;/P&gt;&lt;P&gt;| stats avg(d_duration) as avg_d_duration, avg(g_duration) &amp;nbsp;by def.build, def.hardware&amp;nbsp;&lt;/P&gt;&lt;P&gt;]&lt;/P&gt;&lt;P&gt;g_duration = avg_a_duration&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;example3:&lt;/P&gt;&lt;P&gt;| stats avg(avg(a_duration) as avg_a_duration by def.build, def.hardware&lt;/P&gt;&lt;P&gt;|eval avg_a_duration = round(avg(avg_a_duration),2)&lt;/P&gt;&lt;P&gt;| append [ ...&lt;/P&gt;&lt;P&gt;| stats avg(d_duration) as avg_d_duration, avg(avg_a_duration) &amp;nbsp;by def.build, def.hardware&lt;/P&gt;&lt;P&gt;|eval avg_d_duration = round(avg(avg_d_duration),3)&lt;/P&gt;&lt;P&gt;]&lt;/P&gt;&lt;P&gt;avg_a_duration = 10&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In Example1, I see the results from the first search appended to the second search&lt;/P&gt;&lt;P&gt;In Example 2, I see the same results as in example1, but just a different column - 'g_duration'&lt;/P&gt;&lt;P&gt;In Example 3, I see avg_a_duration is constant for both appended search results. &amp;nbsp; &amp;nbsp; &amp;lt;= This is what I'm looking for, but I'm trying to achieve this with the results from the first search.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sorry, I'm fairly new to Splunk, so there's a lot of learning on my end. &amp;nbsp;Please let me know if I need to clarify any parts of the question.&lt;/P&gt;</description>
      <pubDate>Tue, 25 Apr 2023 21:26:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-fields-across-different-events-via-eval-and-search/m-p/641347#M222195</guid>
      <dc:creator>GaryZ</dc:creator>
      <dc:date>2023-04-25T21:26:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to get fields across different events - via eval and search/where?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-fields-across-different-events-via-eval-and-search/m-p/641354#M222199</link>
      <description>&lt;P&gt;I am confused. &amp;nbsp;You already performed&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt; | stats avg(d_duration) as avg_d_duration, avg(a_duration) as avg_a_duration by def.build, def.hardware&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;After this, abc.duration no longer exist in data stream, only avg_a_duration. &amp;nbsp;But then, you have this eval&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval avg_a_duration=abc.duration  ```&amp;lt;= this is a limit line I want to implement based on the next search ```&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This wipes avg_a_duration out with null value because abc.duration no longer exists.&lt;/P&gt;&lt;P&gt;Of course, even if you do not have that eval, the first stats will not give you value for avg_a_duration, either, because the abc.duration only exists with abc.build and abc.hardware.&lt;/P&gt;&lt;P&gt;The best way to start is to describe your use case. &amp;nbsp;What is the result that you expect from the illustrated data? &amp;nbsp;What is the logic to "cross" events? &amp;nbsp;Is there any key to correlate the two builds? (I don't see any in your illustrated data.) &amp;nbsp;What is the purpose of that last search for abc attributes after you stats over def builds?&lt;/P&gt;&lt;P&gt;If there is no correlation, the best you can do is your search 1 with append.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Apr 2023 00:50:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-fields-across-different-events-via-eval-and-search/m-p/641354#M222199</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2023-04-26T00:50:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to get fields across different events - via eval and search/where?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-fields-across-different-events-via-eval-and-search/m-p/641356#M222200</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/33901"&gt;@yuanliu&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for getting back. &amp;nbsp;I am looking to plot a chart, where the x,y values are the build and duration values (respectively), &amp;nbsp;based on the latest sw version. &amp;nbsp; I want to add a limit-line (base-line) captured from the previous sw version, and super impose it on the current chart. &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Since the build numbers will be different from the current and previous sw version, I want to capture a single data point &amp;nbsp;from previous sw version, and use that as the base-line point. &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How would I go about in getting this in the Splunk search?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;TIA&lt;/P&gt;</description>
      <pubDate>Wed, 26 Apr 2023 01:41:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-fields-across-different-events-via-eval-and-search/m-p/641356#M222200</guid>
      <dc:creator>GaryZ</dc:creator>
      <dc:date>2023-04-26T01:41:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to get fields across different events - via eval and search/where?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-fields-across-different-events-via-eval-and-search/m-p/641390#M222219</link>
      <description>&lt;P&gt;So, to clarify:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;You want to chart by sw, not hardware. &amp;nbsp;If you stats by hardware, you will never get the chart by sw.&lt;/LI&gt;&lt;LI&gt;The designation of abc and def is just weird because they are just distractions. &amp;nbsp;Do the top node really change from event to event in real data?&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;Assuming that the top node does change from event to event, you'll have to find some way to get rid of because they do not factor into your desired result. (Identical top node will make the search infinitely simpler.) &amp;nbsp;The function to call is&amp;nbsp;&lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/ConditionalFunctions#coalesce.28.26lt.3Bvalues.26gt.3B.29" target="_blank" rel="noopener"&gt;coalesce&lt;/A&gt;; but you will need some way to enumerate the top nodes. &amp;nbsp;In the following, I will use&amp;nbsp;&lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Foreach" target="_blank" rel="noopener"&gt;foreach&lt;/A&gt;&amp;nbsp;command to iterate. &amp;nbsp;This is less obvious what it does, so I also put a manual enumeration equivalent in comments.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| foreach *.*
    [ | eval &amp;lt;&amp;lt;MATCHSEG2&amp;gt;&amp;gt; = mvappend(&amp;lt;&amp;lt;MATCHSEG2&amp;gt;&amp;gt;, '&amp;lt;&amp;lt;MATCHSEG1&amp;gt;&amp;gt;.&amp;lt;&amp;lt;MATCHSEG2&amp;gt;&amp;gt;')]
``` the above is equivalent to the following
| eval build = coalesce('abc.build', 'def.build', 'ghi.build')
| eval duration = coalesce('abc.duration', 'def.duration', 'ghi.duration')
| eval sw = coalesce('abc.sw', 'def.sw', 'ghi.sw')```&lt;/LI-CODE&gt;&lt;P&gt;The next question is: Do you always know the latest sw version and the one before that? &amp;nbsp;It would be simpler if you do. &amp;nbsp;Suppose the latest version is gen2 as in illustrated data, and second to last is gen1.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| foreach *.*
    [ | eval &amp;lt;&amp;lt;MATCHSEG2&amp;gt;&amp;gt; = mvappend(&amp;lt;&amp;lt;MATCHSEG2&amp;gt;&amp;gt;, '&amp;lt;&amp;lt;MATCHSEG1&amp;gt;&amp;gt;.&amp;lt;&amp;lt;MATCHSEG2&amp;gt;&amp;gt;')]
| where sw == "gen2"
| chart values(duration) over build&lt;/LI-CODE&gt;&lt;P&gt;This will give you the chart for gen2. &amp;nbsp;Then, to overlay a flat line for gen1, you calculate its average, then spread it over gen2 builds. (I believe that average is better than a single data point.) &amp;nbsp;Like this.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| foreach *.*
    [ | eval &amp;lt;&amp;lt;MATCHSEG2&amp;gt;&amp;gt; = mvappend(&amp;lt;&amp;lt;MATCHSEG2&amp;gt;&amp;gt;, '&amp;lt;&amp;lt;MATCHSEG1&amp;gt;&amp;gt;.&amp;lt;&amp;lt;MATCHSEG2&amp;gt;&amp;gt;')]
| eventstats avg(duration) as avg_duration by sw
| eventstats values(eval(if(sw == "gen1", avg_duration, null()))) as previous_avg
| where sw == "gen2"
| chart values(duration) as duration values(previous_avg) as baseline by build&lt;/LI-CODE&gt;&lt;P&gt;If you don't know the latest version, you can calculate it based on data. &amp;nbsp;It is just more calculations.&lt;/P&gt;</description>
      <pubDate>Wed, 26 Apr 2023 07:13:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-fields-across-different-events-via-eval-and-search/m-p/641390#M222219</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2023-04-26T07:13:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to get fields across different events - via eval and search/where?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-fields-across-different-events-via-eval-and-search/m-p/641455#M222225</link>
      <description>&lt;P&gt;The &lt;FONT face="courier new,courier"&gt;append&lt;/FONT&gt; command adds its results to the bottom of the current result set.&amp;nbsp; If the main search returns results "foo" and "bar" and the &lt;FONT face="courier new,courier"&gt;append&lt;/FONT&gt; returns "baz" and "bat" then the final resullt will be&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;foo
bar
baz
bat&lt;/LI-CODE&gt;&lt;P&gt;No relationship is made among any of the results.&amp;nbsp; You need to do that yourself.&amp;nbsp; Usually, that's done with the &lt;FONT face="courier new,courier"&gt;stats&lt;/FONT&gt; command using any field(s) common to all results.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;&amp;lt;main search&amp;gt;&amp;gt;
| append [ &amp;lt;&amp;lt;some other search&amp;gt;&amp;gt; ]
| stats values(*) as * by blah&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 26 Apr 2023 14:42:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-fields-across-different-events-via-eval-and-search/m-p/641455#M222225</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2023-04-26T14:42:20Z</dc:date>
    </item>
  </channel>
</rss>

