<?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 How to Optimize this Search in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-Optimize-this-Search/m-p/462602#M30360</link>
    <description>&lt;P&gt;Hello,&lt;BR /&gt;
Still learning and getting better at it. However, I have this very complex search in one of my dashboard panels, and I would like to optimize it.&lt;/P&gt;

&lt;P&gt;I am reviewing the links &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/201110"&gt;@niketn&lt;/a&gt; offered to another Splunker in this post (&lt;A href="https://answers.splunk.com/answers/620388/how-to-make-efficient-and-fast-searches-reports-an.html" target="_blank"&gt;https://answers.splunk.com/answers/620388/how-to-make-efficient-and-fast-searches-reports-an.html&lt;/A&gt;) and I figure I would post my code for additional feedback and insights.&lt;/P&gt;

&lt;P&gt;Initially, I was looking for a way to use post-processing. But unless I am mistaken, that would work between panels; and not within the same panel, because only one  per panel. Correct?&lt;/P&gt;

&lt;P&gt;I was also thinking of running a main search in a hidden panel where &lt;STRONG&gt;depends&lt;/STRONG&gt; equals something that will never happen; therefore keeping the panel hidden. In this panel I would use the  and then in the main (visible) panel use . Is this viable?&lt;/P&gt;

&lt;P&gt;Here is my complex search. Note: the tokens are selected via dropdown inputs in the dashboard.&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;&lt;P&gt;$Selected_Time_Range.earliest$&lt;BR /&gt;
$Selected_Time_Range.latest$&lt;BR /&gt;
$hostName_tok$&lt;BR /&gt;
$userId_tok$&lt;BR /&gt;
$linuxId_tok&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;    &amp;lt;search&amp;gt;
      &amp;lt;query&amp;gt;
        [ search index="*linuxevents"
            AND earliest=$Selected_Time_Range.earliest$ AND latest=$Selected_Time_Range.latest$
            AND (source="/var/log/sudo.log" OR source="/var/log/secure")
            AND host=$hostName_tok$
            AND _raw="*$userId_tok$*"
        | append
            [ search index="*linuxevents" 
              AND earliest=$Selected_Time_Range.earliest$ AND latest=$Selected_Time_Range.latest$
              AND (source="/var/log/sudo.log" OR source="/var/log/secure")
              AND host=$hostName_tok$
              AND [ search index="*linuxevents" AND source="ps" 
                      AND earliest=$Selected_Time_Range.earliest$ AND latest=$Selected_Time_Range.latest$
                      AND host=$hostName_tok$
                      AND (USER=$userId_tok$ OR (USER="root" AND "*$userId_tok$*"))
                    | dedup pid
                    | sort +pid
                    | table pid ] ]
          | dedup _raw ]

          | append
            [ search index="*linuxevents" 
                AND earliest=$Selected_Time_Range.earliest$ AND latest=$Selected_Time_Range.latest$
                AND source="/var/log/audit/audit.log" 
                AND host=$hostName_tok$
                AND [ search index="*linuxevents" 
                        AND earliest=$Selected_Time_Range.earliest$ AND latest=$Selected_Time_Range.latest$
                        AND source="/var/log/audit/audit.log"  
                        AND host=$hostName_tok$
                        AND ([`multi_field_search("auid euid fsuid id inode_uid oauid ouid sauid suid uid", "$linuxId_tok$")`]
                          OR [`multi_field_search("user acct cwd name", "*$userId_tok$*")`])
                      | dedup event_id
                      | sort +event_id
                      | table event_id ] 

          | append                    
              [search index="*linuxevents" 
                  AND earliest=$Selected_Time_Range.earliest$ AND latest=$Selected_Time_Range.latest$
                  AND source="/var/log/audit/audit.log" 
                  AND host=$hostName_tok$
                  AND ([`multi_field_search("user acct cwd name", "*$userId_tok$*")`]
                    OR [`multi_field_search("auid euid fsuid id inode_uid oauid ouid sauid suid uid", "$linuxId_tok$")`]
                    OR [ search index="*linuxevents" 
                            AND earliest=$Selected_Time_Range.earliest$ AND latest=$Selected_Time_Range.latest$
                            AND source="/var/log/audit/audit.log"  
                            AND host=$hostName_tok$
                            AND [`multi_field_search("user acct cwd name", "*$userId_tok$*")`]
                            AND (auid!="0" AND auid!="4294967295")
                            AND addr!="?"
                              | head limit=1
                              | eval addr="\"".addr."\""
                              | return $addr ])  ] 

          | append
              [ search index="*linuxevents"
                  AND earliest=$Selected_Time_Range.earliest$ AND latest=$Selected_Time_Range.latest$
                  AND source="/var/log/audit/audit.log"
                  AND host=$hostName_tok$
                  AND (_raw="*new auid*" AND "$linuxId_tok$") ]
              | dedup _raw
              | transaction event_id ]

          | eval log=case(source=="/var/log/sudo.log", "sudo", source=="/var/log/secure", "secure", source=="/var/log/audit/audit.log", "audit")
          | sort +_time
          | table _time, log, host, _raw
      &amp;lt;/query&amp;gt;
    &amp;lt;/search&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;&lt;/LI&gt;
