> For the complete documentation index, see [llms.txt](https://docs.openg2p.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.openg2p.org/operations/deployment/deployment-guide/view-system-logs-in-grafana-loki.md).

# View System Logs in Grafana (Loki)

Cluster logs are collected and queried through the **OpenTelemetry + Grafana Loki** stack — there is no OpenSearch in the current deployment. An OpenTelemetry agent (a DaemonSet) tails every pod's logs, ships them through an OTel gateway to **Grafana Loki** (backed by its own dedicated MinIO object store), and you query them in **Grafana** using LogQL. PII is redacted in the OTel pipeline before logs are stored.

{% hint style="info" %}
This replaces the old OpenSearch Dashboards flow. OpenSearch and the Fluentd-based pipeline have been removed; logging is handled cluster-wide by OpenTelemetry + Loki at the infrastructure layer.
{% endhint %}

## Open Grafana

Grafana ships with the cluster's monitoring stack and is reached **through the Rancher UI** — it does not have its own public hostname:

* In Rancher, open the **`local` cluster → Monitoring → Grafana** (Cluster Explorer → Monitoring → Grafana dashboards), or
* port-forward it from your workstation (Wireguard up, kubeconfig set):

  ```bash
  kubectl -n cattle-monitoring-system port-forward svc/rancher-monitoring-grafana 3000:80
  # then open http://localhost:3000
  ```

## View and filter logs

1. **Open Explore** — in Grafana's left menu, click **Explore**, then select the **Loki** data source (top-left dropdown).
2. **Pick the logs you want** with a LogQL label selector. Labels include `k8s_namespace_name`, `k8s_pod_name`, `k8s_container_name`, and `service_name`:
   * `{k8s_namespace_name="prod"}` — all logs in the `prod` environment namespace.
   * `{k8s_namespace_name="prod", k8s_pod_name=~"commons-services-esignet.*"}` — a specific service.
   * `{k8s_namespace_name="cattle-system"}` — Rancher's own logs.
3. **Filter by content / severity** with pipeline filters:
   * `{k8s_namespace_name="prod"} |= "ERROR"` — lines containing `ERROR`.
   * `{k8s_namespace_name="prod"} |~ "(?i)exception|panic|oom"` — case-insensitive regex match.
   * `{k8s_namespace_name="prod"} |= "ERROR" != "healthcheck"` — include `ERROR`, exclude `healthcheck`.
4. **Set the time range** — use the time picker (top-right): Last 15 minutes, Last 1 hour, Today, or a custom range.
5. **Save / share** — pin a useful query to a dashboard panel, or use **Share** to copy a link that reproduces the query + time range.
6. **Inspect a line** — expand any log line to see its labels and the full message; click a label value to add it to the query.

## Log-based alerts

Loki's ruler evaluates **LogQL alert rules** (high error rate, fatals/panics/OOM, auth-failure bursts, and a dead-man's-switch if the pipeline goes silent) and forwards firing alerts to the same **Alertmanager** that ships with Rancher monitoring. Tune the thresholds per environment; see the alerting configuration in the production automation.

{% hint style="info" %}
The production automation installs this whole pipeline (OTel agent → gateway → Loki + dedicated MinIO → Grafana datasource) as part of the infrastructure stage — no manual setup is needed.
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.openg2p.org/operations/deployment/deployment-guide/view-system-logs-in-grafana-loki.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
