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

# Grafana Cloud

> Ship msb-metrics output to Grafana Cloud's OTLP gateway

Local-only (This page covers msb-metrics, which reads host-local shared memory and is local-only. It does not apply to microsandbox cloud sandboxes.)

> [!NOTE]
>
> This guide ships data emitted by [`msb-metrics`](https://docs.microsandbox.dev/observability/msb-metrics).
> See the msb-metrics page for the flag reference, metric names, and
> deployment constraints.

Grafana Cloud exposes a region-specific OTLP gateway at
`otlp-gateway-prod-<region>.grafana.net`. `msb-metrics` ships directly
to it using HTTP/Protobuf and Basic auth.

## Connect Grafana Cloud

**1. Get your OTLP endpoint and credentials**

In the Grafana Cloud admin console, open **My Account → Connections
→ OpenTelemetry**. Copy three values:

* **Endpoint URL** (looks like
  `https://otlp-gateway-prod-us-east-2.grafana.net/otlp`)
* **Instance ID** (a numeric instance identifier)
* **API token** with scope `metrics:write` (create one if you
  don't already have it)

**2. Build the Basic auth header**

Grafana Cloud's OTLP gateway uses HTTP Basic auth, where the
username is your instance ID and the password is the API token.

```sh macOS & Linux theme={null}
GC_ID=...      # numeric instance id
GC_TOKEN=...   # API token with metrics:write
AUTH="Basic $(printf '%s:%s' "$GC_ID" "$GC_TOKEN" | base64 | tr -d '\n')"
```

```powershell Windows theme={null}
$env:GC_ID = '...'      # numeric instance id
$env:GC_TOKEN = '...'   # API token with metrics:write
$credentials = "$env:GC_ID`:$env:GC_TOKEN"
$auth = 'Basic ' + [Convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes($credentials))
```

**3. Run msb-metrics**

```sh macOS & Linux theme={null}
msb-metrics otel \
  --endpoint=https://otlp-gateway-prod-us-east-2.grafana.net/otlp/v1/metrics \
  --protocol=http \
  --header="Authorization=${AUTH}"
```

```powershell Windows theme={null}
msb-metrics otel `
  --endpoint=https://otlp-gateway-prod-us-east-2.grafana.net/otlp/v1/metrics `
  --protocol=http `
  --header="Authorization=$auth"
```

Substitute your region in the URL. If Grafana shows you the base
OTLP URL ending in `/otlp`, append `/v1/metrics` for this HTTP
metrics-only exporter.

**4. Verify**

Boot a sandbox (`msb run alpine`) and open Grafana → **Explore**.
Query `microsandbox_cpu_utilization` (PromQL view of the OTel
`microsandbox.cpu.utilization` gauge). You should see data within
the next flush interval (default 10s).

## Production: prefer Grafana Alloy

For long-running deployments, point `msb-metrics` at a local
[Grafana Alloy](https://docs.microsandbox.dev/how-to/metrics-backends/grafana-alloy.md)
instance instead of the OTLP gateway directly. Alloy handles
batching, retries, credential rotation, and buffering through Grafana
Cloud hiccups without touching `msb-metrics`.

## Reference

* [Grafana Cloud OTLP endpoint reference](https://grafana.com/docs/grafana-cloud/send-data/otlp/send-data-otlp/)
* [Grafana Cloud OTLP format considerations](https://grafana.com/docs/grafana-cloud/send-data/otlp/otlp-format-considerations/)


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