&lt;/UL&gt;

&lt;P&gt;Thanks for direction and ideas in advance.&lt;BR /&gt;
God bless,&lt;BR /&gt;
Genesius&lt;/P&gt;

&lt;P&gt;PS I am overthinking this? Is the answer that obvious?&lt;/P&gt;</description>
    <pubDate>Wed, 30 Sep 2020 01:54:30 GMT</pubDate>
    <dc:creator>genesiusj</dc:creator>
    <dc:date>2020-09-30T01:54:30Z</dc:date>
    <item>
      <title>How to Optimize this Search</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-Optimize-this-Search/m-p/462602#M30360</link>
      <description>&lt;P&gt;Hello,&lt;BR /&gt;
Still learning and getting better at it. However, I have this very complex search in one of my dashboard panels, and I would like to optimize it.&lt;/P&gt;

&lt;P&gt;I am reviewing the links &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/201110"&gt;@niketn&lt;/a&gt; offered to another Splunker in this post (&lt;A href="https://answers.splunk.com/answers/620388/how-to-make-efficient-and-fast-searches-reports-an.html" target="_blank"&gt;https://answers.splunk.com/answers/620388/how-to-make-efficient-and-fast-searches-reports-an.html&lt;/A&gt;) and I figure I would post my code for additional feedback and insights.&lt;/P&gt;

&lt;P&gt;Initially, I was looking for a way to use post-processing. But unless I am mistaken, that would work between panels; and not within the same panel, because only one  per panel. Correct?&lt;/P&gt;

&lt;P&gt;I was also thinking of running a main search in a hidden panel where &lt;STRONG&gt;depends&lt;/STRONG&gt; equals something that will never happen; therefore keeping the panel hidden. In this panel I would use the  and then in the main (visible) panel use . Is this viable?&lt;/P&gt;

