<?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: Using Time Range with Bin in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Using-Time-Range-with-Bin/m-p/707745#M239360</link>
    <description>&lt;P class="lia-align-left"&gt;Hi&lt;/P&gt;&lt;P class="lia-align-left"&gt;you could find quite many examples for this with query&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;site:community.splunk.com%20login%20failed%20more%20than%205%20times%20per%20hour%20solved&lt;/LI-CODE&gt;&lt;P&gt;just copy paste this to google.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;In your example there is at least one misunderstanding. You have add “bin _time span=24h”, later you are expecting that your _time is divided into 1 hour span. But just google those examples and then change your query or just create a new.&lt;/P&gt;&lt;P&gt;With splunk there is rarely only one correct solution!&lt;/P&gt;&lt;P&gt;Happy splunking!&lt;/P&gt;</description>
    <pubDate>Mon, 30 Dec 2024 17:12:04 GMT</pubDate>
    <dc:creator>isoutamo</dc:creator>
    <dc:date>2024-12-30T17:12:04Z</dc:date>
    <item>
      <title>Using Time Range with Bin</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Using-Time-Range-with-Bin/m-p/707734#M239359</link>
      <description>&lt;P&gt;Splunkers&lt;BR /&gt;I'm trying to detect when a user fails GT 5 times in time range of one hour for last 24h, and i have the splq below, but i would like to have an opinion from community if any other option is to use splq logic to do the same?&lt;/P&gt;
&lt;P&gt;SPLQ Used&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;index=VPN_Something
| bin _time span=24h
| stats list(status) as Attempts, count(eval(match(status,"failure"))) as Failed, count(eval(match(status,"success"))) as Success by _time user
| eval "Time Range"= strftime(_time,"%Y-%m-%d %H:%M")
| eval "Time Range"= 'Time Range'.strftime(_time+3600,"- %H:%M")
| where Failed &amp;gt; 5&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 30 Dec 2024 17:00:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Using-Time-Range-with-Bin/m-p/707734#M239359</guid>
      <dc:creator>CyberWolf</dc:creator>
      <dc:date>2024-12-30T17:00:24Z</dc:date>
    </item>
    <item>
      <title>Re: Using Time Range with Bin</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Using-Time-Range-with-Bin/m-p/707745#M239360</link>
      <description>&lt;P class="lia-align-left"&gt;Hi&lt;/P&gt;&lt;P class="lia-align-left"&gt;you could find quite many examples for this with query&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;site:community.splunk.com%20login%20failed%20more%20than%205%20times%20per%20hour%20solved&lt;/LI-CODE&gt;&lt;P&gt;just copy paste this to google.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;In your example there is at least one misunderstanding. You have add “bin _time span=24h”, later you are expecting that your _time is divided into 1 hour span. But just google those examples and then change your query or just create a new.&lt;/P&gt;&lt;P&gt;With splunk there is rarely only one correct solution!&lt;/P&gt;&lt;P&gt;Happy splunking!&lt;/P&gt;</description>
      <pubDate>Mon, 30 Dec 2024 17:12:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Using-Time-Range-with-Bin/m-p/707745#M239360</guid>
      <dc:creator>isoutamo</dc:creator>
      <dc:date>2024-12-30T17:12:04Z</dc:date>
    </item>
    <item>
      <title>Re: Using Time Range with Bin</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Using-Time-Range-with-Bin/m-p/707746#M239361</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/273420"&gt;@CyberWolf&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;There's a tendency among practitioners to bin time into buckets rounded to the nearest time interval, e.g. 1 hour: 00:00, 01:00, 02:00, etc.; however, this results in counting errors. Instead, count using a rolling window in ascending _time order:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;index=VPN_Something status=failure
| stats count by _time user
| streamstats time_window=1h sum(count) as failure_count by user
| where failure_count&amp;gt;5&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Since you're only interested in a 1-hour window, your search time range only needs span the last hour plus any allowance for ingest lag and a buffer to accommodate your scheduling interval.&lt;/P&gt;&lt;P&gt;See&amp;nbsp;&lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Streamstats" target="_blank" rel="noopener"&gt;https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Streamstats&lt;/A&gt;&amp;nbsp;for information on scaling streamstats.&lt;/P&gt;&lt;P&gt;If you're using accelerated data models or indexed fields or if your raw events are structured in key-value pairs separated by minor breakers, you can use tstats to greatly improve the performance of the search.&lt;/P&gt;&lt;P&gt;If you have the capacity, you might also consider a real-time search that counts events as they're indexed, although the results may be incorrect relative to your requirements. If you have Splunk Enterprise Security, look at the "&lt;SPAN&gt;Access - Excessive Failed Logins - Rule" correlation search. For reference, it's a real-time search scheduled every 5 minutes (*/5 * * * *), with earliest=rt-65m@m and latest=rt-5m@m:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;| from datamodel:"Authentication"."Failed_Authentication" | stats values("tag") as "tag",dc("user") as "user_count",dc("dest") as "dest_count",count by "app","src" | where 'count'&amp;gt;=6&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the Authentication data model, app would be something like vpn, and src would be a device identifier.&lt;/P&gt;&lt;P&gt;As&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/214410"&gt;@isoutamo&lt;/a&gt;&amp;nbsp;wrote, there are many approximate solutions to this problem. The correct solution depends on your requirements and your tolerance for counting errors.&lt;/P&gt;</description>
      <pubDate>Mon, 30 Dec 2024 17:44:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Using-Time-Range-with-Bin/m-p/707746#M239361</guid>
      <dc:creator>tscroggins</dc:creator>
      <dc:date>2024-12-30T17:44:14Z</dc:date>
    </item>
  </channel>
</rss>

