<?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: Strip datetime and group by filename in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Strip-datetime-and-group-by-filename/m-p/503996#M140706</link>
    <description>&lt;P&gt;Depending on what you mean by "file name without date&amp;amp;time", this may help.&amp;nbsp; It ignores the part of the file name after (and including) the first underscore character.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=* namespace=* "File successfully sent -"
| rex "File successfully sent - AllOpenItems(?&amp;lt;reptype&amp;gt;[^_]+)"
| stats count as ReportCount by reptype&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 11 Jun 2020 20:28:24 GMT</pubDate>
    <dc:creator>richgalloway</dc:creator>
    <dc:date>2020-06-11T20:28:24Z</dc:date>
    <item>
      <title>Strip datetime and group by filename</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Strip-datetime-and-group-by-filename/m-p/503947#M140685</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I have the following logs from Cron&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;File successfully sent - AllOpenItemsPT_YYYYMMDD_HR-MM.csv.zip @08:00&lt;/P&gt;&lt;P&gt;File successfully sent - AllOpenItemsPT_YYYYMMDD_HR-MM.csv.zip @10:15&lt;/P&gt;&lt;P&gt;File successfully sent - AllOpenItemsPT_YYYYMMDD_HR-MM.csv.zip @11:00&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;File successfully sent - AllOpenItemsMaint_YYYYMMDD_HR-MM.csv.zip @07:00&lt;/P&gt;&lt;P&gt;File successfully sent - AllOpenItemsMaint_YYYYMMDD_HR-MM.csv.zip @09:00&lt;/P&gt;&lt;P&gt;File successfully sent - AllOpenItemsMaint_YYYYMMDD_HR-MM.csv.zip @13:00&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;File successfully sent - AllOpenItemsCOUNTRYNAME_YYYYMMDD_HR-MM.csv.zip @12:00&lt;/P&gt;&lt;P&gt;File successfully sent - AllOpenItemsCOUNTRYNAME_YYYYMMDD_HR-MM.csv.zip @14:30&lt;/P&gt;&lt;P&gt;File successfully sent - AllOpenItemsCOUNTRYNAME_YYYYMMDD_HR-MM.csv.zip @17:20&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to group the files based on "AllOpenItems" string for last 24 hours and tried the below.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;index=* namespace=*&lt;BR /&gt;"File successfully sent -"| rex "File successfully sent - AllOpenItems(?&amp;lt;reptype&amp;gt;\w+)"|stats values(reptype) as ReportType by reptype&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;The problem with the above is, I am unable to strip the Date&amp;amp;time the file name, so it won't group as per my requirement.&lt;/P&gt;&lt;P&gt;Could someone assist please?&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jun 2020 15:35:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Strip-datetime-and-group-by-filename/m-p/503947#M140685</guid>
      <dc:creator>raghul725</dc:creator>
      <dc:date>2020-06-11T15:35:18Z</dc:date>
    </item>
    <item>
      <title>Re: Strip datetime and group by filename</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Strip-datetime-and-group-by-filename/m-p/503949#M140686</link>
      <description>&lt;P&gt;could you please tell us how your output should look like from those sample logs.&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jun 2020 15:57:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Strip-datetime-and-group-by-filename/m-p/503949#M140686</guid>
      <dc:creator>mayurr98</dc:creator>
      <dc:date>2020-06-11T15:57:40Z</dc:date>
    </item>
    <item>
      <title>Re: Strip datetime and group by filename</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Strip-datetime-and-group-by-filename/m-p/503955#M140688</link>
      <description>&lt;P&gt;Assuming that the strings above are source/filename (or another field) within the events, would the below work for you? &amp;nbsp;This should at least give you fields from the string that you can use with your stats command.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults
| eval source="File successfully sent - AllOpenItemsPT_20200610_08-00.csv.zip @08:00"
| append 
    [| makeresults 
    |  eval source="File successfully sent - AllOpenItemsPT_20200610_10-15.csv.zip @10:15"]
| append 
    [| makeresults 
    |  eval source="File successfully sent - AllOpenItemsPT_20200610_11-00.csv.zip @11:00"]
| append 
    [| makeresults 
    |  eval source="File successfully sent - AllOpenItemsMaint_20200610_07-00.csv.zip @07:00"]
| append 
    [| makeresults 
    |  eval source="File successfully sent - AllOpenItemsMaint_20200610_09-00.csv.zip @09:00"]
| append 
    [| makeresults 
    |  eval source="File successfully sent - AllOpenItemsMaint_20200610_13-00.csv.zip @13:00"]
| append 
    [| makeresults 
    |  eval source="File successfully sent - AllOpenItemsUS_20200610_12-00.csv.zip @12:00"]
| append 
    [| makeresults 
    |  eval source="File successfully sent - AllOpenItemsUS_20200610_14-30.csv.zip @14:30"]
| append 
    [| makeresults 
    |  eval source="File successfully sent - AllOpenItemsUS_20200610_17-20.csv.zip @17:20"]
