Detect data spikes (loops) in MySQL database and ignore these
Acoording to your pattern, you could do something like this (change your column names and url pattern accordingly):

mysql&gt; SET @max_redirects := 10;
Query OK, 0 rows affected (0.00 sec)

mysql&gt; SELECT count(*) as `# redirects`, ip, min(url) as url, 
              time_event - INTERVAL SECOND(time_event) SECOND AS minute 
       FROM log WHERE url like '/login?redirect=%' 
       GROUP BY ip, minute 
       HAVING `# redirects` &gt; @max_redirects;
+-------------+-----------------+----------------------+---------------------+
| # redirects | ip              | url                  | minute              |
+-------------+-----------------+----------------------+---------------------+
|          53 | 1.1.1.1         | /login?redirect=/    | 2014-08-05 08:03:00 |
|          21 | 1.1.1.1         | /login?redirect=/    | 2014-08-05 08:05:00 |
|         128 | 123.123.123.123 | /login?redirect=/app | 2014-01-01 10:00:00 |
+-------------+-----------------+----------------------+---------------------+
3 rows in set (0.01 sec)


Expect this to be slow on a tall table, so add an index on your timestamp column and filter by date to avoid huge sorts.