Logs help you troubleshoot issues with your clusters and apps. Sometimes, you might want to send logs somewhere for processing or long-term storage. On a Kubernetes cluster in the IBM Cloud Container Service, you can enable log forwarding for your cluster and choose where your logs are forwarded.
Using the Container Service CLI, you can forward your container logs to a syslog server with one command:
The above command creates a logging configuration to send all container standard output and error logs from the default Kubernetes namespace. These logs are sent using the syslog protocol to mysyslog.example.com
.
In this tutorial, you will forward your logs to an rsyslog instance running in the same cluster.
Create a Kubernetes cluster on the IBM Cloud Container Service and wait for it to become ready. Next, connect
commands to your cluster with the following command:
Next, create an rsyslog service we can forward logs to.
Start by creating
with the following contents:
Then run the following:
Then configure your logs to go to the rsyslog service.
Finally, deploy a container to your cluster that generates logs. I like using anoisy
file with the following contents:
Finally, create the
pod.
Now take a look inside the rsyslog instance to see the logs.
If you see someHello world
!
lines, then you have successfully forwarded logs to your rsyslog service.
To learn more, continue reading about log forwarding or IBM’s Kubernetes offering.