| rex field=source "(?&amp;lt;prefix&amp;gt;File successfully sent - AllOpenItems)((?&amp;lt;description&amp;gt;[^_]*)_(?&amp;lt;dt&amp;gt;[^_]*)_(?&amp;lt;tm&amp;gt;\d{2}-\d{2}))"
| table _time, prefix, description, dt, tm
| stats values(description) as description&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jun 2020 16:13:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Strip-datetime-and-group-by-filename/m-p/503955#M140688</guid>
      <dc:creator>ChrisH</dc:creator>
      <dc:date>2020-06-11T16:13:45Z</dc:date>
    </item>
    <item>
      <title>Re: Strip datetime and group by filename</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Strip-datetime-and-group-by-filename/m-p/503959#M140689</link>
      <description>&lt;P&gt;See if this helps.&amp;nbsp; It breaks out the filename and time separately.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=* namespace=*
"File successfully sent -"| rex "File successfully sent - AllOpenItems(?&amp;lt;reptype&amp;gt;\S+)"
| rex field=reptype "_(?&amp;lt;time&amp;gt;[^\.]+)"
| eval epoch=strptime(time,"%Y%M%D_%H-%M")
|stats values(reptype) as ReportType by epoch&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jun 2020 16:47:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Strip-datetime-and-group-by-filename/m-p/503959#M140689</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2020-06-11T16:47:46Z</dc:date>
    </item>
    <item>
      <title>Re: Strip datetime and group by filename</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Strip-datetime-and-group-by-filename/m-p/503965#M140691</link>
      <description>&lt;P&gt;Sure, Group by file name without date&amp;amp;time&amp;nbsp; (Example - AllOpenItemsPT, AllOpenItemsMaint etc) and display the count.&lt;BR /&gt;But thinking about it, it may be useful to display the date&amp;amp;time as well, but then my previous group by won't work&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jun 2020 16:42:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Strip-datetime-and-group-by-filename/m-p/503965#M140691</guid>
      <dc:creator>raghul725</dc:creator>
      <dc:date>2020-06-11T16:42:36Z</dc:date>
    </item>
    <item>
      <title>Re: Strip datetime and group by filename</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Strip-datetime-and-group-by-filename/m-p/503968#M140692</link>
      <description>&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&amp;nbsp; But as soon as I add "by epoch", search says no event returned.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I guess group by epoch does apply here, because epoch is defined by -&amp;nbsp;%Y%M%D_%H-%M"&lt;/P&gt;&lt;P&gt;And none of the files can be grouped based on that?&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jun 2020 17:04:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Strip-datetime-and-group-by-filename/m-p/503968#M140692</guid>
      <dc:creator>raghul725</dc:creator>
      <dc:date>2020-06-11T17:04:44Z</dc:date>
    </item>
    <item>
      <title>Re: Strip datetime and group by filename</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Strip-datetime-and-group-by-filename/m-p/503979#M140697</link>
      <description>Before we go further down the wrong rabbit hole, what exactly do you want the output to look like?</description>
      <pubDate>Thu, 11 Jun 2020 18:21:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Strip-datetime-and-group-by-filename/m-p/503979#M140697</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2020-06-11T18:21:57Z</dc:date>
    </item>
    <item>
      <title>Re: Strip datetime and group by filename</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Strip-datetime-and-group-by-filename/m-p/503986#M140700</link>
      <description>&lt;P&gt;Sure, Group by file name without date&amp;amp;time&amp;nbsp; (Example - AllOpenItemsPT, AllOpenItemsMaint etc) and display the count.&lt;BR /&gt;But thinking about it, it may be useful to display the date&amp;amp;time as well, but then my previous group by won't work&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jun 2020 18:57:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Strip-datetime-and-group-by-filename/m-p/503986#M140700</guid>
      <dc:creator>raghul725</dc:creator>
      <dc:date>2020-06-11T18:57:09Z</dc:date>
    </item>
    <item>
      <title>Re: Strip datetime and group by filename</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Strip-datetime-and-group-by-filename/m-p/503996#M140706</link>
      <description>&lt;P&gt;Depending on what you mean by "file name without date&amp;amp;time", this may help.&amp;nbsp; It ignores the part of the file name after (and including) the first underscore character.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=* namespace=* "File successfully sent -"
