> For the complete documentation index, see [llms.txt](https://docs.pagerly.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.pagerly.io/sre-ai-agent/data-sources/loki.md).

# Loki

## What the Agent Can Do

* Query logs using LogQL syntax
* Search by labels, time range, and patterns
* Discover available log labels and streams

## Setup Instructions

1. Get your **Loki endpoint URL**:
   * **Grafana Cloud:** Go to My Account > Grafana Cloud > Loki Details > copy URL and generate API key
   * **Self-hosted:** Your Loki instance URL (default port 3100)
2. If authentication is required, get a bearer token or basic auth credentials
3. Paste your Loki URL and credentials in the Pagerly dashboard

## Required Credentials

| Field                         | Description                | Example                                     |
| ----------------------------- | -------------------------- | ------------------------------------------- |
| **Loki URL**                  | Your Loki endpoint URL     | `https://logs-prod-us-central1.grafana.net` |
| **Bearer Token** *(optional)* | Required for Grafana Cloud | —                                           |

## Context Prompt Tips

> *"Our logs use app=myservice label. Production logs have env=prod. Error logs are level=error."*

## Docs

* [Loki HTTP API](https://grafana.com/docs/loki/latest/reference/loki-http-api/)