&lt;P&gt;Here is my complex search. Note: the tokens are selected via dropdown inputs in the dashboard.&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;&lt;P&gt;$Selected_Time_Range.earliest$&lt;BR /&gt;
$Selected_Time_Range.latest$&lt;BR /&gt;
$hostName_tok$&lt;BR /&gt;
$userId_tok$&lt;BR /&gt;
$linuxId_tok&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;    &amp;lt;search&amp;gt;
      &amp;lt;query&amp;gt;
        [ search index="*linuxevents"
            AND earliest=$Selected_Time_Range.earliest$ AND latest=$Selected_Time_Range.latest$
            AND (source="/var/log/sudo.log" OR source="/var/log/secure")
            AND host=$hostName_tok$
            AND _raw="*$userId_tok$*"
        | append
            [ search index="*linuxevents" 
              AND earliest=$Selected_Time_Range.earliest$ AND latest=$Selected_Time_Range.latest$
              AND (source="/var/log/sudo.log" OR source="/var/log/secure")
              AND host=$hostName_tok$
              AND [ search index="*linuxevents" AND source="ps" 
                      AND earliest=$Selected_Time_Range.earliest$ AND latest=$Selected_Time_Range.latest$
                      AND host=$hostName_tok$
                      AND (USER=$userId_tok$ OR (USER="root" AND "*$userId_tok$*"))
                    | dedup pid
                    | sort +pid
                    | table pid ] ]
          | dedup _raw ]

          | append
            [ search index="*linuxevents" 
                AND earliest=$Selected_Time_Range.earliest$ AND latest=$Selected_Time_Range.latest$
                AND source="/var/log/audit/audit.log" 
                AND host=$hostName_tok$
                AND [ search index="*linuxevents" 
                        AND earliest=$Selected_Time_Range.earliest$ AND latest=$Selected_Time_Range.latest$
                        AND source="/var/log/audit/audit.log"  
                        AND host=$hostName_tok$
                        AND ([`multi_field_search("auid euid fsuid id inode_uid oauid ouid sauid suid uid", "$linuxId_tok$")`]
                          OR [`multi_field_search("user acct cwd name", "*$userId_tok$*")`])
                      | dedup event_id
                      | sort +event_id
                      | table event_id ] 

          | append                    
              [search index="*linuxevents" 
                  AND earliest=$Selected_Time_Range.earliest$ AND latest=$Selected_Time_Range.latest$
                  AND source="/var/log/audit/audit.log" 
                  AND host=$hostName_tok$
                  AND ([`multi_field_search("user acct cwd name", "*$userId_tok$*")`]
                    OR [`multi_field_search("auid euid fsuid id inode_uid oauid ouid sauid suid uid", "$linuxId_tok$")`]
                    OR [ search index="*linuxevents" 
                            AND earliest=$Selected_Time_Range.earliest$ AND latest=$Selected_Time_Range.latest$
                            AND source="/var/log/audit/audit.log"  
                            AND host=$hostName_tok$
                            AND [`multi_field_search("user acct cwd name", "*$userId_tok$*")`]
                            AND (auid!="0" AND auid!="4294967295")
                            AND addr!="?"
                              | head limit=1
                              | eval addr="\"".addr."\""
                              | return $addr ])  ] 

          | append
              [ search index="*linuxevents"
                  AND earliest=$Selected_Time_Range.earliest$ AND latest=$Selected_Time_Range.latest$
                  AND source="/var/log/audit/audit.log"
                  AND host=$hostName_tok$
                  AND (_raw="*new auid*" AND "$linuxId_tok$") ]
              | dedup _raw
              | transaction event_id ]

          | eval log=case(source=="/var/log/sudo.log", "sudo", source=="/var/log/secure", "secure", source=="/var/log/audit/audit.log", "audit")
          | sort +_time
          | table _time, log, host, _raw
      &amp;lt;/query&amp;gt;
    &amp;lt;/search&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;&lt;/LI&gt;
&lt;/UL&gt;

&lt;P&gt;Thanks for direction and ideas in advance.&lt;BR /&gt;
God bless,&lt;BR /&gt;
Genesius&lt;/P&gt;

&lt;P&gt;PS I am overthinking this? Is the answer that obvious?&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 01:54:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-Optimize-this-Search/m-p/462602#M30360</guid>
      <dc:creator>genesiusj</dc:creator>
      <dc:date>2020-09-30T01:54:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to Optimize this Search</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-Optimize-this-Search/m-p/462603#M30361</link>
      <description>&lt;P&gt;Hi genesiusj,&lt;BR /&gt;
use post process search in one panel has no reason, because the advantage to use pps is to run one search and use results in many panels instead running many searches one for each panel.&lt;/P&gt;

