how to collect knative service logs?

724 Views Asked by At

I want to deploy my service through knative, but I don't know how to collect the service log and save them in the es. The service logs are located under /var/log directory, so I mount the directory to the emptyDir volumn and collect log via sidecar. When I submit the yaml file, I find that knatve doesn't support this approach.

enter image description here

I know how to collect the container console log,I just don't know how to collect specific directory log when the service is deployed through knative. So does anyone know the solution ?

Thanks for your help and time

1

There are 1 best solutions below

0
On

as error says, yaml has 2 containers(multi container) which is not supported by knative default. thats why your yaml not accepted by knative webhook. now v0.17 supports multi container. you should try this first. https://github.com/knative/serving/blob/master/config/core/configmaps/features.yaml#L44 https://knative.dev/docs/serving/feature-flags/#control

In my case, I did collect log to ES using just stdout and it works pretty easy, so i didnt try your apporach. however, it seems that you dont need to mount additional volume considering this config file. https://github.com/knative/serving/blob/master/config/monitoring/logging/elasticsearch/100-fluentd-configmap.yaml#L46

I have no better idea anymore. hope you find best way.