# Logging & Monitoring

## Monitor Cluster Components

Metrics server is a monitoring solution for Kubernetes, every Kubernetes cluster can have only one metrics server, it collects metrics from nodes and pods and places them In-memory (not on disk).

Kubelet has a sub-component called cAdvisor and its responsible for retrieving performance metrics from pods and expose them through kubelet API so they can be used by metrics server.

#### You can download metrics server by running:

{% code overflow="wrap" %}

```bash
kubectl apply -f https://github.com/kubernetes-sigs/metrics-server/releases/latest/download/components.yaml
```

{% endcode %}

#### After downloading metrics server, view CPU and Memory consumption of nodes and pods:

```bash
kubectl top node
kubectl top pod
```

### Lab:

No issues identified.

## Managing Application Logs

#### We can create a logging pod using a definition yaml:

<figure><img src="https://4247064012-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFLaJdzZGSq1DpczuSySw%2Fuploads%2FunytvWhu94UkCGfORt02%2Fimage.png?alt=media&#x26;token=b65ac6c0-6207-42d6-8918-7c4caf9ac88b" alt=""><figcaption></figcaption></figure>

#### As we create the pod, we can view logs:

```bash
kubectl logs -f event-simulator-pod image-processor # -f for realtime
```

### Lab:

No issues identified.

## Slides

{% file src="<https://4247064012-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFLaJdzZGSq1DpczuSySw%2Fuploads%2FNeeOMUCDu8sT6SWT1fOJ%2FKubernetes%2B-CKA-%2B0300%2B-%2BLogging-Monitoring.pdf?alt=media&token=e11976d5-457c-4516-86b6-130e446cbb38>" %}
