<?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: Why is my time wrongly  mapped whenever I tabulate the results from transactions? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Why-is-my-time-wrongly-mapped-whenever-I-tabulate-the-results/m-p/461620#M130193</link>
    <description>&lt;P&gt;Transaction creates multivalue fields, but they are not guaranteed to align as if they were produced by list. You are combining "Time" and "Command/Events", and the result is likely to be nonsense.&lt;/P&gt;

&lt;P&gt;More importantly, &lt;CODE&gt;transaction&lt;/CODE&gt; is resource-heavy and should be avoided in this context, where you plan to break the individual events right back out again.    &lt;/P&gt;

&lt;P&gt;Probably what you really need here is an initial collection of the events you want, then use eventstats and streamstats to group them and get the fields you are using &lt;CODE&gt;transaction&lt;/CODE&gt; to get.&lt;/P&gt;</description>
    <pubDate>Tue, 26 May 2020 18:06:23 GMT</pubDate>
    <dc:creator>DalJeanis</dc:creator>
    <dc:date>2020-05-26T18:06:23Z</dc:date>
    <item>
      <title>Why is my time wrongly  mapped whenever I tabulate the results from transactions?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-my-time-wrongly-mapped-whenever-I-tabulate-the-results/m-p/461619#M130192</link>
      <description>&lt;P&gt;When I run this SPL, the transaction commands gives the correct output&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=* source=/var/log/secure* (TERM(sudo)  AND (TERM(adduser) OR TERM(chown) OR TERM(userdel) OR TERM(chmod) OR TERM(usermod) OR TERM(useradd))  AND COMMAND!="*egrep*") 
OR (TERM(sshd) AND "Accepted password" AND TERM(from) AND TERM(port))
| regex _raw != ".*bin\/grep|.*bin\/man|.*bin\/which|.*bin\/less|.*bin\/more" 
| rex field=_raw "(?&amp;lt;=sudo:)\s*(?P&amp;lt;Users&amp;gt;[[:alnum:]]\S*[[:alnum:]])\s*(?=\:).*(?&amp;lt;=COMMAND\=)(?P&amp;lt;command&amp;gt;.*)"
| rex field=_raw "(?&amp;lt;=for)\s*(?P&amp;lt;Users&amp;gt;[[:alnum:]]\S*[[:alnum:]])\s*(?=from).*(?&amp;lt;=from)\s*(?P&amp;lt;ip&amp;gt;[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+)"
| eval "Command/Events" = replace(command,"^(\/bin\/|\/sbin\/)","")
| eval Time = if(match(_raw,"(?&amp;lt;=sudo:)\s*[[:alnum:]]\S*[[:alnum:]]\s*(?=\:).*(?&amp;lt;=COMMAND\=)*") ,strftime(_time, "%Y-%d-%m %H:%M:%S"),null())
| eval Date = strftime(_time, "%Y-%d-%m")
| eval "Report ID" = "ABLR-007"
| eval "Agency HF" = if(isnull(agencyhf),"",agencyhf)
| rename host as Hostname, index as Agency
| transaction Date Hostname Users Agency startswith="sshd"  maxevents=-1  keepevicted=true
| regex _raw = ".*sshd\:\n.*sudo\:|.*sudo\:"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;STRONG&gt;Result:&lt;/STRONG&gt;&lt;BR /&gt;
&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/8962iA51E5D9DEC49E83A/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;Then when I tabulate the data using the SPL below, the time is wrong&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=* source=/var/log/secure* (TERM(sudo)  AND (TERM(adduser) OR TERM(chown) OR TERM(userdel) OR TERM(chmod) OR TERM(usermod) OR TERM(useradd))  AND COMMAND!="*egrep*") 
OR (TERM(sshd) AND "Accepted password" AND TERM(from) AND TERM(port))
| regex _raw != ".*bin\/grep|.*bin\/man|.*bin\/which|.*bin\/less|.*bin\/more" 
| rex field=_raw "(?&amp;lt;=sudo:)\s*(?P&amp;lt;Users&amp;gt;[[:alnum:]]\S*[[:alnum:]])\s*(?=\:).*(?&amp;lt;=COMMAND\=)(?P&amp;lt;command&amp;gt;.*)"
| rex field=_raw "(?&amp;lt;=for)\s*(?P&amp;lt;Users&amp;gt;[[:alnum:]]\S*[[:alnum:]])\s*(?=from).*(?&amp;lt;=from)\s*(?P&amp;lt;ip&amp;gt;[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+)"
| eval "Command/Events" = replace(command,"^(\/bin\/|\/sbin\/)","")
| eval Time = if(match(_raw,"(?&amp;lt;=sudo:)\s*[[:alnum:]]\S*[[:alnum:]]\s*(?=\:).*(?&amp;lt;=COMMAND\=)*") ,strftime(_time, "%Y-%d-%m %H:%M:%S"),null())
| eval Date = strftime(_time, "%Y-%d-%m")
| eval "Report ID" = "ABLR-007"
| eval "Agency HF" = if(isnull(agencyhf),"",agencyhf)
| rename host as Hostname, index as Agency
| transaction Date Hostname Users Agency startswith="sshd"  maxevents=-1  keepevicted=true
| regex _raw = ".*sshd\:\n.*sudo\:|.*sudo\:"
| fields "Report ID" Time Agency Command/Events Hostname Users ip "Agency HF"
| rename ip as  "IP Address"
| eval multivalue_fields = mvzip(Time,'Command/Events')
| mvexpand multivalue_fields
| makemv multivalue_fields delim=","
| eval Time=mvindex(multivalue_fields , 0)
| eval "Command/Events"=mvindex(multivalue_fields , 1)
| table "Report ID" Time Agency Command/Events Hostname Users "IP Address" "Agency HF"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;STRONG&gt;Result&lt;/STRONG&gt;&lt;BR /&gt;
&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/8963i52866462EE534625/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;** I also have tried using stats, yes I could combine the data with it. However, I can't use that as I would need to rely heavily on list().  the data sometimes exceeds 100 and the customer does not want me to touch limits.conf so I changed to transaction instead.&lt;/P&gt;</description>
      <pubDate>Fri, 22 May 2020 07:09:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-my-time-wrongly-mapped-whenever-I-tabulate-the-results/m-p/461619#M130192</guid>
      <dc:creator>xnx_1012</dc:creator>
      <dc:date>2020-05-22T07:09:26Z</dc:date>
    </item>
    <item>
      <title>Re: Why is my time wrongly  mapped whenever I tabulate the results from transactions?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Why-is-my-time-wrongly-mapped-whenever-I-tabulate-the-results/m-p/461620#M130193</link>
      <description>&lt;P&gt;Transaction creates multivalue fields, but they are not guaranteed to align as if they were produced by list. You are combining "Time" and "Command/Events", and the result is likely to be nonsense.&lt;/P&gt;

&lt;P&gt;More importantly, &lt;CODE&gt;transaction&lt;/CODE&gt; is resource-heavy and should be avoided in this context, where you plan to break the individual events right back out again.    &lt;/P&gt;

&lt;P&gt;Probably what you really need here is an initial collection of the events you want, then use eventstats and streamstats to group them and get the fields you are using &lt;CODE&gt;transaction&lt;/CODE&gt; to get.&lt;/P&gt;</description>
      <pubDate>Tue, 26 May 2020 18:06:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Why-is-my-time-wrongly-mapped-whenever-I-tabulate-the-results/m-p/461620#M130193</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2020-05-26T18:06:23Z</dc:date>
    </item>
  </channel>
</rss>

