> For the complete documentation index, see [llms.txt](https://docs.perfectscale.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.perfectscale.io/2.0-self-hosted-or-perfectscale-documentation/product-overview/logging-and-monitoring.md).

# Logging and monitoring

PerfectScale provides built-in monitoring and logging capabilities for your on-premises installation.&#x20;

To collect key system metrics and enable effective monitoring, the installation includes Prometheus, Grafana, and necessary exporters. For logging, Loki works alongside Promtail agents to efficiently collect and manage log data.

Remote logging and the ability to write to PerfectScale's centralized Prometheus and Loki instances remotely are enabled by default; however, this feature is optional. Port forwarding provides access to Prometheus and Grafana for viewing logs and metrics.

## How to access the logs  <a href="#how-to-access-to-the-logs" id="how-to-access-to-the-logs"></a>

1. Access Grafana via port forwarding

```
kubectl port-forward svc/monitoring-grafana 8888:80 -n ks-test
```

2. Navigate to [http://127.0.0.1:8888](http://127.0.0.1:8888/) in your browser.
3. Go to **Explore**, select **Loki** in **Outline**, and filter the logs by labels.

<figure><img src="/files/OvrpUoPf0jj8OY5QrtSz" alt=""><figcaption><p>How to access logs</p></figcaption></figure>

## Loki logs collection and debugging

Use the following instructions to collect logs from Loki and send them to PerfectScale for debugging.

1. Access Grafana via port forwarding

```
kubectl port-forward svc/monitoring-grafana 8888:80 -n ks-test
```

2. Navigate to [http://127.0.0.1:8888](http://127.0.0.1:8888/) in your browser.
3. Go to **Explore**, select **Loki** in **Outline**.&#x20;
4. Set the **Line Limit** to **5000** (1), switch to the **Code** mode(2), and execute the following query (3):

{% hint style="info" %}
Change the namespace to your namespace.
{% endhint %}

```
{namespace="ks-test", pod!~"logging-.*|monitoring-.*|keda-.*|psc-telemetry-.*|python-script-runner-.*|chi-.*|clickhouse-operator-.*|clickhouse-keeper-.*|postgres-postgresql-.*|rabbitmq-.*"} != `Trace` or `Debug` or `No messages left` or `Sleeping`
```

<figure><img src="/files/Fe9eGppeHPH7xUCCIbKh" alt=""><figcaption><p>Logs collection</p></figcaption></figure>

5. Click Download => CSV.
6. Sent the file to PerfectScale.

## How to access the dashboards <a href="#how-to-access-to-the-dashboards" id="how-to-access-to-the-dashboards"></a>

1. Access Grafana via port forwarding

```
kubectl port-forward svc/monitoring-grafana 8888:80 -n ks-test
```

2. Navigate to [http://127.0.0.1:8888](http://127.0.0.1:8888/) in your browser.
3. Navigate to Home and select Dashboards.
4. Import a new dashboard, or select the existing one.

<figure><img src="/files/qwPeQiWJPujENjk8gaKx" alt=""><figcaption><p>Dashboards</p></figcaption></figure>


---

# 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.perfectscale.io/2.0-self-hosted-or-perfectscale-documentation/product-overview/logging-and-monitoring.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