&lt;P&gt;It's difficoult to help you without the main search and the macros you used. anyway, some little hint for your searches:&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;check the number of results of each subsearch because in Splunk there's the limit (configurable but to avoid) of 50,000 results of
subsearches;&lt;/LI&gt;
&lt;LI&gt;you don't need to repeat $Selected_Time_Range.earliest$ AND latest=$Selected_Time_Range.latest$ in  every search except when you want a different value because they are taken by default;&lt;/LI&gt;
&lt;LI&gt;you don't need to use &lt;CODE&gt;_raw="*$userId_tok$*"&lt;/CODE&gt; because if you use a string for search it's used in _raw, in other words you should try to forget to think to Splunk using a database approach!&lt;/LI&gt;
&lt;LI&gt;you don't need to use "AND" boolean operator because there's by default;&lt;/LI&gt;
&lt;LI&gt;you don't need to use "+" in &lt;CODE&gt;| sort +_time&lt;/CODE&gt; it's a default;&lt;/LI&gt;
&lt;LI&gt;I see that you're using the same search parameters in all the searches&lt;/LI&gt;
&lt;/UL&gt;

&lt;P&gt;search index="&lt;EM&gt;linuxevents"&lt;BR /&gt;
AND earliest=$Selected_Time_Range.earliest$ AND latest=$Selected_Time_Range.latest$&lt;BR /&gt;
AND (source="/var/log/sudo.log" OR source="/var/log/secure")&lt;BR /&gt;
AND host=$hostName_tok$&lt;BR /&gt;
AND _raw="&lt;/EM&gt;$userId_tok$*"&lt;/P&gt;

&lt;P&gt;so you should try to build your search in a different way, putting the search parameters in the main search.&lt;/P&gt;

&lt;P&gt;Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 01:56:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-Optimize-this-Search/m-p/462603#M30361</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2020-09-30T01:56:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to Optimize this Search</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-Optimize-this-Search/m-p/462604#M30362</link>
      <description>&lt;P&gt;@gcusello &lt;BR /&gt;
I have been taking the Fund2 training this week and haven't had a chance to review your comments. I hope to beginning of next week.&lt;BR /&gt;
In the meantime, thank you and God bless,&lt;BR /&gt;
Genesius&lt;/P&gt;</description>
      <pubDate>Thu, 05 Sep 2019 19:42:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-Optimize-this-Search/m-p/462604#M30362</guid>
      <dc:creator>genesiusj</dc:creator>
      <dc:date>2019-09-05T19:42:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to Optimize this Search</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-Optimize-this-Search/m-p/462605#M30363</link>
      <description>&lt;P&gt;Your idea with the hidden panel does work and I have used it before.  The problem is your search.  Will you explain what you are trying to do?  It definitely needs to be reworked.  In particular, it looks like the entire thing is wrapped in a subsearch.  For starters, remove the &lt;CODE&gt;[]&lt;/CODE&gt; that surrounds everything as it is not needed.&lt;/P&gt;</description>
      <pubDate>Sat, 26 Oct 2019 15:59:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-Optimize-this-Search/m-p/462605#M30363</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-10-26T15:59:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to Optimize this Search</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-Optimize-this-Search/m-p/462606#M30364</link>
      <description>&lt;P&gt;Really, I would start from scratch on your core search.  It seems poorly constructed and I am quite sure that we can create a far smaller and more efficient search.  What exactly are you trying to do with it?&lt;/P&gt;</description>
      <pubDate>Sat, 09 Nov 2019 20:23:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-Optimize-this-Search/m-p/462606#M30364</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-11-09T20:23:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to Optimize this Search</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-Optimize-this-Search/m-p/462607#M30365</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/1406"&gt;@woodcock&lt;/a&gt; &lt;BR /&gt;
Here is what I need to provide to our *nix SysAdmins. &lt;/P&gt;

&lt;P&gt;Current process: they open 3 separate windows on their monitors. One is to view &lt;STRONG&gt;audit.log&lt;/STRONG&gt;, the other to view &lt;STRONG&gt;/var/log/secure&lt;/STRONG&gt;, and the last to view &lt;STRONG&gt;sudo.log&lt;/STRONG&gt;. &lt;BR /&gt;
Requirements: a single view of all three on one screen, with the ability to drill down into each individual log if needed.&lt;BR /&gt;
Initially, we installed the &lt;EM&gt;Splunk Linux Auditd app&lt;/EM&gt;. And while a much better app than the &lt;EM&gt;Splunk App for Unix and Linux&lt;/EM&gt; (utterly useless to our SysAdmins), the Auditd app does not return ALL the events associated with an ssh session as I hope to explain below.&lt;/P&gt;

