1

I have a simple livenessProbe http check:

livenessProbe:
    httpGet:
      path: /health
      port: 8080
    initialDelaySeconds: 20
    timeoutSeconds: 30
    failureThreshold: 3
    successThreshold: 3

In my logs there are tons of /health checks with status 200 OK and it makes logs really big and therefore expensive. Is there a way to log only when status is NOT 200?

I was trying to search for answer but no luck yet.

Can anybody help me with it? Thanks

#UPDATE

i think the logs are generating through nginx:

nginx's configuration:

server {
    listen 8080;

    root /www/data/;
    index index.html;
    access_log off;

    location /health {
        return 200 '{\"status\": \"ok\"}';
        default_type application/json;
    }

    location / {
        gzip on;
        try_files $uri /index.html;
    }
}
Martin Fric
  • 726
  • 2
  • 9
  • 27

1 Answers1

0

OpenShift does not record the successful probe logs to the event logs(you can see using oc get events) if probe check succeed. It's only recorded the failed logs. I think the log you mentioned may be access logs like httpd or nginx web server. If it's the pod logs as running web server or your application, you should filter the "/health" through the web server or your application configurations.

For example, if you use the httpd web server, you can filter the access logs as follows.

SetEnvIf Request_URI "^/health$" health_check_log

CustomLog "logs/access_log" combined env=!health_check_log
Daein Park
  • 4,393
  • 2
  • 12
  • 21
  • Yes actually those are logs on pods. and is it possible to filter out only logs that do not contain statusCode: 200? – Martin Fric Aug 27 '20 at 15:45
  • @MartinFric AFAIK, apache does not have a filter option based on status code, so you remain the healthcheck logs separately using ` CustomLog "logs/health_log" combined env=health_check_log"`, and you can remove the status code 200 logs regularly using cron and so on. – Daein Park Aug 28 '20 at 05:01
  • I found where does it come from. And it is i guess in nginx configuration. Line updated in #UPDATE part of question. Can you help me to configure nginx the way you explained for httpd webserver? – Martin Fric Aug 28 '20 at 06:57
  • I'm not familiar with nginx, but how about try this ? ~~~ location /health { return 200 '{\"status\": \"ok\"}'; default_type application/json; access_log off; }~~~ – Daein Park Aug 28 '20 at 09:22