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

# Google Cloud CDN

> This documentation explains how to set up Google Cloud CDN log delivery to Profound Agent Analytics platform using a log sink.

## Overview

This integration uses a topic, subscription, and log sink to capture Google Cloud CDN logs and forward them to Profound Agent Analytics platform.

## Prerequisites

* A GCP account with Google Cloud CDN enabled

* Access and edit permissions to the GCP project

* API endpoint details for the Profound Agent Analytics platform

## Configuration

<img src="https://mintcdn.com/profound-37face47/tg0qbLRw_vFMInTl/images/agent-analytics/gcp/gcp_setup.png?fit=max&auto=format&n=tg0qbLRw_vFMInTl&q=85&s=afcaea65e6de8c8cf41bf68e5da11fe4" alt="GCP setup" width="3680" height="2390" data-path="images/agent-analytics/gcp/gcp_setup.png" />

<Steps>
  <Step title="Step 1">
    Sign into the GCP Console and navigate to `Topics`, you can search for 'topics' in the search bar.
  </Step>

  <Step title="Step 2">
    Create a new topic by clicking the `Create Topic` button near the top.

    <img src="https://mintcdn.com/profound-37face47/tg0qbLRw_vFMInTl/images/agent-analytics/gcp/create_topic.png?fit=max&auto=format&n=tg0qbLRw_vFMInTl&q=85&s=b562468b14ddb5f2958332a7cf80ded3" alt="Create a topic" width="3680" height="2390" data-path="images/agent-analytics/gcp/create_topic.png" />

    Give your topic a name and click `Create`
  </Step>

  <Step title="Step 3">
    Navigate to the `Subscriptions` tab on the left sidebar. Click the `Create Subscription` button near the top.

    <img src="https://mintcdn.com/profound-37face47/tg0qbLRw_vFMInTl/images/agent-analytics/gcp/create_a_subscription.png?fit=max&auto=format&n=tg0qbLRw_vFMInTl&q=85&s=9dd8d288cad258acaed3fba9b4fc23f2" alt="Create subscription" width="3680" height="2390" data-path="images/agent-analytics/gcp/create_a_subscription.png" />

    1. Give your subscription a name.
    2. Select the topic you created in step 2.
    3. Use delivery type `Push`
       * Enter `https://artemis.api.tryprofound.com/v1/logs/gcp_log_sink` as the endpoint
       * Enable authentication
       * Paste the service account this subscription will use into the `Service account` field
       * Leave `Audience` blank
       * Enable payload unwrapping
  </Step>

  <Step title="Step 4">
    Add retention policy configurations at your discretion.

    <img src="https://mintcdn.com/profound-37face47/tg0qbLRw_vFMInTl/images/agent-analytics/gcp/subscription_retention_policy.png?fit=max&auto=format&n=tg0qbLRw_vFMInTl&q=85&s=99f1706b09abb9289f362878cd3c0239" alt="Retention policy" width="3680" height="2390" data-path="images/agent-analytics/gcp/subscription_retention_policy.png" />
  </Step>

  <Step title="Step 5">
    Click `Add a Transform` button. Enter `profound_agent_analytics_reduce` as the function name.

    Paste the following code into the function body:

    ```javascript theme={null}
    /* This UDF is used to filter the unused fields before sending to Profound.
     * 
     * @param {Object} message - The message to reduce.
     * @param {Object} metadata - The metadata of the message.
     * @returns {Object} The reduced message.
    */

    function profound_agent_analytics_reduce(message, metadata) {
        // parse the message
        const data = JSON.parse(message.data);

        // remove unused fields
        delete data['insertId'];
        delete data['jsonPayload'];
        delete data['logName'];
        delete data['receiveTimestamp'];
        delete data['resource'];
        delete data['severity'];
        delete data['spanId'];
        delete data['trace'];

        message.data = JSON.stringify(data);

        return message;

    }
    ```

    <Info>This function is used to drop extraneous fields before sending to Profound. This reduces log export volume, improves performance, and enhances data security.</Info>

    <img src="https://mintcdn.com/profound-37face47/tg0qbLRw_vFMInTl/images/agent-analytics/gcp/subscription_transform.png?fit=max&auto=format&n=tg0qbLRw_vFMInTl&q=85&s=30c80cbdc54364c310f5b1aaeea9477d" alt="Transform function" width="3680" height="2390" data-path="images/agent-analytics/gcp/subscription_transform.png" />

    Click `Validate` to ensure the function is valid.
  </Step>

  <Step title="Step 6">
    Add additional configurations at your discretion.

    <img src="https://mintcdn.com/profound-37face47/tg0qbLRw_vFMInTl/images/agent-analytics/gcp/subscription_optional_config.png?fit=max&auto=format&n=tg0qbLRw_vFMInTl&q=85&s=c863a14ff66be1824ce1878df86bee24" alt="Additional configurations" width="3680" height="2390" data-path="images/agent-analytics/gcp/subscription_optional_config.png" />

    Click `Create` to create the subscription.
  </Step>

  <Step title="Step 7">
    Navigate to the `Log Router` tab by searching 'log router' in the search bar. Click the `Create sink` button near the top.

    Give your sink a name and optional description.
  </Step>

  <Step title="Step 8">
    In the `Sink destination` section, select `Cloud Pub/Sub topic` as the `sink service` . In the `sink destination` field, select the topic you created in step 2.

    <img src="https://mintcdn.com/profound-37face47/tg0qbLRw_vFMInTl/images/agent-analytics/gcp/sink_service.png?fit=max&auto=format&n=tg0qbLRw_vFMInTl&q=85&s=fc04900889359ece1c61f29f3c0f6645" alt="Sink service" width="3680" height="2390" data-path="images/agent-analytics/gcp/sink_service.png" />
  </Step>

  <Step title="Step 9">
    Add the following filters to your sink in the `Choose logs to include in sink` section.

    <Warning>Make sure to replace the placeholders with your real load balancer and url map names. **This is only an example.**</Warning>

    ```toml theme={null}
    resource.type="http_load_balancer"
    resource.labels.forwarding_rule_name="MY-FORWARDING-RULE-NAME"
    resource.labels.url_map_name="MY-URL-MAP-NAME"
    ```

    <img src="https://mintcdn.com/profound-37face47/tg0qbLRw_vFMInTl/images/agent-analytics/gcp/sink_filters.png?fit=max&auto=format&n=tg0qbLRw_vFMInTl&q=85&s=5b2447b42a4b3bb85515a7fff4f9c275" alt="Sink filters" width="3680" height="2390" data-path="images/agent-analytics/gcp/sink_filters.png" />

    Finally, click `Create sink` at the bottom.

    <Info>
      If you have multiple load balancers and url maps, you can modify the filters to include multiple resources like:

      ```toml theme={null}
      resource.type="http_load_balancer"
      AND (
      (resource.labels.forwarding_rule_name="MY-FORWARDING-RULE-NAME"
      AND resource.labels.url_map_name="MY-URL-MAP-NAME")
      OR
      (resource.labels.forwarding_rule_name="MY-FORWARDING-RULE-NAME-2"
      AND resource.labels.url_map_name="MY-URL-MAP-NAME-2")
      )
      ```
    </Info>
  </Step>

  <Step title="Step 10">
    <Warning>
      If you are registering multiple GCP domains with Profound, you will need to create a separate service account for each domain. The account is used to decode the JWT token and confirm the source domain.
    </Warning>

    Navigate back to Profound. On the Agent Analytics onboarding page, paste the same service account email you used in step 3 into the `GCP Service Account` field. Ensure you click `Save` after pasting the email.

    <img src="https://mintcdn.com/profound-37face47/tg0qbLRw_vFMInTl/images/agent-analytics/gcp/gcp_setup.png?fit=max&auto=format&n=tg0qbLRw_vFMInTl&q=85&s=afcaea65e6de8c8cf41bf68e5da11fe4" alt="Service account" width="3680" height="2390" data-path="images/agent-analytics/gcp/gcp_setup.png" />

    Click `Continue` to complete the onboarding process.
  </Step>
</Steps>

<Check>
  That's it! Google Cloud CDN will now send real-time logs to Profound. Data should begin appearing in your dashboard within a few minutes.
</Check>

## Troubleshooting

* Ensure you have shared the same service account email with Profound that you used to create the subscription.

* Check the `Logs` tab in Profound to verify the logs are being received.

* Verify the service account has the necessary permissions to access the topic as pub/sub.

* Verify the topic is created and active.

* Verify the subscription is created and active.

## Additional Resources

* [Third Party Log Routing Documentation](https://docs.cloud.google.com/logging/docs/export/pubsub#integrate-thru-pubsub)

* [Service Account Management Documentation](https://docs.cloud.google.com/iam/docs/create-service-agents#grant-role)

* Contact [support@tryprofound.com](mailto:support@tryprofound.com) for API-related questions
