openshift livenessProbe仅在状态NOT 200时进行日志记录



我有一个简单的livenessProbe http检查:

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

在我的日志中,有大量的/健康检查,状态200 OK,这使得日志非常大,因此非常昂贵。是否有一种方法只在状态为NOT200时进行日志记录

我试图寻找答案,但还并没有找到。

有人能帮我吗?感谢

#更新

我认为日志是通过nginx:生成的

nginx的配置:

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;
}
}

如果探测检查成功,OpenShift不会将成功的探测日志记录到事件日志中(您可以使用oc get events看到(。它只记录了失败的日志。我认为您提到的日志可能是httpd或nginx web服务器之类的访问日志。如果是pod日志作为运行web服务器或您的应用程序,您应该过滤"/健康;通过web服务器或您的应用程序配置。

例如,如果使用httpd web服务器,则可以按如下方式筛选访问日志。

SetEnvIf Request_URI "^/health$" health_check_log
CustomLog "logs/access_log" combined env=!health_check_log

最新更新