<?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: Two questions one answer in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Two-questions-one-answer/m-p/92969#M23971</link>
    <description>&lt;P&gt;Thanks alot mate, been looking for a "if" - ability, unaware it was underneath the eval command. And yes it worked like a charm..&lt;/P&gt;</description>
    <pubDate>Mon, 22 Nov 2010 03:31:46 GMT</pubDate>
    <dc:creator>isrjo</dc:creator>
    <dc:date>2010-11-22T03:31:46Z</dc:date>
    <item>
      <title>Two questions one answer</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Two-questions-one-answer/m-p/92967#M23969</link>
      <description>&lt;P&gt;Greetings, I'm new to splunk and even though I'm extremely impressed with what I have seen/managed to do so far I still have not fully understand the structure of the querys, nor what functions to use where.&lt;/P&gt;

&lt;P&gt;I have managed to introduce logs from our e-mail system and defined fields inside splunk accordingly. The problem however is that the meaning of the fields changes depending on the event. So for example my introduced field event_group with value 5 contains sent e-mail events and value 6 received, meaning in a group 5 event the sender is placed in field m_username and recipient in field m_sr_name, and for a group 6 it's the other way around.&lt;/P&gt;

&lt;P&gt;The challange i'm facing is to present both events in one table sorted by date. Just to
illustrate, these are the two questions I would like to combine and have the output sent to the same table.&lt;/P&gt;

&lt;P&gt;VBEAAAAABcO+PgAAZAABX1MLAb5U event_group="5" | rename m_ptime AS
"Date_time", m_username AS "Sender", m_sr_name AS "Recipient" | table
Date_time , Sender , Recipient&lt;/P&gt;

&lt;P&gt;VBEAAAAABcO+PgAAZAABX1MLAb5U event_group="6" | rename m_ptime AS
"Date_time", m_username AS "Recipient", m_sr_name AS "Sender" | table
Date_time , Sender , Recipient&lt;/P&gt;

&lt;P&gt;I have played around with various subsearches but as soon as I rename the fields inside the subsearch I am no longer able to extract that field, not even sure if that is the best approach.&lt;/P&gt;</description>
      <pubDate>Sun, 21 Nov 2010 21:07:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Two-questions-one-answer/m-p/92967#M23969</guid>
      <dc:creator>isrjo</dc:creator>
      <dc:date>2010-11-21T21:07:27Z</dc:date>
    </item>
    <item>
      <title>Re: Two questions one answer</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Two-questions-one-answer/m-p/92968#M23970</link>
      <description>&lt;P&gt;The simplest method is to use &lt;CODE&gt;eval&lt;/CODE&gt; -- take a look at &lt;A href="http://www.splunk.com/base/Documentation/4.1.5/SearchReference/Eval" rel="nofollow"&gt;&lt;CODE&gt;eval&lt;/CODE&gt;&lt;/A&gt; and &lt;A href="http://www.splunk.com/base/Documentation/4.1.5/SearchReference/CommonEvalFunctions" rel="nofollow"&gt;functions for eval and where&lt;/A&gt;:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;VBEAAAAABcO+PgAAZAABX1MLAb5U event_group="5" OR event_group="6"
| eval Sender=if(event_group==5, m_username, m_sr_name)
| eval Recipient=if(event_group==5, m_sr_name, m_username)
| table Date_time, Sender, Recipient
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Alternately, you can modify your field extractions to extract field names differently depending on context. The difficulty of doing so will vary depending on what your raw events look like.&lt;/P&gt;</description>
      <pubDate>Mon, 22 Nov 2010 00:59:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Two-questions-one-answer/m-p/92968#M23970</guid>
      <dc:creator>southeringtonp</dc:creator>
      <dc:date>2010-11-22T00:59:25Z</dc:date>
    </item>
    <item>
      <title>Re: Two questions one answer</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Two-questions-one-answer/m-p/92969#M23971</link>
      <description>&lt;P&gt;Thanks alot mate, been looking for a "if" - ability, unaware it was underneath the eval command. And yes it worked like a charm..&lt;/P&gt;</description>
      <pubDate>Mon, 22 Nov 2010 03:31:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Two-questions-one-answer/m-p/92969#M23971</guid>
      <dc:creator>isrjo</dc:creator>
      <dc:date>2010-11-22T03:31:46Z</dc:date>
    </item>
  </channel>
</rss>

