<?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 do you compare 2 multivalued fields from different indices? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-compare-2-multivalued-fields-from-different-indices/m-p/390152#M113641</link>
    <description>&lt;P&gt;So, let's say the application front-end reports latency of 500ms for a given event. An API (with events being logged in B) takes that front-end request and processes it, Splunk logs this as an event and reports the API response_time=50ms. I believe this means that the request spent 450ms (the difference between the 2 values) traveling through proxies and gateways and whatnot. I am trying to run a Linear Regression as a proof of concept against these two values to show they are directly related.&lt;/P&gt;

&lt;P&gt;Sample events (only showing relevant fields):&lt;/P&gt;

&lt;P&gt;Index A - Front End&lt;BR /&gt;
11/13/18&lt;BR /&gt;
11:01:16.000 AM &lt;BR /&gt;
{&lt;BR /&gt;&lt;BR /&gt;
     latency:    1189&lt;BR /&gt;&lt;BR /&gt;
}&lt;/P&gt;

&lt;P&gt;Index B - API&lt;BR /&gt;
11/13/18&lt;BR /&gt;
11:00:56.735 AM &lt;BR /&gt;
{&lt;BR /&gt;&lt;BR /&gt;
     method:     GET&lt;BR /&gt;&lt;BR /&gt;
     response_length:    9&lt;BR /&gt;&lt;BR /&gt;
     response_status:    200&lt;BR /&gt;&lt;BR /&gt;
     response_time:  0&lt;BR /&gt;&lt;BR /&gt;
}&lt;/P&gt;

&lt;P&gt;So here, these events were produced via the same request. From this, I can tell that the API is not responsible for any of the latency experienced on the front-end (via response_time: 0). Thus, the latency is likely due to the request routing.&lt;/P&gt;</description>
    <pubDate>Tue, 29 Sep 2020 22:02:56 GMT</pubDate>
    <dc:creator>maxzintel</dc:creator>
    <dc:date>2020-09-29T22:02:56Z</dc:date>
    <item>
      <title>How do you compare 2 multivalued fields from different indices?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-compare-2-multivalued-fields-from-different-indices/m-p/390147#M113636</link>
      <description>&lt;P&gt;I am attempting to correlate network latency fields from different indices. Basically, I would like to end up with a table with 2 columns, with each column being populated with every recorded value for network latency in each of the indices.&lt;/P&gt;

&lt;P&gt;I have tried using subsearches like so:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=indexA | eval "latencyFromIndexB"=[search index=indexB | return &amp;lt;count&amp;gt; $latencyB]+0 | fields "latencyFromIndexA" "latencyFromIndexB" 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But, I have been unable to get multiple values to return from the subsearch in a useful way. Depending on the exact method, latencyFromIndexB either lists a single value or the same value over and over, presumably from the first event it finds.&lt;/P&gt;

&lt;P&gt;End result will hopefully look something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;latencyA | latencyB
12312    |  545
324      |  2123
etc... 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Thank you in advance if you are able to assist me!&lt;/P&gt;</description>
      <pubDate>Fri, 09 Nov 2018 21:42:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-compare-2-multivalued-fields-from-different-indices/m-p/390147#M113636</guid>
      <dc:creator>maxzintel</dc:creator>
      <dc:date>2018-11-09T21:42:04Z</dc:date>
    </item>
    <item>
      <title>Re: How do you compare 2 multivalued fields from different indices?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-compare-2-multivalued-fields-from-different-indices/m-p/390148#M113637</link>
      <description>&lt;P&gt;How is one event in index A related to an event in index B? Is there a request ID?&lt;/P&gt;</description>
      <pubDate>Sat, 10 Nov 2018 06:10:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-compare-2-multivalued-fields-from-different-indices/m-p/390148#M113637</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2018-11-10T06:10:36Z</dc:date>
    </item>
    <item>
      <title>Re: How do you compare 2 multivalued fields from different indices?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-compare-2-multivalued-fields-from-different-indices/m-p/390149#M113638</link>
      <description>&lt;P&gt;@martin_mueller Sorry for the delayed reply! Index A logs front-end events, Index B logs events from our API's. The latency reported by each should be different but directly related, with their difference being latency caused by the request traversing the internet.&lt;/P&gt;</description>
      <pubDate>Tue, 13 Nov 2018 14:01:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-compare-2-multivalued-fields-from-different-indices/m-p/390149#M113638</guid>
      <dc:creator>maxzintel</dc:creator>
      <dc:date>2018-11-13T14:01:08Z</dc:date>
    </item>
    <item>
      <title>Re: How do you compare 2 multivalued fields from different indices?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-compare-2-multivalued-fields-from-different-indices/m-p/390150#M113639</link>
      <description>&lt;P&gt;In other words, each front-end event that reports network latency should have a correlating event in the API index.&lt;/P&gt;</description>
      <pubDate>Tue, 13 Nov 2018 14:03:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-compare-2-multivalued-fields-from-different-indices/m-p/390150#M113639</guid>
      <dc:creator>maxzintel</dc:creator>
      <dc:date>2018-11-13T14:03:04Z</dc:date>
    </item>
    <item>
      <title>Re: How do you compare 2 multivalued fields from different indices?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-compare-2-multivalued-fields-from-different-indices/m-p/390151#M113640</link>
      <description>&lt;P&gt;How does one correlate an event from A with an event from B on a conceptual level? Ignore Splunk/SPL for now.&lt;/P&gt;

