Tried your syntax, however didn’t get very far. I also tried with/without the datepattern syntax.
Without the datepattern syntax I only get the below upon a failed login in the fail2ban logs.
It seems to be grabbing the first line and ignoring the second entry which contains the “Bad Request” entry even though it is in the regex filter.
2023-09-28 13:38:52,478 fail2ban.filter [1]: WARNING [grafana] Please check a jail for a timing issue. Line with odd timestamp: logger=authn.service t=2023-09-28T14:38:52.46676519-06:00 level=warn msg=“Failed to authenticate request” client=auth.client.form error=“[password-auth.failed] failed to authenticate identity: [identity.not-found] no user fund: user not found”
You definitely need the datepattern… fail2ban doesn’t know what to do with more than 3 digits of milliseconds, which is why you’re getting the “Line with odd timestamp” error. I think it also struggles when the date isn’t the first thing in the line, which is why my datepattern starts with ^(?:[^=]+=[^ ]* )+t=
As for which line fail2ban “sees,” it’s really just checking every line against the failregex and seeing if it matches.
Looking a little closer, the value in the error= doesn’t work with this regex. Can you try this instead?
I updated my Grafana to 10.1.2 and confirmed that the log messages for failed logins have changed.
After spending a little more time on this, I think the regex I provided above could result in false positives if some other event triggers a log with msg="Bad request". With that in mind, I’ve updated to what I believe will be a more reliable regex that focuses on the errror= section of the log entry. I also tweaked the datepattern to hopefully be more robust if the log format changes again.
Are you sure you’re using the failregex I posted in this post? I ask because that failregex will only pick up log messages that have error="[password-auth.failed] in the log line. Your example doesn’t even have an error section, so I don’t see how my failregex could be triggered by that log line.
Is it possible you have another jail looking at the same log file that uses a different failregex?
It appears I did have a jail/filter for traefik access.log which may have spurred the ban. I have removed the traefik.conf filter to see if it will resolve the issue.