> ## Documentation Index
> Fetch the complete documentation index at: https://docs.nebius.com/llms.txt
> Use this file to discover all available pages before exploring further.

# How to ingest Managed Service for Kubernetes® logs with the Nebius Observability Agent for Kubernetes

Nebius Observability Agent for Kubernetes collects workload logs (Pod logs) from your Managed Service for Kubernetes cluster and forwards them to Observability Logs.

To install the Nebius Observability Agent for Kubernetes in your Managed Service for Kubernetes cluster, follow the guide in [Nebius Observability Agent for Kubernetes](https://docs.nebius.com/observability/agents/nebius-o11y-agent.md).

By default, the agent automatically collects logs from all workloads in your cluster. After [installation](https://docs.nebius.com/observability/agents/nebius-o11y-agent.md#installation), logs will appear in the `default` bucket in Observability Logs.

> [!TIP]
>
> [Connect Grafana®](https://docs.nebius.com/observability/logs/grafana.md) to view ingested logs within it.

## Log collection configuration

You can customize log collection by creating a `values.yaml` file and updating your Nebius Observability Agent for Kubernetes installation:

```bash theme={null}
helm upgrade nebius-observability-agent oci://cr.nebius.cloud/observability/public/nebius-observability-agent-helm \
  --version $(curl https://artifacts.nebius.cloud/nebius-observability-agent/nebius-observability-agent-helm/latest-release) \
  --namespace observability \
  --values values.yaml
```

### Basic log configuration

```yaml theme={null}
config:
  logs:
    enabled: true
    collectAgentLogs: false
    excludedNamespaces:
      - kube-system
    operators:
      - type: json_parser
        ...
    processors:
      - name: transform/json_logs
        ...
```

### Configuration parameters

* `config.logs.enabled`: Enable or disable log collection. Default: `true`.
* `config.logs.collectAgentLogs`: Parameter to collect logs from the Nebius Observability Agent for Kubernetes itself. Default: `false`.
* `config.logs.excludedNamespaces`: List of namespaces to exclude from log collection.
* `config.logs.operators`: List of OpenTelemetry operators that parse Pod log lines. The agent runs them after it parses the container runtime log format. For more details, see [Parsing structured logs](#parsing-structured-logs).
* `config.logs.processors`: List of OpenTelemetry processors for the logs pipeline. The agent runs them after it adds Kubernetes metadata and before it sends the logs. For more details, see [Parsing structured logs](#parsing-structured-logs).

### Excluding namespaces

To avoid collecting logs from infrastructure or monitoring namespaces, exclude specific namespaces from the log collection:

```yaml theme={null}
config:
  logs:
    enabled: true
    collectAgentLogs: false
    excludedNamespaces:
      - kube-system
      - monitoring
      - cert-manager
      - istio-system
```

### Parsing structured logs

By default, the agent sends each Pod log line as a text message. If your application writes logs in JSON, Observability Logs shows the whole JSON object as one string and does not recognize the severity or other fields.

To set up the Nebius Observability Agent for Kubernetes to parse JSON logs, add OpenTelemetry log processing units of the following types to the agent configuration (`values.yaml`):

* [Operators](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/pkg/stanza/docs/operators/README.md) (`config.logs.operators` in `values.yaml`) parse logs after the agent parses the container runtime log format, but before it adds Kubernetes metadata to the logs. Operators use shorter configuration and recognize common severity level names in all letter cases out of the box.
* [Processors](https://github.com/open-telemetry/opentelemetry-collector/blob/main/processor/README.md) (`config.logs.processors` in `values.yaml`) parse logs after the agent adds Kubernetes metadata to them, and thus their conditions support attributes such as `resource.attributes["k8s.namespace.name"]`. Processors also let you filter or mask data.

For uppercase severity values, the examples below give the same result:

* The `message` field becomes the log message.
* The `severity` field sets the log severity.
* Other fields become log attributes. Nested objects stay structured.
* Lines that are not JSON objects stay unchanged.

For example, the agent turns the following line into a log with the `Model is ready.` message, the `INFO` severity, and the `logger` attribute:

```json theme={null}
{"message": "Model is ready.", "severity": "INFO", "logger": "app.model_serving"}
```

> [tab] Operators
>
> ```yaml theme={null}
> config:
>   logs:
>     operators:
>       - type: json_parser
>         if: 'body matches "^\\s*\\{"'
>         on_error: send_quiet
>         body: attributes.message
>         severity:
>           parse_from: attributes.severity
>           mapping:
>             fatal: critical
>       - type: remove
>         field: attributes.message
>         if: '"message" in attributes'
>       - type: remove
>         field: attributes.severity
>         if: '"severity" in attributes'
> ```
>
> The severity parser recognizes common level names, such as `DEBUG`, `INFO`, `WARNING`, and `ERROR`, in any letter case. The `mapping` section adds `CRITICAL` as a fatal level.
>
> With `on_error: send_quiet`, the agent still sends a line that has no `severity` field or is not valid JSON, and does not write an error to its log for each such line.

> [tab] Processors
>
> > [!NOTE]
> >
> > Unlike the operators, this example matches severity values in uppercase only.
>
> ```yaml theme={null}
> config:
>   logs:
>     processors:
>       - name: transform/json_logs
>         config:
>           error_mode: ignore
>           log_statements:
>             - conditions:
>                 - IsString(log.body) and IsMatch(log.body, "^\\s*\\{")
>               statements:
>                 - merge_maps(log.attributes, ParseJSON(log.body), "upsert")
>                 - set(log.body, log.attributes["message"]) where log.attributes["message"] != nil
>                 - set(log.severity_text, log.attributes["severity"]) where log.attributes["severity"] != nil
>                 - set(log.severity_number, SEVERITY_NUMBER_DEBUG) where log.severity_text == "DEBUG"
>                 - set(log.severity_number, SEVERITY_NUMBER_INFO) where log.severity_text == "INFO"
>                 - set(log.severity_number, SEVERITY_NUMBER_WARN) where log.severity_text == "WARNING"
>                 - set(log.severity_number, SEVERITY_NUMBER_ERROR) where log.severity_text == "ERROR"
>                 - set(log.severity_number, SEVERITY_NUMBER_FATAL) where log.severity_text == "CRITICAL"
>                 - delete_key(log.attributes, "message")
>                 - delete_key(log.attributes, "severity")
> ```
>
> All processors require `name` and `config`:
>
> * `name`: String that identifies the processor, consisting of processor type and its name separated by a forward slash (`/`). For example: `transform/json_logs`. The following processor types are supported:
>
>   * `batch` ([documentation](https://github.com/open-telemetry/opentelemetry-collector/blob/main/processor/batchprocessor/README.md))
>   * `filter` ([documentation](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/processor/filterprocessor/README.md))
>   * `groupbyattrs` ([documentation](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/processor/groupbyattrsprocessor/README.md))
>   * `transform` ([documentation](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/processor/transformprocessor/README.md))
>     * `attributes` ([documentation](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/processor/attributesprocessor/README.md)), superseded by `transform`
>   * `redaction` ([documentation](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/processor/redactionprocessor/README.md))
>   * `resourcedetection` ([documentation](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/processor/resourcedetectionprocessor/README.md))
>   * `unroll` ([documentation](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/processor/unrollprocessor/README.md))
>
>   `name` must be unique across processors in `values.yaml`. `transform/set_attributes` is a reserved name. If a processor has an unsupported type, uses a reserved name, or two processors have the same name, the agent returns an error and doesn't start.
>
> * `config`: Processor configuration. For more details, see the documentation for the respective processor type.

If your logs use other field names or severity values, change them in the example.

The examples parse logs from all Pods. To parse logs only from one namespace, add a namespace check to the condition:

* In operators: `if: 'resource["k8s.namespace.name"] == "<namespace>" and body matches "^\\s*\\{"'`.
* In processors: `resource.attributes["k8s.namespace.name"] == "<namespace>" and IsString(log.body) and IsMatch(log.body, "^\\s*\\{")`.

## Data enrichment

The Nebius Observability Agent for Kubernetes enriches logs with the following metadata:

* `k8s_cluster_id`: Cluster ID
* `k8s_node_group_id`: Node group ID
* `app.kubernetes.io/name`: Application name label
* `k8s.namespace.name`: Namespace name
* `k8s.deployment.name`: Deployment name (if applicable)
* `k8s.statefulset.name`: StatefulSet name (if applicable)
* `k8s.daemonset.name`: DaemonSet name (if applicable)
* `k8s.cronjob.name`: CronJob name (if applicable)
* `k8s.job.name`: Job name (if applicable)
* `k8s.node.name`: Node name
* `k8s.pod.name`: Pod name
* `k8s.pod.start_time`: Pod start time
* `container.image.tag`: Container image tag
* `k8s.container.restart_count`: Number of the container restarts in the Pod
* `k8s_pod_uid`: Pod unique identifier

## Troubleshooting

If you encounter issues with log or metric collection, do the following:

1. Verify the agent is running:

   ```bash theme={null}
   kubectl get pods --namespace observability
   ```

2. Check agent logs for errors:

   ```bash theme={null}
   kubectl logs <Pod_name> --namespace observability
   ```

***

*The Grafana Labs Marks are trademarks of Grafana Labs, and are used with Grafana Labs' permission. We are not affiliated with, endorsed or sponsored by Grafana Labs or its affiliates.*