&lt;P&gt;Before I get into that, I would like to comment on the suggestions from gcusello, and why I did or did not follow his valuable advice.&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;check the number of results of each subsearch because in Splunk there's the limit (configurable but to avoid) of 50,000 results of subsearches;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;Don’t believe any of the subsearches will return more than 50,000. But this will be dependent upon the Time Picker. Which is a question I raised on another post.&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;you don't need to repeat $Selected_Time_Range.earliest$ AND latest=$Selected_Time_Range.latest$ in every search except when you want a different value because they are taken by default;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;Removed from the query in all subsearches and the main search.&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;you don't need to use _raw="&lt;EM&gt;$userId_tok$&lt;/EM&gt;" because if you use a string for search it's used in _raw, in other words you should try to forget to think to Splunk using a database approach!&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;Unfortunately, the events in the &lt;STRONG&gt;source="ps"&lt;/STRONG&gt; are not clearly defined extractions (see explanation further down on why this search is required). &lt;BR /&gt;
One of the ps events below shows the &lt;STRONG&gt;user=user1&lt;/STRONG&gt; as the first field. Therefore, I know these are events related to &lt;STRONG&gt;user1&lt;/STRONG&gt;. However, there is also an event where the &lt;STRONG&gt;user=root&lt;/STRONG&gt;, AND the string &lt;STRONG&gt;user1&lt;/STRONG&gt; appears elsewhere in the event. This is why my code includes (USER="root" AND "&lt;EM&gt;$userId_tok$&lt;/EM&gt;"). Performing a deep-dive further into the ps events I found the field &lt;STRONG&gt;ARGS&lt;/STRONG&gt;, which Splunk extracts using the &lt;STRONG&gt;ps.sh&lt;/STRONG&gt;. Using this field instead of &lt;STRONG&gt;_raw&lt;/STRONG&gt; speeds up this subsearch due to the removal of the wildcard at the beginning of the field. Further testing is required to determine if &lt;EM&gt;the wildcard at the end of the field&lt;/EM&gt; &lt;STRONG&gt;ARGS&lt;/STRONG&gt; can be removed as well.&lt;BR /&gt;
This SPL line changed from &lt;BR /&gt;
(USER=$userId_tok$ OR (USER="root" AND "&lt;EM&gt;$userId_tok$&lt;/EM&gt;"))&lt;BR /&gt;
 to&lt;BR /&gt;
(USER=$userId_tok$ OR (USER="root" AND ARGS="$userId_tok$*")).&lt;/P&gt;

&lt;P&gt;Sample events from source=ps. From this subsearch I am extracting a list of PIDs associated with user1. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;root 7267 14 0.0 00:00:00 0.0 4032 104388 ? S 01:01 sshd: user1_[priv]
user1 7271 2 0.0 00:00:00 0.0 2712 104720 ? S 01:01 sshd: user1@notty
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;you don't need to use "AND" boolean operator because there's by default;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;I understand this. Does this slow the SPL down? If not, I like to include it for readability.&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;you don't need to use "+" in | sort +_time it's a default;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;My experience has been that if I don’t use &lt;STRONG&gt;| sort +_time&lt;/STRONG&gt;, the table comes out with latest event first. I require first event first. Can this be modified in a conf file?&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;I see that you're using the same search parameters in all the searches.&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;At the present I don’t see any way around this, which is why I am posting. Is there is a command to state to use the same index, host, acct, addr, and auid? &lt;/P&gt;