| rex "File successfully sent - AllOpenItems(?&amp;lt;reptype&amp;gt;[^_]+)"
| stats count as ReportCount by reptype&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jun 2020 20:28:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Strip-datetime-and-group-by-filename/m-p/503996#M140706</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2020-06-11T20:28:24Z</dc:date>
    </item>
    <item>
      <title>Re: Strip datetime and group by filename</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Strip-datetime-and-group-by-filename/m-p/504083#M140726</link>
      <description>&lt;P&gt;Hello Again,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As soon as I group "by reptype", no events are returned.&lt;/P&gt;&lt;P&gt;Any other suggestions please?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jun 2020 08:21:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Strip-datetime-and-group-by-filename/m-p/504083#M140726</guid>
      <dc:creator>raghul725</dc:creator>
      <dc:date>2020-06-12T08:21:41Z</dc:date>
    </item>
    <item>
      <title>Re: Strip datetime and group by filename</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Strip-datetime-and-group-by-filename/m-p/504139#M140737</link>
      <description>&lt;P&gt;It works fine in this run-anywhere example.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults annotate=t| eval data="File successfully sent - AllOpenItemsPT_YYYYMMDD_HR-MM.csv.zip @08:00|File successfully sent - AllOpenItemsPT_YYYYMMDD_HR-MM.csv.zip @10:15|File successfully sent - AllOpenItemsPT_YYYYMMDD_HR-MM.csv.zip @11:00|File successfully sent - AllOpenItemsMaint_YYYYMMDD_HR-MM.csv.zip @07:00|File successfully sent - AllOpenItemsMaint_YYYYMMDD_HR-MM.csv.zip @09:00|File successfully sent - AllOpenItemsMaint_YYYYMMDD_HR-MM.csv.zip @13:00|File successfully sent - AllOpenItemsCOUNTRYNAME_YYYYMMDD_HR-MM.csv.zip @12:00|File successfully sent - AllOpenItemsCOUNTRYNAME_YYYYMMDD_HR-MM.csv.zip @14:30|File successfully sent - AllOpenItemsCOUNTRYNAME_YYYYMMDD_HR-MM.csv.zip @17:20" | eval data=split(data,"|") | mvexpand data
`comment("Above sets up test data")`
| rex field=data "File successfully sent - AllOpenItems(?&amp;lt;reptype&amp;gt;[^_]+)"
| stats count as ReportCount by reptype&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 12 Jun 2020 12:43:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Strip-datetime-and-group-by-filename/m-p/504139#M140737</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2020-06-12T12:43:14Z</dc:date>
    </item>
    <item>
      <title>Re: Strip datetime and group by filename</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Strip-datetime-and-group-by-filename/m-p/504143#M140738</link>
      <description>&lt;P&gt;I see what the confusion could be. Sorry I should have been clear.&lt;/P&gt;&lt;P&gt;When I said&amp;nbsp;&lt;/P&gt;&lt;P&gt;File successfully sent - AllOpenItemsPT_YYYYMMDD_HR-MM.csv.zip @08:00&lt;/P&gt;&lt;P&gt;File successfully sent - AllOpenItemsPT_YYYYMMDD_HR-MM.csv.zip @10:15&lt;/P&gt;&lt;P&gt;File successfully sent - AllOpenItemsPT_YYYYMMDD_HR-MM.csv.zip @11:00&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The time after&amp;nbsp;@ is not in the logs, that was just an example stating it runs around that time.&lt;/P&gt;&lt;P&gt;So to put it simply the logs would like&amp;nbsp;&lt;/P&gt;&lt;P&gt;File successfully sent - AllOpenItemsPT_YYYYMMDD_HR-MM.csv.zip&lt;/P&gt;&lt;P&gt;Would your suggestion still work please?&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jun 2020 12:49:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Strip-datetime-and-group-by-filename/m-p/504143#M140738</guid>
      <dc:creator>raghul725</dc:creator>
      <dc:date>2020-06-12T12:49:16Z</dc:date>
    </item>
    <item>
      <title>Re: Strip datetime and group by filename</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Strip-datetime-and-group-by-filename/m-p/504145#M140740</link>
      <description>Removing the times changes nothing. Did you try my test query?</description>
      <pubDate>Fri, 12 Jun 2020 12:52:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Strip-datetime-and-group-by-filename/m-p/504145#M140740</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2020-06-12T12:52:36Z</dc:date>
    </item>
    <item>
      <title>Re: Strip datetime and group by filename</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Strip-datetime-and-group-by-filename/m-p/504154#M140743</link>
      <description>&lt;P&gt;Yes I tried your test query it works&lt;/P&gt;&lt;P&gt;And tried it immediately without time after @&amp;amp; I thought it would work and it did.&lt;/P&gt;&lt;P&gt;OK now,&lt;/P&gt;&lt;P&gt;If I run the query against my logs using search i.e. by not passing the log lines via the query, I see 31 events for yesterday, but statistics (0).&lt;/P&gt;&lt;P&gt;As usual if I remove "by reptype", returns the count as 31 under statistics.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jun 2020 13:20:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Strip-datetime-and-group-by-filename/m-p/504154#M140743</guid>
      <dc:creator>raghul725</dc:creator>
      <dc:date>2020-06-12T13:20:24Z</dc:date>
    </item>
    <item>
      <title>Re: Strip datetime and group by filename</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Strip-datetime-and-group-by-filename/m-p/504156#M140744</link>
      <description>The stats command will return no results if the field used in the 'by' clause is empty. Check that the field in the 'by' clause is spelled correctly and that it has values.</description>
      <pubDate>Fri, 12 Jun 2020 13:24:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Strip-datetime-and-group-by-filename/m-p/504156#M140744</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2020-06-12T13:24:19Z</dc:date>
    </item>
  </channel>
</rss>

