> For the complete documentation index, see [llms.txt](https://codemash.gitbook.io/codemash/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://codemash.gitbook.io/codemash/cloud/logs/integrations/providers/grafana-loki.md).

# Grafana Loki

Connect Grafana Loki to Logs — coming soon; the card is in Cloud, but Norbix refuses to save it yet.

Grafana Loki stores logs by labels and lets you query them in Grafana next to your metrics; you run it yourself or use Grafana Cloud.

{% hint style="warning" %}
Cloud has no working Grafana Loki integration yet. The **Grafana Loki** card is in the picker and its form opens, but the form has only **Integration Name**, and **Save** is refused: *The 'GrafanaLoki' logging provider isn't available yet. Support for it is coming soon — for now you can use Norbix Logging or Datadog for project logging.* The same answer comes from the SDK, the CLI and the API. To keep your logs today, use [Norbix Logging](/codemash/cloud/logs/integrations/providers/norbix-logging.md).
{% endhint %}

## Get your credentials

What Grafana Loki will ask for, from its own documentation:

1. Self-hosted Loki: note the push address of your Loki (`https://loki.example.com/loki/api/v1/push`). See the [Loki HTTP API](https://grafana.com/docs/loki/latest/reference/loki-http-api/).
2. Grafana Cloud: open your stack → **Loki → Details** and copy the URL, the **user** (a number) and create an **access policy token** with `logs:write`. See [Send logs to Grafana Cloud](https://grafana.com/docs/grafana-cloud/send-data/logs/).

## Connect it in Cloud

**Where:** Logs → Integrations → **Add New Integration** → Grafana Loki · `/projects/<project>/logging/integrations/new/grafana-loki`

| Field            | Required | What it does                                                                         | Example        |
| ---------------- | -------- | ------------------------------------------------------------------------------------ | -------------- |
| Integration Name | yes      | The name in your integrations list. The Grafana Loki fields are not in the form yet. | `Grafana Loki` |

<figure><img src="https://712692422-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHy372bqsaex2cqS3ikhL%2Fuploads%2Fgit-blob-8512c6476dc830a5a96eeb576a3054e2da6c0924%2Fgrafana-loki-form-1.png?alt=media" alt="New Grafana Loki Integration form with only the field Integration Name, filled with Grafana Loki"><figcaption><p>The form has only the name.</p></figcaption></figure>

<figure><img src="https://712692422-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHy372bqsaex2cqS3ikhL%2Fuploads%2Fgit-blob-11e6bb8201e9e5d453cc512def872f036298020a%2Fgrafana-loki-saved-2.png?alt=media" alt="After Save: the toast Bad request and the red text The &#x27;GrafanaLoki&#x27; logging provider isn&#x27;t available yet."><figcaption><p>Save is refused.</p></figcaption></figure>

## Test and set as default

There is nothing to test until Grafana Loki can be saved. When it can, **Test integration** works as described in [Test an integration](/codemash/cloud/logs/integrations/test.md); logging has no default integration ([Default integration](/codemash/cloud/logs/integrations/set-default.md)).

## Common errors

| Message                                                                                                                                                    | Cause                             | Fix                                                                                  |
| ---------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------- | ------------------------------------------------------------------------------------ |
| The 'GrafanaLoki' logging provider isn't available yet. Support for it is coming soon — for now you can use Norbix Logging or Datadog for project logging. | Every save of Grafana Loki today. | Use [Norbix Logging](/codemash/cloud/logs/integrations/providers/norbix-logging.md). |

## Do it from code

```ts
const { id } = await norbix.hub.logs.saveLoggingIntegration({
  projectId,
  integration: {
    provider: 'GrafanaLoki',
    integrationName: 'Grafana Loki',
    isEnabled: true,
  } as any, // the TS type knows only the shared fields
});
// throws: The 'GrafanaLoki' logging provider isn't available yet. …
```

```sh
norbix hub logs logging integration save --projectId "$NORBIX_PROJECT_ID" --integration '{"provider":"GrafanaLoki","integrationName":"Grafana Loki","isEnabled":true}'
```

The provider is written `GrafanaLoki` in requests. The client setup is on the [Logs page](/codemash/cloud/logs.md#use-it-from-code). API: [Save Logging Integration](/codemash/api-reference/logs/integrations/save-logging-integration.md)