&lt;P&gt;Now that I have answered gcusello’s suggestions, here are the reasons for the complexity of this SPL. There would be several events missing for user1’s entire ssh session without this myriad of subsearches.&lt;BR /&gt;
There are some field-value pairs that are not known for user1’s ssh session until other (later) events are seen.&lt;BR /&gt;
Below is an abridged list of the events from this dashboard. I've inserted a number in front of each event for readability.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(1)    type=CRYPTO_KEY_USER msg=audit(1569008008.220:10732729): user pid=20626 uid=0 auid=4294967295 ses=4294967295 msg='op=destroy kind=server fp=28:6a:cb:a7:ab:67:d4:85:ff:34:99:b7:c9:f5:55:5c direction=? spid=20626 suid=0 exe="/usr/sbin/sshd" hostname=? addr=10.10.10.10 terminal=? res=success'
(2)    type=CRYPTO_KEY_USER msg=audit(1569008008.220:10732730): user pid=20626 uid=0 auid=4294967295 ses=4294967295 msg='op=destroy kind=server fp=48:24:f7:c4:0a:87:94:34:88:22:e1:88:47:1a:15:e2 direction=? spid=20626 suid=0 exe="/usr/sbin/sshd" hostname=? addr=10.10.10.10 terminal=? res=success'
(3)    type=CRYPTO_SESSION msg=audit(1569008008.220:10732731): user pid=20623 uid=0 auid=4294967295 ses=4294967295 msg='op=start direction=from-client cipher=aes128-ctr ksize=128 spid=20626 suid=74 rport=41507 laddr=10.1.1.1 lport=22 exe="/usr/sbin/sshd" hostname=? addr=10.10.10.10 terminal=? res=success'
(4)    type=CRYPTO_SESSION msg=audit(1569008008.220:10732732): user pid=20623 uid=0 auid=4294967295 ses=4294967295 msg='op=start direction=from-server cipher=aes128-ctr ksize=128 spid=20626 suid=74 rport=41507 laddr=10.1.1.1 lport=22 exe="/usr/sbin/sshd" hostname=? addr=10.10.10.10 terminal=? res=success'
(4)    type=USER_AUTH msg=audit(1569008008.350:10732733): user pid=20623 uid=0 auid=4294967295 ses=4294967295 msg='op=pubkey_auth rport=41507 acct="user1" exe="/usr/sbin/sshd" hostname=? addr=10.10.10.10 terminal=? res=success'
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The first 4 events do not have an &lt;STRONG&gt;acct&lt;/STRONG&gt; field (selected from the earlier dropdown). The only way to correlate these 4 events with the ssh session is by capturing from the 5th event of the results, which is from &lt;STRONG&gt;audit.log&lt;/STRONG&gt;. This event includes the &lt;STRONG&gt;acct&lt;/STRONG&gt; field and the value we are searching for, &lt;STRONG&gt;user1&lt;/STRONG&gt;, as well as the value of its corresponding addr &lt;STRONG&gt;10.10.10.10&lt;/STRONG&gt;. A new subsearch will be run to include these 4 events, as well as any other events in &lt;STRONG&gt;audit&lt;/STRONG&gt;, &lt;STRONG&gt;secure&lt;/STRONG&gt; or &lt;STRONG&gt;sudo&lt;/STRONG&gt; that contain only &lt;STRONG&gt;addr&lt;/STRONG&gt;.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(12) type=LOGIN msg=audit(1569008008.358:10732739): pid=20623 uid=0 old auid=4294967295 new auid=1014 old ses=4294967295 new ses=23056
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;In the 12th event, also from &lt;STRONG&gt;audit.log&lt;/STRONG&gt; the &lt;STRONG&gt;auid&lt;/STRONG&gt; is set for &lt;STRONG&gt;user1&lt;/STRONG&gt;. Prior audit.log events had auid set as the RedHat default &lt;STRONG&gt;auid=4294967295&lt;/STRONG&gt;. However, Splunk doesn’t extract this field as &lt;STRONG&gt;new auid&lt;/STRONG&gt;. Checking the values for &lt;STRONG&gt;auid&lt;/STRONG&gt; on this event are both &lt;STRONG&gt;4294967295&lt;/STRONG&gt; and &lt;STRONG&gt;1014&lt;/STRONG&gt;. The field auid has become a &lt;EM&gt;multivalued&lt;/EM&gt; field for this event. Not good. A custom extract was created.&lt;BR /&gt;
Now we have values for the 3 main fields required to perform this search: &lt;STRONG&gt;acct=user1&lt;/STRONG&gt;; &lt;STRONG&gt;addr=10.10.10.10&lt;/STRONG&gt;; and &lt;STRONG&gt;auid=1014&lt;/STRONG&gt;.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(42) 2019-09-20T15:33:28.536160-04:00 ruby01-s sshd[20623]: subsystem request for sftp
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;In event 42, from /var/log/secure, there are no &lt;STRONG&gt;acct&lt;/STRONG&gt;, &lt;STRONG&gt;addr&lt;/STRONG&gt; or &lt;STRONG&gt;auid&lt;/STRONG&gt; fields. This event was discovered because of the &lt;STRONG&gt;source=ps&lt;/STRONG&gt; subsearch performed earlier where the &lt;STRONG&gt;pid&lt;/STRONG&gt; was extracted (&lt;STRONG&gt;20623&lt;/STRONG&gt;). A subsearch for this PID (and all others associated with &lt;STRONG&gt;user1&lt;/STRONG&gt;) needs to be performed across all 3 logs to find any other events.&lt;/P&gt;

