Skip to content

feat: make the severity of the bounce log line configurable (BOUNCING_LOG_LEVEL) - #160

Open
halkt wants to merge 1 commit into
crowdsecurity:mainfrom
halkt:feat/bouncing-log-level
Open

halkt wants to merge 1 commit into
crowdsecurity:mainfrom
halkt:feat/bouncing-log-level

Conversation

@halkt

@halkt halkt commented Sep 18, 2026 •

Copy link
Copy Markdown

Hello,

Adds a BOUNCING_LOG_LEVEL option so you can choose the log level the bouncer uses
when it blocks a request. The default is alert, which is what it does today, so
nothing changes unless you set it.

We run this bouncer on a site with a lot of traffic. It writes one line every time it
blocks a request. We send our nginx error log to an external service, and those lines
alone are a big part of what we pay for it. On our side a block is normal and expected,
so it is closer to info than to an error.

Today we cannot lower just those lines. error_log sets one level for all of nginx.
That is why we would like to be able to choose this level.

@halkt
halkt marked this pull request as draft September 18, 2026 14:48
The "[Crowdsec] denied '<ip>' with '<remediation>'" line emitted on every
bounced request is hardcoded to ngx.ALERT in csmod.Allow(). alert is more
severe than error, so nginx writes it at every practical error_log level;
the only way to keep it out of the error log is `error_log ... emerg;`,
which also silences nginx's own errors and real bouncer failures such as
"failed to query LAPI" or "Lua shared dict is full".

Since the line is emitted once per bounced request, its volume is unbounded
exactly when the bouncer is doing its job, and operators shipping the error
log elsewhere have no way to opt out of it.

Add a BOUNCING_LOG_LEVEL option taking the nginx error_log severity names.
The name is resolved to the matching ngx.* constant once in csmod.init(),
so the hot path stays a plain field read. Unknown values fall back to the
default with a warning, matching the other enum-like options in config.lua.

The default is "alert", i.e. current behaviour, so this is a no-op unless
the option is set.
@halkt
halkt force-pushed the feat/bouncing-log-level branch from 1c652a1 to e1e35de Compare September 18, 2026 14:49
@halkt
halkt marked this pull request as ready for review September 18, 2026 14:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant