---
title: 'Log streaming: Fastly Object Storage'
summary: null
url: >-
  https://www.fastly.com/documentation/guides/integrations/logging-endpoints/object-and-cloud-storage/log-streaming-fastly-object-storage
---

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 a bucket in [Fastly Object Storage](https://www.fastly.com/documentation/guides/platform/object-storage/about-object-storage). When you add a Fastly Object Storage logging endpoint, you select a region and a bucket. The Fastly platform creates an access key limited to that bucket and stores it with the endpoint, so you don't create or enter access keys or a storage domain.

You can also create these endpoints with the [Fastly Object Storage logging API](https://www.fastly.com/documentation/reference/api/logging/fos/).

## Prerequisites

Before you add a Fastly Object Storage logging endpoint, check the following:

- Fastly Object Storage must be enabled on your account. Fastly Object Storage is a separate product and is priced in addition to other Fastly services. 

  On most accounts, anyone assigned the role of superuser can purchase this product from the Fastly control panel. If you have not been assigned that role, you can use the control panel to request that a superuser purchase it for you.

- You must have the Engineer or Superuser role to add or edit this endpoint in order to manage Object Storage access keys.

## Adding Fastly Object Storage as a logging endpoint

Follow these instructions to add Fastly Object Storage as a logging endpoint:

### Cdn Services

1.   Review the information in our guide to [setting up remote log streaming](https://www.fastly.com/documentation/guides/integrations/streaming-logs/setting-up-remote-log-streaming).

2. From the **Add endpoint** menu, select **Fastly Object Storage**.

3. Fill out the **Add Fastly Object Storage 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](https://www.fastly.com/documentation/guides/integrations/streaming-logs/changing-log-placement) for more information.

   -   In the **Log format** field, optionally enter an Apache-style string or VCL variables to use for log formatting. Consult the [example format section](https://www.fastly.com/documentation/guides/integrations/logging-endpoints/object-and-cloud-storage/log-streaming-fastly-object-storage#example-format) for details.

   - From the **Region** menu, select the Object Storage region where your bucket is stored. This value defaults to `us-east-1`.
   - From the **Bucket name** menu, select the bucket to store logs in. The menu lists your buckets in the selected region. To create a bucket in that region instead, click **Create bucket** and then fill out the **Create bucket** fields. Note the [bucket naming rules](https://www.fastly.com/documentation/guides/platform/object-storage/working-with-object-storage#creating-a-bucket).
     > **HINT:** You can send logs to buckets in legacy regions like `us-east`, `us-west`, and `eu-central`, but you can't create new buckets from these regions.
   -   *(Optional)* In the **Timestamp format** field, enter a timestamp format for log files. The default is an `strftime` compatible string. Our guide on [changing where log files are written](https://www.fastly.com/documentation/guides/integrations/streaming-logs/changing-where-log-files-are-written) provides more information.

   -   In the **Period** field, enter an interval (in seconds) to control how frequently your log files are rotated. Rotation entails the finalization of one file object and the start of a new one, never removing any previously created file object. This value defaults to `3600` seconds.

   -   *(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](https://www.fastly.com/documentation/guides/integrations/streaming-logs/setting-up-regional-log-aggregation) provides more information.

4. Click **Advanced options** and fill out the following fields:

   -   *(Optional)* In the **Path** field, enter the path within the bucket to store the files. The path ends with a trailing slash. If this field is left empty, the files will be saved in the bucket's root path. Our guide on [changing where log files are written](https://www.fastly.com/documentation/guides/integrations/streaming-logs/changing-where-log-files-are-written) provides more information.

   -   *(Optional)* In the **PGP public key** field, enter a PGP public key that Fastly will use to encrypt your log files before writing them to disk. You will only be able to read the contents by decrypting them with your private key. The PGP key should be in [PEM (Privacy-Enhanced Mail) format](https://en.wikipedia.org/wiki/Privacy-enhanced_Electronic_Mail). Read our guide on [log encryption](https://www.fastly.com/documentation/guides/integrations/streaming-logs/encrypting-logs) for more information.

   -   In the **Select a log line format** area, select the log line format for your log messages. Our guide on [changing log line formats](https://www.fastly.com/documentation/guides/integrations/streaming-logs/changing-log-line-formats) provides more information.

   -   *(Optional)* In the **Compression** field, select the compression format you want applied to the log files. Our guide on [changing log compression options](https://www.fastly.com/documentation/guides/integrations/streaming-logs/changing-log-compression-options) provides more information.

   - _(Optional)_ In the **Maximum bytes** field, enter the maximum file size in bytes. This value caps the file size and overrides any configured period if the size threshold is exceeded prior to the end of the period. If set to 0, no maximum is set and the file size will not be capped.

     > **HINT:** The minimum file size is 1048576 bytes (1 MiB).

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

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

After you create your logging endpoint, the endpoint appears on the **Logging** page with its bucket name and a link to your buckets in that region. Fastly also creates an [Object Storage access key](https://www.fastly.com/documentation/guides/integrations/logging-endpoints/object-and-cloud-storage/log-streaming-fastly-object-storage#about-the-endpoints-access-key) with read and write access to the endpoint's bucket only and stores the key with the endpoint.

Once the service version is active, the Fastly platform writes log files to the bucket.

> **NOTE:** The Fastly platform streams logs continuously, but a log file isn't available in the bucket until its upload is complete.

### Example format

The following is an example format string for sending data to Fastly Object Storage. Our discussion of [format strings](https://www.fastly.com/documentation/guides/integrations/streaming-logs/custom-log-formats) provides more information.

```plaintext
{
  "timestamp": "%{strftime(\{"%Y-%m-%dT%H:%M:%S%z"\}, 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](https://www.fastly.com/documentation/guides/integrations/streaming-logs/setting-up-remote-log-streaming-for-compute). Additionally, our developer documentation provides more [information about logging](https://www.fastly.com/documentation/guides/integrations/non-fastly-services/developer-guide-logging/) with Compute code written in our [supported languages](https://www.fastly.com/documentation/reference/compute/sdks/).

2. From the **Add endpoint** menu, select **Fastly Object Storage**.

3. Fill out the **Add Fastly Object Storage 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](https://www.fastly.com/documentation/guides/compute/developer-guides/rust/#logging), the name is `my_endpoint_name`.

   - From the **Region** menu, select the Object Storage region where your bucket is stored. This value defaults to `us-east-1`.
   - From the **Bucket name** menu, select the bucket to store logs in. The menu lists your buckets in the selected region. To create a bucket in that region instead, click **Create bucket** and then fill out the **Create bucket** fields. Note the [bucket naming rules](https://www.fastly.com/documentation/guides/platform/object-storage/working-with-object-storage#creating-a-bucket).
     > **HINT:** You can send logs to buckets in legacy regions like `us-east`, `us-west`, and `eu-central`, but you can't create new buckets from these regions.
   -   *(Optional)* In the **Timestamp format** field, enter a timestamp format for log files. The default is an `strftime` compatible string. Our guide on [changing where log files are written](https://www.fastly.com/documentation/guides/integrations/streaming-logs/changing-where-log-files-are-written) provides more information.

   -   In the **Period** field, enter an interval (in seconds) to control how frequently your log files are rotated. Rotation entails the finalization of one file object and the start of a new one, never removing any previously created file object. This value defaults to `3600` seconds.

   -   *(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](https://www.fastly.com/documentation/guides/integrations/streaming-logs/setting-up-regional-log-aggregation) provides more information.

4. Click **Advanced options** and fill out the following fields:

   -   *(Optional)* In the **Path** field, enter the path within the bucket to store the files. The path ends with a trailing slash. If this field is left empty, the files will be saved in the bucket's root path. Our guide on [changing where log files are written](https://www.fastly.com/documentation/guides/integrations/streaming-logs/changing-where-log-files-are-written) provides more information.

   -   *(Optional)* In the **PGP public key** field, enter a PGP public key that Fastly will use to encrypt your log files before writing them to disk. You will only be able to read the contents by decrypting them with your private key. The PGP key should be in [PEM (Privacy-Enhanced Mail) format](https://en.wikipedia.org/wiki/Privacy-enhanced_Electronic_Mail). Read our guide on [log encryption](https://www.fastly.com/documentation/guides/integrations/streaming-logs/encrypting-logs) for more information.

   -   In the **Select a log line format** area, select the log line format for your log messages. Our guide on [changing log line formats](https://www.fastly.com/documentation/guides/integrations/streaming-logs/changing-log-line-formats) provides more information.

   -   *(Optional)* In the **Compression** field, select the compression format you want applied to the log files. Our guide on [changing log compression options](https://www.fastly.com/documentation/guides/integrations/streaming-logs/changing-log-compression-options) provides more information.

   - _(Optional)_ In the **Maximum bytes** field, enter the maximum file size in bytes. This value caps the file size and overrides any configured period if the size threshold is exceeded prior to the end of the period. If set to 0, no maximum is set and the file size will not be capped.

     > **HINT:** The minimum file size is 1048576 bytes (1 MiB).

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

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

After you create your logging endpoint, the endpoint appears on the **Logging** page with its bucket name and a link to your buckets in that region. Fastly also creates an [Object Storage access key](https://www.fastly.com/documentation/guides/integrations/logging-endpoints/object-and-cloud-storage/log-streaming-fastly-object-storage#about-the-endpoints-access-key) with read and write access to the endpoint's bucket only and stores the key with the endpoint.

Once the service version is active, the Fastly platform writes log files to the bucket.

> **NOTE:** The Fastly platform streams logs continuously, but a log file isn't available in the bucket until its upload is complete.

## About the endpoint's access key

When you create a Fastly Object Storage endpoint, the Fastly platform creates an Object Storage access key with read and write access to the endpoint's bucket only and stores the key with the endpoint. The secret key isn't shown in the control panel or returned by the API.

The access key is listed with your other keys on the **Resources** > [**Object Storage**](https://manage.fastly.com/resources/object-storage) page. Its description names the user who created it, the endpoint, the service type, the service and its ID, the service version it was created on, and the bucket. For example:

`Automatically created for user@example.com by logger my-logs on delivery service Example Service (SU1Z0isxPaozGVKXdv0eY) version 3 with access to my-log-bucket.`

If you change the endpoint's bucket in a new service version, the Fastly platform creates a new access key for the new bucket. The previous key isn't deleted, because older service versions still use it. It keeps read and write access to the old bucket. After you activate the new version, if no other service version uses, or will use, the old bucket, [delete the previous key](https://www.fastly.com/documentation/guides/platform/object-storage/working-with-object-storage#managing-object-storage-keys).

> **WARNING:** If you delete the endpoint's access key, the Fastly platform can't write log files to the bucket. The failures appear as [logging configuration errors](https://www.fastly.com/documentation/guides/integrations/streaming-logs/troubleshooting-logging-endpoints#viewing-errors) on the **Service summary** page. To restore delivery, clone the active version, edit the endpoint, click **Update** without changing anything, and then activate the new version. Saving the endpoint creates a new access key.

## Keeping log files for a set time

Log files stay in the bucket until they're deleted. To delete them automatically after a set number of days, add a [lifecycle rule](https://www.fastly.com/documentation/guides/platform/object-storage/bucket-lifecycle-management) to the bucket. If the bucket also holds objects that aren't logs, limit the rule with a prefix filter that matches the endpoint's path.

## Sending logs to an existing bucket in a legacy region

The **Region** menu also lists the legacy regions `us-east`, `us-west`, and `eu-central`, so you can send logs to buckets that already exist there. You can't create a bucket in these regions from the logging endpoint form. To store logs in a new bucket, select `us-east-1`, `us-west-1`, or `eu-central-1` instead.

Buckets in legacy regions don't support [lifecycle rules](https://www.fastly.com/documentation/guides/platform/object-storage/bucket-lifecycle-management), so log files sent there stay until you delete them.

## Deleting the endpoint

Deleting a Fastly Object Storage endpoint doesn't delete its bucket, the log files in that bucket, or its access key, because other service versions can still use them. If no other service version uses, or will use, the endpoint, you can [delete the access key](https://www.fastly.com/documentation/guides/platform/object-storage/working-with-object-storage#managing-object-storage-keys) and the bucket.

## Using an Amazon S3 endpoint with Object Storage

Amazon S3 endpoints that already send logs to Object Storage keep working. You don't need to change them.

If you want to manage the access key yourself, add an [Amazon S3 endpoint](https://www.fastly.com/documentation/guides/integrations/logging-endpoints/object-and-cloud-storage/log-streaming-amazon-s3) instead and use the following values:

- In the **Bucket name** field, enter the name of your Object Storage bucket.
- In the **Access method** area, select **User Credentials**, then enter the access key and secret key of an [Object Storage access key](https://www.fastly.com/documentation/guides/platform/object-storage/working-with-object-storage#creating-an-access-key) with read and write scope.
- In the **Domain** field, enter the [regional Object Storage endpoint](https://www.fastly.com/documentation/guides/platform/object-storage/working-with-object-storage#using-the-s3-compatible-api) for your bucket's region (for example, `us-east-1.object.fastlystorage.app`).

## Related content

- [API reference: Fastly Object Storage log streaming](https://www.fastly.com/documentation/reference/api/logging/fos/)
- [Working with Object Storage](https://www.fastly.com/documentation/guides/platform/object-storage/working-with-object-storage)
- [Bucket lifecycle management for Object Storage](https://www.fastly.com/documentation/guides/platform/object-storage/bucket-lifecycle-management)
- [Troubleshooting logging endpoints](https://www.fastly.com/documentation/guides/integrations/streaming-logs/troubleshooting-logging-endpoints)
