[Mon Oct 25 04:17:18.547111 2021] [authz_core:error] [pid 17689] [client 12.34.45.56:60815] AH01630: client denied by server configuration: /path/to/website.com/web/.well-known, referer: abc.com
I just found out, that my error log is not parsed OK (by using cscli metrics) - because I use a non-default format in my apache config for the error log, and crowdsec can’t parse it.
So questions:
how should I tweak, override the default error log parser?
It seems it is misconfigured and hinders all my default crowdsec collections/scenarios. And the custom one(s) too.
a) no easy/clean way to do that and so I should revert my apache config to the defaults, and then configre a 2nd custom errror log - for my needs
b) copy the parser files and edit the collections/scenarios that reference them
c) edit the parser files
b) and c) seem like bad ideas - hard to maintain in the future
And yet, if I go with a) - in general not having a way to fine-tune the parsers kinda sucks.
Maybe start a new topic in the forum about that one ^ ?
Where can I read some docs/howto-s about creating custom parsers, tweaking/overriding the default ones ?
how should I tweak, override the default error log parser?
I think the best way is to create a new parser for that:
1 - create your parser in /etc/crowdsec/parsers/s01-parse/apache_custom_error.yaml
2 - You can use this skeleton for your parser:
and adapt it to your need (don’t forget the modify the grok with your custom format and add/remove the wanted statics)
3 - Then restart crowdsec, your custom errors log should be parsed
Maybe start a new topic in the forum about that one ^ ?
Yes this can be a good idea if it is not clear on what to do !
Where can I read some docs/howto-s about creating custom parsers, tweaking/overriding the default ones ?
Final question:
I’ve decided to use a local file for the offending referrers - so I created a local file:
/var/lib/crowdsec/data/bad_referers_custom.txt
I put in my scenario:
description: “block hosts using offending referers”
filter: |
evt.Meta.log_type == ‘http_access-log’ and any(File(‘bad_referers_custom.txt’), {evt.Parsed.referrer == #})"
data:
The problem is that the referer is captured inside double quote like "abc.com" . I will fix the parser so it will works with ==. I keep you posted when the parser is fixed.
The fix has been merged. Can you upgrade the apache2-logs parser (sudo cscli hub update and sudo cscli parsers upgrade crowdsecurity/apache2-logs ) and retry with the == please?