&lt;P&gt;Sample events would really help here.&lt;/P&gt;</description>
      <pubDate>Tue, 13 Nov 2018 14:40:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-compare-2-multivalued-fields-from-different-indices/m-p/390151#M113640</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2018-11-13T14:40:02Z</dc:date>
    </item>
    <item>
      <title>Re: How do you compare 2 multivalued fields from different indices?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-compare-2-multivalued-fields-from-different-indices/m-p/390152#M113641</link>
      <description>&lt;P&gt;So, let's say the application front-end reports latency of 500ms for a given event. An API (with events being logged in B) takes that front-end request and processes it, Splunk logs this as an event and reports the API response_time=50ms. I believe this means that the request spent 450ms (the difference between the 2 values) traveling through proxies and gateways and whatnot. I am trying to run a Linear Regression as a proof of concept against these two values to show they are directly related.&lt;/P&gt;

&lt;P&gt;Sample events (only showing relevant fields):&lt;/P&gt;

&lt;P&gt;Index A - Front End&lt;BR /&gt;
11/13/18&lt;BR /&gt;
11:01:16.000 AM &lt;BR /&gt;
{&lt;BR /&gt;&lt;BR /&gt;
     latency:    1189&lt;BR /&gt;&lt;BR /&gt;
}&lt;/P&gt;

&lt;P&gt;Index B - API&lt;BR /&gt;
11/13/18&lt;BR /&gt;
11:00:56.735 AM &lt;BR /&gt;
{&lt;BR /&gt;&lt;BR /&gt;
     method:     GET&lt;BR /&gt;&lt;BR /&gt;
     response_length:    9&lt;BR /&gt;&lt;BR /&gt;
     response_status:    200&lt;BR /&gt;&lt;BR /&gt;
     response_time:  0&lt;BR /&gt;&lt;BR /&gt;
}&lt;/P&gt;

&lt;P&gt;So here, these events were produced via the same request. From this, I can tell that the API is not responsible for any of the latency experienced on the front-end (via response_time: 0). Thus, the latency is likely due to the request routing.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 22:02:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-compare-2-multivalued-fields-from-different-indices/m-p/390152#M113641</guid>
      <dc:creator>maxzintel</dc:creator>
      <dc:date>2020-09-29T22:02:56Z</dc:date>
    </item>
    <item>
      <title>Re: How do you compare 2 multivalued fields from different indices?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-compare-2-multivalued-fields-from-different-indices/m-p/390153#M113642</link>
      <description>&lt;P&gt;How can you tell they were generated by the same request? I see no request ID or something like that to link the two together.&lt;/P&gt;</description>
      <pubDate>Tue, 13 Nov 2018 17:15:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-compare-2-multivalued-fields-from-different-indices/m-p/390153#M113642</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2018-11-13T17:15:56Z</dc:date>
    </item>
    <item>
      <title>Re: How do you compare 2 multivalued fields from different indices?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-compare-2-multivalued-fields-from-different-indices/m-p/390154#M113643</link>
      <description>&lt;P&gt;I currently do not have a request ID field that linking the two events together. My thinking was that if I am exclusively plotting the values of each over time, it would show their relationship just as well as creating some sort of link. That being said, it is possible I do not fully understand the value in adding in a request ID field.&lt;/P&gt;

