linkstack-docker icon indicating copy to clipboard operation
linkstack-docker copied to clipboard

Healthcheck spam

Open STaRDoGG opened this issue 2 years ago • 2 comments

I noticed in the logs there's what I call "healthcheck spam" that makes it hard to glean important stuff when needed. I get around this in my containers like this (it still does the healthcheck, but doesn't spam the log):

image

in the dockerfile I put:

# Container healthcheck
HEALTHCHECK CMD curl -ILfSs http://localhost:80 -A "HealthCheck: J. Scott Elblein/1.0" || exit 1

# Forward Apache access and error logs to Docker's log collector
RUN ln -sf /dev/stdout /var/log/apache2/access.log \
    && ln -sf /dev/stderr /var/log/apache2/error.log

and then in apache's 00-default config, I add near the bottom:

    <IfModule setenvif_module>
        # If UA matched healthcheck, set 'nolog' env var, which we exclude from the log(s) in the logformat section below.
        BrowserMatchNoCase ^healthcheck nolog
    </IfModule>

    ErrorLog ${APACHE_LOG_DIR}/error.log

    # Possible values: debug, info, notice, warn, error, crit, alert, emerg.
    LogLevel warn

    CustomLog ${APACHE_LOG_DIR}/access.log combined env=!nolog

The -A sets the UserAgent (can be whatever ya want; I used 'healthcheck') and then the browsermatchnocase searches for "healthcheck", and if found, just doesn't add it to the log.

I create that 00-default locally and then copy it via the dockerfile:

COPY copy-files/configs/apache/000-default /etc/apache2/sites-available/default

Also, I see the 'harmless but annoying ;)' log message:

AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 10.0.5.5. Set the 'ServerName' directive globally to suppress this message

For that, I create a file named fqdn with this in it: ServerName localhost, and copy it via docker file:

# Shut the 'fully qualified yada yada yada' Apache warning notice up
COPY copy-files/configs/fqdn /etc/apache2/conf.d

I'm a bit OCD about making my logs as easy to find what I need fast, lol. Not sure whether that's important to you but thought I'd help out if you were interested.

STaRDoGG avatar Aug 24 '22 22:08 STaRDoGG

If you open a pull request for this, I'll include it

JulianPrieber avatar Sep 06 '22 13:09 JulianPrieber

Sorry about the delay, I haven't logged in for a minute.

I'll add it as soon as I get a chance.

STaRDoGG avatar Sep 30 '22 04:09 STaRDoGG

Turned out to be a bit more of a PITA than I thought it would be, but finally wrapped it all up.: https://github.com/JulianPrieber/llc-docker/pull/20

STaRDoGG avatar Oct 14 '22 05:10 STaRDoGG