-
-
Notifications
You must be signed in to change notification settings - Fork 591
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
Remove "/health" from logging? #428
Comments
You can use grep
this suppresses all log entries that contain /health. |
That was quick! Thanks a lot! |
@jmattheis I'm using this fix too but I think it's not right. Since the healthcheck is enabled in the Docker image you should exclude these traces to avoid spam. Out-the-box install should include this fix. |
You're probably right. I'll be open to accept a PR for this. |
I would say you have to grep out exact line like |
Grepping a log file feels like a hacky way to solve this, especially when all Docker containers are affected by this in its default configuration Is there any worth at all in logging requests coming from localhost? If not, I think I have a solution using what limited development knowledge I have |
What is the purpose of the health check, is it just a self-check? What happens if the check fails? |
Then docker will mark the container as unhealthy. |
I'm sorry golang is not my normal day to day thing but I think something like this should work in place of: Line 27 in 8affece
skip_log_env, skip_log_env_present := os.LookupEnv("GOTIFY_DISABLE_LOG_PATHS")
if skip_log_env_present {
skip_log_paths := strings.Split(skip_log_env, ",")
}
else {
skip_log_paths := []
}
g.Use(gin.LoggerWithConfig(gin.LoggerConfig{SkipPaths: skip_log_paths, LogFormatter: logFormatter}, gin.Recovery(), error.Handler(), location.Default()) then you can pass in an env like so GOTIFY_DISABLE_LOG_PATHS=/health Reference: https://stackoverflow.com/a/71442218 |
@GAS85 so like this for compose?
|
Seems so, logs format is:
and your grep line should do the job. |
Hello, Is the above command still up to date? I don't understand what it does, but "server:2.0.22" is not the current version anymore. [bonelifer] posted a variant of it, so it this the right way to do it currently?
Running this command seems to produce errors
The health entries still appear and there's a new error message "WebSocket: ReadError read tcp 172.21.0.3:80->172.21.0.2:35506: i/o timeout" |
Then change it to the image you want to use (e.g. 2.2.4 or latest).
The solution @bonelifer posted is just a little more "precise" so to say, but both do work. I am using the line from @jmattheis since he posted it back in August 2021 in my docker-compose file and it still works.
In very simplified terms, the command suppresses the output of all lines that match the string "/health" to the log. |
Healthcheck spam is one of those little easy to fix things that always drives me nuts, too. I ended up fixing it for another container: LinkStackOrg/linkstack-docker#11 and you can see it here starting around this line: https://github.com/LinkStackOrg/linkstack-docker/blob/ef2fd131e623f2dd7fc75a31c9e0307918c3d0a0/docker-entrypoint.sh#LL51C15-L51C15 |
The log file I created with
entrypoint: /bin/bash -c '/app/gotify-app | tee /app/data/gotify.log'
in my docker-compose.yml is pretty quick filling up with entries like[GIN] 2021/08/21 - 19:02:50 | 200 | 440.732µs | 127.0.0.1 | GET "/health"
. Is there a way to prevent these kind of entries in the log file?The text was updated successfully, but these errors were encountered: