Skip to content

Route to Grafana Cloud Loki

Grafana Cloud Loki is one of the most common destinations for log telemetry. The loki exporter ships in both Grafana Alloy and otelcol-contrib — no additional install, no custom build.

What you’ll do

  1. Get your Grafana Cloud Loki endpoint URL, tenant ID, and an API key with the logs:write scope.
  2. Add a Grafana Cloud Loki destination in the LinkMesh UI with those credentials.
  3. Wire it into a route on the collector that produces your logs.
  4. Verify delivery in Grafana Explore.

1. Get the credentials

In Grafana Cloud → My AccountLoki, you’ll see:

  • A push URL like https://logs-prod-eu-west-0.grafana.net/loki/api/v1/push
  • Your tenant ID (the numeric user under “Username / Instance ID”)
  • An API key — create one with the MetricsPublisher role if you don’t already have one

2. Create the destination

Open Route → Destinations in the sidebar and click + New Destination.

The destination picker. Pick 'Grafana Cloud Loki' for the canned form — it knows about basic-auth, tenant IDs, and Loki labels out of the box.

Pick Grafana Cloud Loki. The form prompts for:

  • Endpoint URL — paste verbatim from Grafana Cloud
  • Tenant ID — the numeric user / instance ID
  • API key — pasted into the credential field (LinkMesh stores it encrypted in the destination config; collectors receive it via their runtime’s config channel — Alloy over remotecfg, otelcol-contrib over OpAMP — never as plaintext in a pushed config)
The Grafana Cloud Loki destination form. The 'Default labels' toggle controls which OTel resource attributes get promoted to Loki labels — start with job:true and leave exporter:false to avoid label cardinality blow-up.

3. Wire it into a route

Open the collector that handles your log source. Switch to the Routing tab and either create a new route or edit an existing one. Set:

  • Source: the log source you want to ship
  • Pipeline: whatever pipeline you want (or none — raw passthrough)
  • Destinations: add the new Grafana Cloud Loki destination

Save. The collector picks up the new routing within a few seconds.

4. Verify

Open Grafana Cloud → Explore → select the Loki datasource. Query:

{job="linkmesh"} |= ""

You should see log records flowing within ~30 seconds of the route save. If nothing arrives:

  • journalctl -u alloy -e (or -u otelcol-contrib -e) will print 4xx auth errors or 5xx endpoint errors
  • The LinkMesh UI’s per-component throughput on the collector’s Outputs tab shows the loki/grafana_cloud exporter with rec/s and any failures — that’s faster than tailing the collector log

How the generated config looks

For operators auditing what the UI pushed, the underlying OTel YAML on the collector is:

exporters:
loki/grafana_cloud:
endpoint: https://logs-prod-eu-west-0.grafana.net/loki/api/v1/push
auth:
authenticator: basicauth/grafana_cloud
default_labels_enabled:
exporter: false
job: true
extensions:
basicauth/grafana_cloud:
client_auth:
username: "<your-tenant-id>"
password: ${env:GRAFANA_LOKI_API_KEY}
service:
extensions: [basicauth/grafana_cloud]
pipelines:
logs:
receivers: [otlp, filelog]
processors: [batch]
exporters: [loki/grafana_cloud]

The API key lands in the collector runtime’s own environment — the supervisor’s environment for otelcol-contrib under OpAMP, or Alloy’s service environment for remotecfg — and the collector reads it through ${env:GRAFANA_LOKI_API_KEY} at startup.

  • Destination — the concept this recipe creates
  • Route — what binds the destination to actual traffic
  • Mask PII before this exporter — strongly recommended for any log pipeline that touches user data
  • LinkMesh pricing — LinkMesh is priced per Collector, so multi-tenant routing to Loki has no per-GB cost on the LinkMesh side (your Grafana Cloud usage is separate)