# Kubernetes Logs

> Send logs from Kubernetes Cluster using OpenTelemetry

Source: https://last9.io/docs/integrations/containers-and-k8s/kubernetes-logs/

Send Kubernetes container logs to Last9 via OpenTelemetry Collector.

## Prerequisites

- A running Kubernetes cluster
- [helm](https://helm.sh/) installed
- Last9 OTLP credentials from the [Integrations](https://app.last9.io/integrations?integration=OpenTelemetry) page

## Installation

```bash
curl -O https://raw.githubusercontent.com/last9/last9-k8s-observability/main/last9-otel-setup.sh
chmod +x last9-otel-setup.sh

./last9-otel-setup.sh logs-only \
  endpoint="$last9_otlp_endpoint" \
  token="$last9_otlp_auth_header"
```

## Verification

```bash
kubectl get pods -n last9
```

Visit the [Logs Explorer](https://app.last9.io/logs) to see data flowing in.

## Setting additional log attributes

Customize log attributes in `last9-otel-collector-values.yaml`:

```yaml
transform/logs/last9:
  error_mode: ignore
  log_statements:
    - context: resource
      statements:
        - set(attributes["service.name"], attributes["k8s.container.name"]) where attributes["service.name"] == ""
        - set(attributes["deployment_environment"], "staging")
```

## Uninstall

```bash
./last9-otel-setup.sh uninstall
```

---

## Troubleshooting

Please get in touch with us on [Discord](https://discord.com/invite/Q3p2EEucx9) or [Email](mailto:support@last9.io) if you have any questions.