&lt;P&gt;How would a request ID field assist in getting the output I am looking for?&lt;/P&gt;</description>
      <pubDate>Tue, 13 Nov 2018 19:54:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-compare-2-multivalued-fields-from-different-indices/m-p/390154#M113643</guid>
      <dc:creator>maxzintel</dc:creator>
      <dc:date>2018-11-13T19:54:46Z</dc:date>
    </item>
    <item>
      <title>Re: How do you compare 2 multivalued fields from different indices?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-compare-2-multivalued-fields-from-different-indices/m-p/390155#M113644</link>
      <description>&lt;P&gt;Without an ID you can chart general trends, e.g. this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=A OR index=B | timechart avg(latency) avg(response_time)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;With an ID you could link which slow requests over here are related to which requests over there, potentially providing lots of value for troubleshooting.&lt;/P&gt;</description>
      <pubDate>Tue, 13 Nov 2018 20:07:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-compare-2-multivalued-fields-from-different-indices/m-p/390155#M113644</guid>
      <dc:creator>martin_mueller</dc:creator>
      <dc:date>2018-11-13T20:07:58Z</dc:date>
    </item>
    <item>
      <title>Re: How do you compare 2 multivalued fields from different indices?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-compare-2-multivalued-fields-from-different-indices/m-p/390156#M113645</link>
      <description>&lt;P&gt;The standard way to do this using the "Splunk Soup" method, if you had a matching request ID or similar, is this ...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; (  index=A  your first search ) OR ( index=B your second search) 
| fields ...list the fields you need to keep from either ...
| eval matchkey=case(index="A", key value from index A event, index="B", key value from index b event)
| eval latencyFromIndexA = case(index=A, latency) 
| eval latencyFromIndexB = case(index=B, response_time)
| fields matchkey latency* 
| stats values(latency*) as latency* by matchkey
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;HR /&gt;

&lt;P&gt;The standard way to do this using time constraints, if you had NO request ID or similar, is this ...&lt;BR /&gt;
(This assumes that, like in your example, the record in A will always be timestamped after the record in B, and will always arrive in less than 1s)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; (  index=A  your first search ) OR ( index=B your second search) 
| fields _time index response_time latency ...list any other fields you need to keep from either ...

| rename COMMENT as "sort into ascending order"
| sort 0 _time 

| rename COMMENT as "roll index b data onto the next index A record then throw away index B"
| streamstats time_window=1s last(case(index="B",response_time)) as lastResp  last(case(index="B",_time)) as prior_time
| where index="A"

| rename COMMENT as "now your record looks like this..."
| table _time prior_time latency lastResp
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;HR /&gt;

&lt;P&gt;If you don't care about anything but the list of latencies of the two types, then do this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(search 1) OR (search 2) 
| fields _time latency response_time
| bin _time span=1m
| stats list(latency) as latency_A list(response_time) as response_timeB by _time
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 13 Nov 2018 20:17:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-compare-2-multivalued-fields-from-different-indices/m-p/390156#M113645</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2018-11-13T20:17:06Z</dc:date>
    </item>
    <item>
      <title>Re: How do you compare 2 multivalued fields from different indices?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-compare-2-multivalued-fields-from-different-indices/m-p/390157#M113646</link>
      <description>&lt;P&gt;Spot on. I will add in an ID to make the search more effective. Thank you very much for your time and assistance @martin_mueller !&lt;/P&gt;</description>
      <pubDate>Tue, 13 Nov 2018 20:44:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-compare-2-multivalued-fields-from-different-indices/m-p/390157#M113646</guid>
      <dc:creator>maxzintel</dc:creator>
      <dc:date>2018-11-13T20:44:56Z</dc:date>
    </item>
    <item>
      <title>Re: How do you compare 2 multivalued fields from different indices?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-compare-2-multivalued-fields-from-different-indices/m-p/390158#M113647</link>
      <description>&lt;P&gt;Thank you very much! This fits well with what Martin was explaining, and the detail, explanation, and example code is much appreciated! &lt;/P&gt;</description>
      <pubDate>Tue, 13 Nov 2018 20:47:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-compare-2-multivalued-fields-from-different-indices/m-p/390158#M113647</guid>
      <dc:creator>maxzintel</dc:creator>
      <dc:date>2018-11-13T20:47:22Z</dc:date>
    </item>
  </channel>
</rss>

