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

# Loki

> Logs from a Loki instance.

Connect Loki so Struct Agent can query the logs relevant to its investigations. Verify the intended endpoint and a bounded operation after connecting.

## Inspect access and existing connections

Use a claimed workspace with permission to configure connections.

```bash theme={null}
struct whoami --json
struct connections catalog loki --json
struct connections list --json
```

Use the catalog's current fields, choices and permission requirements. Reuse an existing healthy connection instead of creating a duplicate.

## Connect with the CLI

Supply credentials from approved secret storage through `LOKI_TOKEN` or `LOKI_PASSWORD`. The catalog describes which are needed for the selected authentication method. Do not put literal secrets in shell arguments or chat.

Replace example values with the intended resource:

```bash theme={null}
struct connect loki --deployment grafana_cloud --url <loki-url> --instance-id <instance-id>
```

## Verify and recover

Use the returned connection ID:

```bash theme={null}
struct connections show CONNECTION_ID --json
struct connections test CONNECTION_ID --json
```

Inspect `ok`, `health` and missing permissions, not only the exit code. `struct connections grant-command CONNECTION_ID` prints repair instructions where supported; have an authorized operator apply them. For expired OAuth links, start the connection command again and use the new link. Do not reconnect to a different account silently.

Verify a bounded operation for the requested job. Connection health proves checked access; it does not prove telemetry arrival, an investigation or alert delivery.

## What Struct reads

Log streams by label, service, and time range, plus the surrounding lines around an error. A typical query:

```logql theme={null}
{service="api-gateway"} |= "error" | json | status >= 500
```

## Permissions

On Grafana Cloud, the access policy token needs the `logs:read` scope. Self-hosted Loki needs read access to the tenant.

### Logs

Read log streams for the configured tenant.

| Scope | Used for |
| - | - |
| `logs:read` | Grafana Cloud access policy scope for querying logs |

Permission catalog version `2026-11-04.1`. See [permission changes](https://docs.struct.ai/reference/permission-changes.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.