&lt;P&gt;After gathering all the events from the 3 logs based on the &lt;STRONG&gt;acct&lt;/STRONG&gt;, &lt;STRONG&gt;auid&lt;/STRONG&gt;, or &lt;STRONG&gt;addr&lt;/STRONG&gt; fields, as well as the PIDs from &lt;STRONG&gt;source=ps&lt;/STRONG&gt;, a final seach is run against all events with the transaction command.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(45) type=SYSCALL msg=audit(1569008008.833:10732770): arch=c000003e syscall=2 success=yes exit=8 a0=7fff309e25b0 a1=42 a2=180 a3=8 items=2 ppid=4246 pid=20623 auid=1014 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=(none) ses=23056 comm="sshd" exe="/usr/sbin/sshd" key="logins" 
type=CWD msg=audit(1569008008.833:10732770): cwd="/" 
type=PATH msg=audit(1569008008.833:10732770): item=0 name="/var/log/" inode=130451 dev=fd:03 mode=040755 ouid=0 ogid=0 rdev=00:00 nametype=PARENT 
type=PATH msg=audit(1569008008.833:10732770): item=1 name="/var/log/lastlog" inode=135218 dev=fd:03 mode=0100644 ouid=0 ogid=0 rdev=00:00 nametype=NORMAL
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;In event 45 you can see the last three(sub?) events of the transaction do not include &lt;STRONG&gt;acct&lt;/STRONG&gt;, &lt;STRONG&gt;auid&lt;/STRONG&gt;, or &lt;STRONG&gt;addr&lt;/STRONG&gt;. These events are correlated by running transaction on the &lt;STRONG&gt;eventid&lt;/STRONG&gt; field (&lt;STRONG&gt;10732770&lt;/STRONG&gt;).&lt;/P&gt;

&lt;P&gt;This process repeats itself multiple times throughout the logs.&lt;/P&gt;

&lt;P&gt;I hope this explains our SysAdmins requirements, and what missing events were discovered when the logs were deep-dived.&lt;/P&gt;

&lt;P&gt;Follow up post will include the updated XML.&lt;/P&gt;

&lt;P&gt;Thanks and God bless,&lt;BR /&gt;
Genesius&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 02:56:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-Optimize-this-Search/m-p/462607#M30365</guid>
      <dc:creator>genesiusj</dc:creator>
      <dc:date>2020-09-30T02:56:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to Optimize this Search</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-Optimize-this-Search/m-p/462608#M30366</link>
      <description>&lt;P&gt;@gcusello &lt;BR /&gt;
Thanks for your suggestions. I just posted a deeper explanation what my requirements are, as well as responding to your suggestions.&lt;BR /&gt;
Thanks and God bless,&lt;BR /&gt;
Genesius&lt;/P&gt;</description>
      <pubDate>Tue, 12 Nov 2019 19:03:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-Optimize-this-Search/m-p/462608#M30366</guid>
      <dc:creator>genesiusj</dc:creator>
      <dc:date>2019-11-12T19:03:41Z</dc:date>
    </item>
  </channel>
</rss>

