Help Kubernetes Pod Logs

Kubernetes Pod Logs

Collect, track, and monitor the logs of your applications running on Kubernetes pods using Site24x7 AppLogs. Site24x7's server agent supports collecting logs from Kubernetes log files.

Steps to add Kubernetes pod logs:

  1. Log in to your Site24x7 account.
  2. If you do not have a Kubernetes monitor, add one by following the steps here (or go to Server > Kubernetes > Clusters (+) > Add Kubernetes Monitor).
  3. After adding the Kubernetes monitor, our Site24x7 pod will run on each of your Kubernetes cluster nodes and will be ready to collect the logs.
  4. Then, you can create a log profile by navigating to Admin > AppLogs > Log Profile > Add Log Profile.
  5. Select Kubernetes Pod Logs from the log type list.
  6. Kubernetes pod logs are sourced from the /var/log/pods/ folder path. Adding the Kubernetes monitor will automatically mount the /var folder as /host/var into our Site24x7 pod. The site24x7-agent.yaml file already contains the path mentioned under the parent directory so that our pod can read the logs from the mentioned folder.
    If you want to collect all the pod's logs, use the file path below in the log profile:
    If you want to collect logs from a specific pod, you can do so by specifying the particular pod name path as follows:
    /host/var/log/pods/*<particular Pod name>*/*/*.log
    To exclude the Site24x7 pod logs, click the + icon, select the Exclude option, and add the file path below:
  7. Once you add the Kubernetes monitor, you can associate that Kubernetes node using the Associate this log profile with these servers option.

Sample log

{"log":"Starting image","stream":"stdout","time":"2019-06-04T11:29:54.295671087Z", "namespace" : "kube-system", "podname" : "kube-proxy-4jrl9_323e26da", "podid": "323e26da-67d4-4ae8-ad19-a30abcb9e101", "containername" : "kube-proxy"}

Log pattern

This is the default log pattern defined by Site24x7 for parsing Kubernetes pod logs based on the sample log mentioned above.

json $log$ $stream$ $time:date:yyyy-MM-dd'T'HH:mm:ss.SSS'Z'$ $namespace as NameSpace$ $podname as PodName$ $podid as PodId$ $containername as ContainerName$

This log is separated into fields, each of which will take its respective value and then be uploaded to Site24x7.

Field name Field value
log Starting image
stream stdout
time 2019-06-04T11:29:54.295671087Z
NameSpace kube-system
PodName kube-proxy-4jrl9_323e26da
PodId 323e26da-67d4-4ae8-ad19-a30abcb9e101
ContainerName kube-proxy

Here, the log key will capture the actual log messages. The rest of the field names, such as NameSpace, PodName, PodID, and ContainerName, are additional meta information.

Related log types

Supported log types
Docker container logs

Was this document helpful?
Thanks for taking the time to share your feedback. We’ll use your feedback to improve our online help resources.

Help Kubernetes Pod Logs