---
title: 'Log streaming: Grafana Cloud Logs'
summary: null
url: >-
  https://www.fastly.com/documentation/guides/integrations/logging-endpoints/log-management-and-observability/log-streaming-grafana-cloud-logs
---

Fastly's [Real-Time Log Streaming](https://www.fastly.com/documentation/guides/integrations/streaming-logs/about-fastlys-realtime-log-streaming-features) feature can send log files to [Grafana Cloud Logs](https://grafana.com/products/cloud/logs/), a scalable, multi-tenant log aggregation system by Grafana Labs.

> **NOTE:** 
>
> Fastly does not provide direct support for third-party services. Read [Fastly's Terms of Service](https://www.fastly.com/terms) for more information.
>
>

## Prerequisites

Before adding Grafana Cloud Logs as a logging endpoint for Fastly services, you will need to:

- Register for a [Grafana Cloud Account](https://grafana.com/products/cloud/).
- Create a Grafana Cloud Loki instance in your Grafana stack. Check out the [Grafana Cloud Logs](https://grafana.com/docs/grafana-cloud/send-data/logs/) documentation for more details.
- Create a [Grafana Access Policy](https://grafana.com/docs/grafana-cloud/account-management/authentication-and-permissions/access-policies/) with `logs:write` access scoped to your Loki instance.

### Grafana Streams

Grafana Cloud Logs to sends data to Grafana Cloud via a [stream](https://grafana.com/docs/loki/latest/get-started/overview/). Grafana uses [labels](https://grafana.com/docs/loki/latest/get-started/labels/bp-labels/), formatted as a JSON string (e.g., `{ "app": "my app", "env": "staging" }`), to define a particular log stream.

> **IMPORTANT:** Dynamic labels are not supported with this logging endpoint. Be sure to follow Grafana's current [best practices](https://grafana.com/docs/loki/latest/get-started/labels/bp-labels/) for using labels.

## Adding Grafana Cloud Logs as a logging endpoint

Follow these instructions to add Grafana Cloud Logs as a logging endpoint.

### Cdn Services

1.   Review the information in our guide to [setting up remote log streaming](/guides/integrations/streaming-logs/setting-up-remote-log-streaming).

2. In the Grafana Cloud Logs area, click **Create endpoint**.
3. Fill out the **Create a Grafana Cloud Logs endpoint** fields as follows:
   -   In the **Name** field, enter a human-readable name for the endpoint.

   -   In the **Placement** area, select where the logging call should be placed in the generated VCL. Valid values are **Format Version Default** and **None**. Read our guide on [changing log placement](/guides/integrations/streaming-logs/changing-log-placement) for more information.

   - In the **Log format** field, enter the data to send to Grafana Cloud. Check out the [example format section](https://www.fastly.com/documentation/guides/integrations/logging-endpoints/log-management-and-observability/log-streaming-grafana-cloud-logs#example-format) for details.
   - In the **User ID** area, enter your Grafana User ID.
   - In the **URL** area, enter the URL of your Grafana stack (e.g., `https://myhost.grafana.net`).
   - In the **Access Policy Token** area, enter the Grafana Access Policy token with `logs:write` scope  [you created](https://www.fastly.com/documentation/guides/integrations/logging-endpoints/log-management-and-observability/log-streaming-grafana-cloud-logs#prerequisites).
   - In the **Stream Labels** area, enter the [JSON string](https://www.fastly.com/documentation/guides/integrations/logging-endpoints/log-management-and-observability/log-streaming-grafana-cloud-logs#grafana-streams) used to identify this stream in Grafana (e.g., `{ "app": "my app", "env": "staging" }`).
   -   *(Optional)* From the **Processing region** menu, select a geographic region where logs are processed before being sent to the logging endpoint. Our guide on [regional log aggregation](/guides/integrations/streaming-logs/setting-up-regional-log-aggregation) provides more information.

4.   Click **Create** to create the new logging endpoint.

5.   From the **Activate** menu, select **Activate on Production** to deploy your configuration changes.

### Example format

Data sent to Grafana Cloud Logs can be sent as JSON or plain text. Here's an example of JSON message data sent to Grafana Cloud Logs:

```plain
{
  "timestamp": "%{strftime(\{"%Y-%m-%dT%H:%M:%S"\}, time.start)}V",
  "client_ip": "%{req.http.Fastly-Client-IP}V",
  "geo_country": "%{client.geo.country_name}V",
  "geo_city": "%{client.geo.city}V",
  "host": "%{if(req.http.Fastly-Orig-Host, req.http.Fastly-Orig-Host, req.http.Host)}V",
  "url": "%{json.escape(req.url)}V",
  "request_method": "%{json.escape(req.method)}V",
  "request_protocol": "%{json.escape(req.proto)}V",
  "request_referer": "%{json.escape(req.http.referer)}V",
  "request_user_agent": "%{json.escape(req.http.User-Agent)}V",
  "response_state": "%{json.escape(fastly_info.state)}V",
  "response_status": %{resp.status}V,
  "response_reason": %{if(resp.response, "%22"+json.escape(resp.response)+"%22", "null")}V,
  "response_body_size": %{resp.body_bytes_written}V,
  "fastly_server": "%{json.escape(server.identity)}V",
  "fastly_is_edge": %{if(fastly.ff.visits_this_service == 0, "true", "false")}V
}
```

### Compute Services

1.   Review the information in our guide to [setting up remote log streaming for Compute](/guides/integrations/streaming-logs/setting-up-remote-log-streaming-for-compute). Additionally, our developer documentation provides more [information about logging](/guides/integrations/non-fastly-services/developer-guide-logging/) with Compute code written in our [supported languages](/reference/compute/sdks/).

2. In the Grafana Cloud Logs area, click **Create endpoint**.
3. Fill out the **Create a Grafana Cloud Logs endpoint** fields as follows:
   -   In the **Name** field, enter the endpoint name you specified in your Compute code. For example, in our [Rust code example](/guides/compute/developer-guides/rust/#logging), the name is `my_endpoint_name`.

   - In the **User ID** area, enter your Grafana User ID.
   - In the **URL** area, enter the URL of your Grafana stack (e.g., `https://myhost.grafana.net`).
   - In the **Access Policy Token** area, enter the Grafana Access Policy token with `logs:write` scope  [you created](https://www.fastly.com/documentation/guides/integrations/logging-endpoints/log-management-and-observability/log-streaming-grafana-cloud-logs#prerequisites).
   - In the **Stream Labels** area, enter the [JSON string](https://www.fastly.com/documentation/guides/integrations/logging-endpoints/log-management-and-observability/log-streaming-grafana-cloud-logs#grafana-streams) used to identify this stream in Grafana (e.g., `{ "app": "my app", "env": "staging" }`).
4.   Click **Create** to create the new logging endpoint.

5.   From the **Activate** menu, select **Activate on Production** to deploy your configuration changes.

## Related content

- [API reference: Grafana Cloud Logs log streaming](https://www.fastly.com/documentation/reference/api/logging/grafanacloudlogs/)
- [CLI reference: Grafana Cloud Logs log streaming](https://www.fastly.com/documentation/reference/cli/logging/grafanacloudlogs/)
