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

# Log Forwarding

> Forward Formal logs to your SIEM, data lake, or observability platform

## Overview

Formal can forward all activity logs to your SIEM, data lake, or observability platform. This enables centralized log management, long-term retention, compliance reporting, and integration with your existing security tools.

To see what Formal stores and for how long before you export, see [Data Handling and Retention](https://docs.formal.ai/docs/guides/observability/data-handling.md).

## Supported Platforms

* **AWS S3**
* **Google Cloud Storage (GCS)**
* **Google Cloud Pub/Sub**
* **Azure Blob Storage**
* **Datadog**
* **Splunk**
* **Panther**

> [!NOTE]
>
> By default, Formal forwards **all logs** to your configured destination,
> including [Insights](https://docs.formal.ai/docs/guides/observability/insights.md) findings.

## Setup

### AWS S3

> [!WARNING]
>
> The AWS S3 log integration requires an [AWS Cloud Integration](https://docs.formal.ai/docs/guides/integrations/clouds/aws.md) with S3 access enabled.

**1. Set Up AWS Integration**

First, configure an [AWS Cloud Integration](https://docs.formal.ai/docs/guides/integrations/clouds/aws.md) with:

* **AllowS3Access**: `true`
* **S3BucketARN**: Your S3 bucket ARN

**2. Navigate to SIEM**

Go to [SIEM](https://app.formal.ai/log-integrations)

**3. Create Integration**

Click **Create Integration**

**4. Select AWS S3**

Choose AWS S3 as your provider

**5. Configure**

* **S3 Bucket Name**: Your bucket name
* **Cloud Integration**: Select your AWS Cloud Integration
* **Compression**: the codec log objects are written with (see [Compression](#compression))

#### Terraform

```hcl theme={"languages":{"custom":["/languages/cel.json","/languages/rego.json"]}}
# First, create S3 bucket
resource "aws_s3_bucket" "formal_logs" {
  bucket = "formal-connector-logs"
}

# Create AWS Cloud Integration
resource "formal_integration_cloud" "aws" {
  name         = "aws-integration"
  cloud_region = "us-east-1"

  aws {
    template_version    = "1.2.0"
    allow_s3_access     = true
    s3_bucket_arn       = "${aws_s3_bucket.formal_logs.arn}/*"
  }
}

# Deploy CloudFormation stack (see AWS Integration guide)
resource "aws_cloudformation_stack" "formal" {
  # ... (see AWS Integration docs)
}

# Create log integration
resource "formal_integration_log" "s3" {
  name = "s3-log-drain"

  aws_s3 {
    s3_bucket_name       = aws_s3_bucket.formal_logs.bucket
    cloud_integration_id = formal_integration_cloud.aws.id
    compression          = "gzip"
  }
}
```

### Google Cloud Storage

> [!WARNING]
>
> The GCS log integration requires a [GCP Cloud Account](https://docs.formal.ai/docs/guides/integrations/clouds/gcp.md) with Cloud Storage access enabled.

**1. Set Up GCP Integration**

First, configure a [GCP Cloud Account](https://docs.formal.ai/docs/guides/integrations/clouds/gcp.md) with:

* **allow\_gcs\_access**: `true`
* **gcs\_buckets**: the buckets Formal may write to (empty allows every bucket in the project)

**2. Navigate to SIEM**

Go to [SIEM](https://app.formal.ai/log-integrations)

**3. Create Integration**

Click **Create Integration**

**4. Select Google Cloud Storage**

Choose Google Cloud Storage as your provider

**5. Configure**

* **GCS Bucket Name**: your bucket name
* **Cloud Account**: select your GCP Cloud Account
* **Compression**: the codec log objects are written with (see [Compression](#compression))

#### Terraform

```hcl theme={"languages":{"custom":["/languages/cel.json","/languages/rego.json"]}}
# Create GCP Cloud Account with Cloud Storage access (see GCP Integration guide)
resource "formal_integration_cloud" "gcp" {
  name = "gcp-integration"

  gcp {
    project_id                              = "my-gcp-project"
    enable_compute_instances_autodiscovery  = true
    enable_gke_clusters_autodiscovery       = true
    enable_cloudsql_instances_autodiscovery = true
    allow_gcs_access                        = true
  }
}

# Create log integration
resource "formal_integration_log" "gcs" {
  name = "gcs-log-drain"

  gcs {
    cloud_integration_id = formal_integration_cloud.gcp.id
    gcs_bucket_name      = "my-formal-logs"
    compression          = "gzip"
  }
}
```

> [!NOTE]
>
> Creating the GCP Cloud Account also requires the `terraform-formal-gcp` module and an activation resource. See the [GCP Integration guide](https://docs.formal.ai/docs/guides/integrations/clouds/gcp.md) for the full setup.

### Google Cloud Pub/Sub

Formal publishes each log as one JSON message to a Pub/Sub topic. Attach a [BigQuery subscription](https://cloud.google.com/pubsub/docs/bigquery) (writes messages straight to a table) to stream logs into BigQuery.

> [!WARNING]
>
> The Pub/Sub log integration requires a [GCP Cloud Account](https://docs.formal.ai/docs/guides/integrations/clouds/gcp.md) with Pub/Sub access enabled.

**1. Set Up GCP Integration**

Configure a [GCP Cloud Account](https://docs.formal.ai/docs/guides/integrations/clouds/gcp.md) with:

* **allow\_pubsub\_access**: `true`
* **pubsub\_topics**: full topic names Formal may publish to, such as `projects/my-project/topics/formal-logs`. Leave empty to allow every topic in the project. Listed topics may live in other projects.

**2. Navigate to SIEM**

Go to [SIEM](https://app.formal.ai/log-integrations)

**3. Create Integration**

Click **Create Integration**

**4. Select Google Cloud Pub/Sub**

Choose Google Cloud Pub/Sub as your provider

**5. Configure**

* **Cloud Account**: select your GCP Cloud Account
* **Topic**: the full topic name, `projects/<project>/topics/<topic>`

#### Terraform

```hcl theme={"languages":{"custom":["/languages/cel.json","/languages/rego.json"]}}
resource "formal_integration_cloud" "gcp" {
  name = "gcp-integration"

  gcp {
    project_id          = "my-gcp-project"
    allow_pubsub_access = true
    pubsub_topics       = ["projects/my-gcp-project/topics/formal-logs"]
  }
}

resource "formal_integration_log" "pubsub" {
  name = "pubsub-log-drain"

  gcp_pubsub {
    cloud_integration_id = formal_integration_cloud.gcp.id
    topic                = "projects/my-gcp-project/topics/formal-logs"
  }
}
```

### Azure Blob Storage

> [!WARNING]
>
> The Blob Storage log integration requires an [Azure Cloud Account](https://docs.formal.ai/docs/guides/integrations/clouds/azure.md) with Blob Storage access enabled.

**1. Set Up Azure Integration**

First, configure an [Azure Cloud Account](https://docs.formal.ai/docs/guides/integrations/clouds/azure.md) with:

* **allow\_blob\_access**: `true`
* **blob\_storage\_accounts**: the storage accounts Formal may write to (empty allows every account in scope)

**2. Navigate to SIEM**

Go to [SIEM](https://app.formal.ai/log-integrations)

**3. Create Integration**

Click **Create Integration**

**4. Select Azure Blob Storage**

Choose Azure Blob Storage as your provider

**5. Configure**

* **Storage Account**: the account to write to. Accounts named on the Cloud Account are offered as a list.
* **Container**: the container within that account
* **Cloud Account**: select your Azure Cloud Account
* **Compression**: the codec log objects are written with (see [Compression](#compression))

> [!NOTE]
>
> The Terraform provider does not yet support Blob Storage log integrations. Create them from the Control Plane or the API.

### Datadog

**1. Get Datadog Credentials**

From your Datadog account, retrieve:

* Application Key
* API Key
* Site (e.g., `datadoghq.com`, `datadoghq.eu`)

**2. Navigate to SIEM**

Go to [SIEM](https://app.formal.ai/log-integrations)

**3. Create Integration**

Click **Create Integration**

**4. Select Datadog**

Choose Datadog as your provider

**5. Enter Credentials**

* **Application Key**: Your Datadog Application Key
* **API Key**: Your Datadog API key
* **Site**: Your Datadog site

#### Terraform

```hcl theme={"languages":{"custom":["/languages/cel.json","/languages/rego.json"]}}
resource "formal_integration_log" "datadog" {
  name = "datadog-log-drain"

  datadog {
    account_id = var.datadog_application_key
    api_key    = var.datadog_api_key
    site       = "datadoghq.com"  # or datadoghq.eu, etc.
  }
}
```

#### Datadog Dashboard

Import [this template JSON](https://docs.formal.ai/assets/json/datadog_log_integration_dashboard.json) for a sample of some of the analyses you can do with the Datadog log integration.

### Splunk

**1. Create Splunk HEC Token**

In Splunk, create a new HTTP Event Collector (HEC) token

**2. Navigate to SIEM**

Go to [SIEM](https://app.formal.ai/log-integrations)

**3. Create Integration**

Click **Create Integration**

**4. Select Splunk**

Choose Splunk as your provider

**5. Enter Configuration**

* **Access Token**: Your HEC token
* **Host**: Your Splunk instance hostname
* **Port**: HEC port (usually 8088)

#### Terraform

```hcl theme={"languages":{"custom":["/languages/cel.json","/languages/rego.json"]}}
resource "formal_integration_log" "splunk" {
  name = "splunk-log-drain"

  splunk {
    access_token = var.splunk_hec_token
    host         = "splunk.example.com"
    port         = 8088
  }
}
```

### Panther

[Custom.Formal.Logs schema](https://docs.formal.ai/assets/yaml/formal_logs_panther_schema.yaml)

## Compression

Log objects written to AWS S3, Google Cloud Storage, and Azure Blob Storage can be sent as compressed files.

| Codec | Object name | Notes |
| - | - | - |
| `none` | `.json` | Default. Plain JSON. |
| `gzip` | `.json.gz` | Widest tool support, and the format most log pipelines expect. |
| `zstd` | `.json.zst` | Smaller objects and faster decompression, with narrower support. |

Compression applies per log object, and Formal currently writes one object per log line. Compression reduces stored bytes but not the number of objects.

> [!NOTE]
>
> Formal records the codec in the object name and leaves the `Content-Encoding` metadata unset.

## Object Storage Layout

For AWS S3, Google Cloud Storage, and Azure Blob Storage, Formal writes objects under:

```text theme={"languages":{"custom":["/languages/cel.json","/languages/rego.json"]}}
formal/logs/{source}/{year}/{month}/{day}/{file}
```

`{source}` is the Connector's name for Connector logs. For other logs, it is `desktop`, `control-plane`, `workflow`, or `insights`. Datadog and Splunk receive the same value as the service name. See [Control Plane Logs](https://docs.formal.ai/docs/guides/observability/control-plane-logs.md#forwarding-control-plane-logs) for Control Plane-specific details.

## Use Cases

### Compliance and Auditing

Forward logs to long-term storage for compliance requirements:

```hcl theme={"languages":{"custom":["/languages/cel.json","/languages/rego.json"]}}
# Archive to S3 for 7 years (SOC 2, HIPAA, etc.)
resource "formal_integration_log" "compliance_archive" {
  name = "compliance-s3-archive"

  aws_s3 {
    s3_bucket_name       = aws_s3_bucket.compliance_logs.bucket
    cloud_integration_id = formal_integration_cloud.aws.id
  }
}

# Configure S3 lifecycle policy
resource "aws_s3_bucket_lifecycle_configuration" "compliance" {
  bucket = aws_s3_bucket.compliance_logs.id

  rule {
    id     = "archive-old-logs"
    status = "Enabled"

    transition {
      days          = 90
      storage_class = "GLACIER"
    }

    expiration {
      days = 2555  # 7 years
    }
  }
}
```

### Real-Time Security Monitoring

Send logs to your SIEM for real-time threat detection:

```hcl theme={"languages":{"custom":["/languages/cel.json","/languages/rego.json"]}}
# Send to Datadog for real-time monitoring
resource "formal_integration_log" "security_monitoring" {
  name = "datadog-security"

  datadog {
    account_id = var.datadog_application_key
    api_key    = var.datadog_api_key
    site       = "datadoghq.com"
  }
}
```

Create alerts in Datadog for:

* Failed authentication attempts
* Policy violations
* Unusual query patterns
* Off-hours access

### Data Lake Integration

Forward logs to your data lake for analytics:

```hcl theme={"languages":{"custom":["/languages/cel.json","/languages/rego.json"]}}
# Send to S3 data lake
resource "formal_integration_log" "data_lake" {
  name = "data-lake-integration"

  aws_s3 {
    s3_bucket_name       = "my-data-lake-formal-logs"
    cloud_integration_id = formal_integration_cloud.aws.id
  }
}
```

Then use Athena, Redshift Spectrum, or Databricks to analyze:

* User access patterns
* Query performance
* Policy effectiveness
* Resource utilization

### Multi-Destination Forwarding

Send logs to multiple destinations:

```hcl theme={"languages":{"custom":["/languages/cel.json","/languages/rego.json"]}}
# Real-time monitoring
resource "formal_integration_log" "splunk_realtime" {
  name = "splunk-realtime"
  splunk {
    access_token = var.splunk_hec_token
    host         = "splunk.example.com"
    port         = 8088
  }
}

# Long-term archive
resource "formal_integration_log" "s3_archive" {
  name = "s3-archive"
  aws_s3 {
    s3_bucket_name       = "formal-logs-archive"
    cloud_integration_id = formal_integration_cloud.aws.id
  }
}

# Security analytics
resource "formal_integration_log" "datadog_security" {
  name = "datadog-security"
  datadog {
    account_id = var.datadog_application_key
    api_key    = var.datadog_api_key
    site       = "datadoghq.com"
  }
}
```

## Next Steps

> [card] [Cloud Accounts](https://docs.formal.ai/docs/guides/integrations/clouds/introduction.md)
>
> Connect AWS or GCP for S3 and GCS log delivery

> [card] [View Logs](https://docs.formal.ai/docs/guides/observability/logs.md)
>
> Monitor logs in the Control Plane


## Related topics

- [Logs](https://docs.formal.ai/docs/guides/observability/logs.md)
- [Glossary](https://docs.formal.ai/docs/glossary/index.md)
- [Control Plane Logs](https://docs.formal.ai/docs/guides/observability/control-plane-logs.md)
- [AWS](https://docs.formal.ai/docs/guides/integrations/clouds/aws.md)
- [Data Handling and Retention](https://docs.formal.ai/docs/guides/observability/data-handling.md)


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