Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exclude health check probes from access logs #48

Open
fiunchinho opened this issue Aug 6, 2018 · 4 comments
Open

Exclude health check probes from access logs #48

fiunchinho opened this issue Aug 6, 2018 · 4 comments

Comments

@fiunchinho
Copy link
Contributor

Hi!
It's common to have a load balancer or container orchestration system probing that your application is ready to serve traffic. At the moment, I'm using Janino to exclude those access logs from appearing, but I believe it's such a common issue that it would be helpful to provide a Spring property to enable/disable excluding the health check access logs.
The request uri to be excluded would be the actuator health endpoint, and only when the response is 200 OK. That way, if something goes wrong, you still see the errors. But you no longer get an infinite log full of GET /health 200 OK.

I'd be happy to contribute, but I don't know how that can be done in this library.

@a8t3r
Copy link
Contributor

a8t3r commented Dec 3, 2018

Hello!

Logback access filters are designed to solve this problem. Can you more clearly explain your use case with janino? I'm a little puzzled, because logback also uses janino for filters:

<filter class="ch.qos.logback.core.filter.EvaluatorFilter">
    <evaluator name="EvalActuator">
        <expression>
         !((event.getStatusCode() == 200) &amp;&amp; (event.getRequestURI().startsWith("/actuator"))
        </expression>
    </evaluator>
    <onMismatch>DENY</onMismatch>
</filter>

@nightswimmings
Copy link

nightswimmings commented Jan 25, 2019

actuators context is customizable... I think it would be much better to use a custom spring boot property, something like spring.logging.access.exclude-url-patterns

@adammichalik
Copy link

Another way to configure the EvaluatorFilter:

<filter class="ch.qos.logback.core.filter.EvaluatorFilter">
    <evaluator class="ch.qos.logback.access.net.URLEvaluator">
        <URL>/health</URL>
        <!-- add more URLs as needed -->
    </evaluator>
    <OnMismatch>NEUTRAL</OnMismatch>
    <OnMatch>DENY</OnMatch>
</filter>

@akkinoc akkinoc added this to the v2 milestone Sep 5, 2021
@akkinoc akkinoc removed this from the v2 milestone Oct 24, 2021
@saranyajithin
Copy link

Hi @fiunchinho
I would like to know how you enabled actuator health logs to be printed with status?

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

No branches or pull requests

6 participants