<?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 extract time from bash_history # timestamp? in Deployment Architecture</title>
    <link>https://community.splunk.com/t5/Deployment-Architecture/How-to-extract-time-from-bash-history-timestamp/m-p/484211#M16806</link>
    <description>&lt;P&gt;Try &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; # props.conf
 [bash_history]
 # define event breaking behavior
 LINE_BREAKER = ([\r\n]+)\#\d+
 SHOULD_LINEMERGE = false

 # define time parsing behavior
 TIME_PREFIX = #
 TIME_FORMAT = %s
 MAX_TIMESTAMP_LOOKAHEAD = 12
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 17 Jan 2020 02:15:15 GMT</pubDate>
    <dc:creator>jarizeloyola</dc:creator>
    <dc:date>2020-01-17T02:15:15Z</dc:date>
    <item>
      <title>How to extract time from bash_history # timestamp?</title>
      <link>https://community.splunk.com/t5/Deployment-Architecture/How-to-extract-time-from-bash-history-timestamp/m-p/484207#M16802</link>
      <description>&lt;P&gt;I'm dealing with bash_history files in the following format. I would like to extract the timestamp and use that as the event timestamp, but I'm having some issues doing so.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;#1579207583
whoami
#1579207584
cd /var/log
#1579207590
cat messages
#1579207595
id
#1579207598
exit
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I'm using the following thread as reference: &lt;A href="https://answers.splunk.com/answers/60015/splunking-bash-history.html" target="_blank"&gt;https://answers.splunk.com/answers/60015/splunking-bash-history.html&lt;/A&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; [bash_history]
 BREAK_ONLY_BEFORE = #(?=\d+)
 MAX_TIMESTAMP_LOOKAHEAD = 11
 SHOULD_LINEMERGE = true
 TIME_FORMAT = %s
 TIME_PREFIX = #
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;We've changed a number of variables (set TIME_PREFIX = ^#, set MAX_TIMESTAMP_LOOKAHEAD to a higher value, etc.), but nothing seems to be working correctly.&lt;/P&gt;

&lt;P&gt;The events do break in the correct place (#), and they do merge, so we get "groups" of events like:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;#1579207583
 whoami
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;However, the timestamp for the event isn't set to that value. All events are set to the date/time that history was written on, so everything for any given session is the same.&lt;/P&gt;

&lt;P&gt;That props.conf configuration -appears- correct, and our sourcetype is named bash_history (we've also tried source::/root/.bash_history, without success). I'm not sure where we are going wrong, but any suggestions would be welcome.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 03:40:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Deployment-Architecture/How-to-extract-time-from-bash-history-timestamp/m-p/484207#M16802</guid>
      <dc:creator>peterm30</dc:creator>
      <dc:date>2020-09-30T03:40:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract time from bash_history # timestamp?</title>
      <link>https://community.splunk.com/t5/Deployment-Architecture/How-to-extract-time-from-bash-history-timestamp/m-p/484208#M16803</link>
      <description>&lt;P&gt;Can you check the errors and warning you are receiving for date time parsing on the receiving SPLUNK instance &lt;/P&gt;</description>
      <pubDate>Thu, 16 Jan 2020 22:16:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Deployment-Architecture/How-to-extract-time-from-bash-history-timestamp/m-p/484208#M16803</guid>
      <dc:creator>badrinath_itrs</dc:creator>
      <dc:date>2020-01-16T22:16:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract time from bash_history # timestamp?</title>
      <link>https://community.splunk.com/t5/Deployment-Architecture/How-to-extract-time-from-bash-history-timestamp/m-p/484209#M16804</link>
      <description>&lt;P&gt;Where did you place your props.conf ?&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jan 2020 23:49:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Deployment-Architecture/How-to-extract-time-from-bash-history-timestamp/m-p/484209#M16804</guid>
      <dc:creator>jarizeloyola</dc:creator>
      <dc:date>2020-01-16T23:49:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract time from bash_history # timestamp?</title>
      <link>https://community.splunk.com/t5/Deployment-Architecture/How-to-extract-time-from-bash-history-timestamp/m-p/484210#M16805</link>
      <description>&lt;P&gt;I wonder if you replaced your entire props config as posted with just the below if this would cover both the line breaking and the timestamping?  Maybe test and let me know?&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;[bash_history]&lt;BR /&gt;
LINE_BREAKER = (^\#)\d+&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jan 2020 23:54:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Deployment-Architecture/How-to-extract-time-from-bash-history-timestamp/m-p/484210#M16805</guid>
      <dc:creator>marycordova</dc:creator>
      <dc:date>2020-01-16T23:54:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract time from bash_history # timestamp?</title>
      <link>https://community.splunk.com/t5/Deployment-Architecture/How-to-extract-time-from-bash-history-timestamp/m-p/484211#M16806</link>
      <description>&lt;P&gt;Try &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; # props.conf
 [bash_history]
 # define event breaking behavior
 LINE_BREAKER = ([\r\n]+)\#\d+
 SHOULD_LINEMERGE = false

 # define time parsing behavior
 TIME_PREFIX = #
 TIME_FORMAT = %s
 MAX_TIMESTAMP_LOOKAHEAD = 12
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 17 Jan 2020 02:15:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Deployment-Architecture/How-to-extract-time-from-bash-history-timestamp/m-p/484211#M16806</guid>
      <dc:creator>jarizeloyola</dc:creator>
      <dc:date>2020-01-17T02:15:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract time from bash_history # timestamp?</title>
      <link>https://community.splunk.com/t5/Deployment-Architecture/How-to-extract-time-from-bash-history-timestamp/m-p/484212#M16807</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;| makeresults
| eval _raw="#1579207583
whoami
#1579207584
cd /var/log
#1579207590
cat messages
#1579207595
id
#1579207598
exit"
 `comment("this is sample you provide")`
| rex max_match=100 "(?:#)(?&amp;lt;time&amp;gt;\w+)"
| rex max_match=100 "(?m)^(?=[^#])(?&amp;lt;command&amp;gt;.+)$"
| eval tmp=mvzip(time,command)
| stats count by tmp
| eval _time=mvindex(split(tmp,","),0), command=mvindex(split(tmp,","),1)
| table _time command
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If &lt;CODE&gt;props.conf&lt;/CODE&gt;  doesn't work, you can extract it with this query.&lt;/P&gt;</description>
      <pubDate>Fri, 17 Jan 2020 04:24:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Deployment-Architecture/How-to-extract-time-from-bash-history-timestamp/m-p/484212#M16807</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-01-17T04:24:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract time from bash_history # timestamp?</title>
      <link>https://community.splunk.com/t5/Deployment-Architecture/How-to-extract-time-from-bash-history-timestamp/m-p/484213#M16808</link>
      <description>&lt;P&gt;If it is still possible to change the host configuration, I'd suggest to set the variable HISTTIMEFORMAT to '%F %T ' which will not make any time extraction work unnecessary, but also human readable. For example for CentOS you can add to /etc/profile (or some other bash config file):&lt;BR /&gt;
  HISTTIMEFORMAT='%F %T '&lt;/P&gt;

&lt;P&gt;the bash_history looks like this:&lt;BR /&gt;
      999  2020-01-17 11:30:27 ping 192.168.1.2&lt;BR /&gt;
     1000  2020-01-17 11:30:30 history&lt;BR /&gt;
     1001  2020-01-17 11:30:40 set|grep FORMAT&lt;BR /&gt;
     1002  2020-01-17 11:30:44 man bash&lt;BR /&gt;
     1003  2020-01-17 11:31:12 export HISTTIMEFORMAT='%F %T '&lt;BR /&gt;
     1004  2020-01-17 11:31:13 history&lt;/P&gt;

&lt;P&gt;don't miss a space before the final quote!&lt;/P&gt;</description>
      <pubDate>Fri, 17 Jan 2020 10:41:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Deployment-Architecture/How-to-extract-time-from-bash-history-timestamp/m-p/484213#M16808</guid>
      <dc:creator>PavelP</dc:creator>
      <dc:date>2020-01-17T10:41:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract time from bash_history # timestamp?</title>
      <link>https://community.splunk.com/t5/Deployment-Architecture/How-to-extract-time-from-bash-history-timestamp/m-p/484214#M16809</link>
      <description>&lt;P&gt;After looking in a few logs where I would expect and error to be (if there was one) I did a grep of -all- logs in /opt/splunk/var/log/splunk/ for "bash" and found nothing. Is there a specific log and/or keyword you know to check for?&lt;/P&gt;</description>
      <pubDate>Fri, 17 Jan 2020 14:52:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Deployment-Architecture/How-to-extract-time-from-bash-history-timestamp/m-p/484214#M16809</guid>
      <dc:creator>peterm30</dc:creator>
      <dc:date>2020-01-17T14:52:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract time from bash_history # timestamp?</title>
      <link>https://community.splunk.com/t5/Deployment-Architecture/How-to-extract-time-from-bash-history-timestamp/m-p/484215#M16810</link>
      <description>&lt;P&gt;It was deployed from the deployment server within the Splunk_TA_nix app to the UF's (so /opt/splunk/etc/deployment-apps/Splunk_TA_nix/local/)&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 03:41:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Deployment-Architecture/How-to-extract-time-from-bash-history-timestamp/m-p/484215#M16810</guid>
      <dc:creator>peterm30</dc:creator>
      <dc:date>2020-09-30T03:41:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract time from bash_history # timestamp?</title>
      <link>https://community.splunk.com/t5/Deployment-Architecture/How-to-extract-time-from-bash-history-timestamp/m-p/484216#M16811</link>
      <description>&lt;P&gt;No luck, it's breaking... weird. So one event comes in as&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;hi this is a text
#1579273320
exit
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And the previous one as:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;1579273315
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;(the timestamp minux the #). It appears to alternate like this. Neither appears to be actually using this as the timestamp for the event though.&lt;/P&gt;</description>
      <pubDate>Fri, 17 Jan 2020 15:09:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Deployment-Architecture/How-to-extract-time-from-bash-history-timestamp/m-p/484216#M16811</guid>
      <dc:creator>peterm30</dc:creator>
      <dc:date>2020-01-17T15:09:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract time from bash_history # timestamp?</title>
      <link>https://community.splunk.com/t5/Deployment-Architecture/How-to-extract-time-from-bash-history-timestamp/m-p/484217#M16812</link>
      <description>&lt;P&gt;No luck, it appears to be line breaking at the correct place, as my original props.conf did. However, it's still not parsing the timestamp.&lt;/P&gt;</description>
      <pubDate>Fri, 17 Jan 2020 15:20:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Deployment-Architecture/How-to-extract-time-from-bash-history-timestamp/m-p/484217#M16812</guid>
      <dc:creator>peterm30</dc:creator>
      <dc:date>2020-01-17T15:20:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract time from bash_history # timestamp?</title>
      <link>https://community.splunk.com/t5/Deployment-Architecture/How-to-extract-time-from-bash-history-timestamp/m-p/484218#M16813</link>
      <description>&lt;P&gt;That's actually exactly what's in place. However, the internal log format is always timestamped with the #epoch timestamp. The behavior is described here: &lt;A href="https://unix.stackexchange.com/questions/214322/write-bash-history-to-a-file-with-a-timestamp"&gt;https://unix.stackexchange.com/questions/214322/write-bash-history-to-a-file-with-a-timestamp&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;In other words, if you can the raw log, regardless of HISTTIMEFORMAT, you get #. Since Splunk is reading the raw log is what it gets.&lt;/P&gt;</description>
      <pubDate>Fri, 17 Jan 2020 16:52:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Deployment-Architecture/How-to-extract-time-from-bash-history-timestamp/m-p/484218#M16813</guid>
      <dc:creator>peterm30</dc:creator>
      <dc:date>2020-01-17T16:52:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract time from bash_history # timestamp?</title>
      <link>https://community.splunk.com/t5/Deployment-Architecture/How-to-extract-time-from-bash-history-timestamp/m-p/484219#M16814</link>
      <description>&lt;P&gt;I figured it out. The "default/props.conf" in Splunk_TA_nix contains several lines that affect the timestamp. I copied these to "local/props.conf" and unset them (didn't provide a value), and now it's working. Final props.conf looks like...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[bash_history]
BREAK_ONLY_BEFORE = #(?=\d+)
MAX_TIMESTAMP_LOOKAHEAD = 10
SHOULD_LINEMERGE = true
TIME_FORMAT = %s
TIME_PREFIX = ^#
EVENT_BREAKER_ENABLE =
DATETIME_CONFIG =
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I also added a field extraction for the command itself:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;^#\d+\s+(?P&amp;lt;command&amp;gt;.+) 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;TL;DR - It was working from the beginning, but other values in default were affecting the final result.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 03:41:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Deployment-Architecture/How-to-extract-time-from-bash-history-timestamp/m-p/484219#M16814</guid>
      <dc:creator>peterm30</dc:creator>
      <dc:date>2020-09-30T03:41:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract time from bash_history # timestamp?</title>
      <link>https://community.splunk.com/t5/Deployment-Architecture/How-to-extract-time-from-bash-history-timestamp/m-p/484220#M16815</link>
      <description>&lt;P&gt;Never use the &lt;CODE&gt;break_*&lt;/CODE&gt; settings.  Try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[bash_history]
SHOULD_LINEMERGE = false
LINE_BREAKER = ([\r\n]+[\s#]*)
TIME_PREFIX = ^
TIME_FORMAT = %s
MAX_TIMESTAMP_LOOKAHEAD = 10
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But that is probably not your problem.  If you are sure that your settings are correct, it must be something else.  If you are doing a sourcetype override/overwrite, you must use the &lt;EM&gt;ORIGINAL&lt;/EM&gt; value, &lt;EM&gt;NOT&lt;/EM&gt; the new value.  You must deploy your settings to the first full instance(s) of Splunk that handle the events (usually either the HF tier if you use one, or else your Indexer tier) UNLESS you are using HEC's JSON endpoint (it gets pre-cooked) or INDEXED_EXTRACTIONS (configs go on the UF in that case), then restart all Splunk instances there.  When (re)evaluating, you must send in new events (old events will stay broken), then test using &lt;CODE&gt;_index_earliest=-5m&lt;/CODE&gt; to be absolutely certain that you are only examining the newly indexed events.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 03:45:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Deployment-Architecture/How-to-extract-time-from-bash-history-timestamp/m-p/484220#M16815</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2020-09-30T03:45:38Z</dc:date>
    </item>
  </channel>
</rss>

