Setting up the Fastly integration

Setting up Log File Analysis with the Fastly Real-Time Log Streaming (opens in a new tab) in ContentKing is very straightforward! Follow the steps outlined below to enable Log File Analysis in ContentKing, and set up the Fastly integration.

Setting up the Log File Analysis

The process of configuring the Log File Analysis consists of two phases:

  1. Enabling the Log File Analysis feature and creating an AWS S3 bucket (opens in a new tab) in ContentKing.

  2. Configuring the Fastly Real-Time Log Streaming in the Fastly UI.

1. Enabling the Log File Analysis feature and creating an AWS S3 bucket in ContentKing

If you navigate to Account and then Websites section in ContentKing, you can easily filter and see which of the websites you are monitoring in ContentKing are on Fastly:

Screenshot of the website section in ContentKing

From there, just follow the steps outlined below to enable Log File Analysis on the wanted website:

  1. Click any website that is running on Fastly in the Websites section (opens in a new tab) of ContentKing
  2. Click on Log File Analysis tab in settings
  3. Move the Log File Analysis toggle to Enabled state

After this is done, follow the next steps to create an AWS S3 bucket in ContentKing:

  1. In the same Log File Analysis section, click on How to install link under the Log Sources
  2. Specify in which region should the AWS S3 bucket be created (EU or US) and click on Create bucket
  3. After this, ContentKing will automatically generate the AWS credentials and the AWS S3 bucket
  4. Save the credentials as they will be used to associate the AWS S3 bucket with the Fastly Real-Time Log Streaming in the next section

2. Configuring the Fastly Real-Time Log Streaming

The Fastly Real-Time Log Streaming needs to be manually configured in the Fastly UI for every website.

The configuration of the Fastly Real-Time Log Streaming consists of these steps:

1. Open website settings screen in your Fastly account

Log in to your Fastly account (opens in a new tab) and click on the website (service) for which you want to enable the Log File Analysis feature

Screenshot of the services in the Fastly UI
2. Click the Edit configuration button

In the service summary screen, click Edit configuration

Screenshot of the website settings in the Fastly UI
3. Open the Logging endpoints screen and create a new endpoint

In the left-hand nav bar click on Logging, and then click Create endpoint

Screenshot of the logging screen in the Fastly account
3. Select the Amazon S3 endpoint

In the Amazon S3 section click Create endpoint

Screenshot illustrating how to enable S3 endpoint in Fastly account
4. Configure the S3 endpoint

In the S3 endpoint details screen add the following settings:

  • Name: enter any name that would help easily identify the endpoint, e.g, "ContentKing LFA S3"
  • Placement: Format Version Default (this is the default, no change needed)
  • Log format: Paste the following format
{   
    "timestampMs": %{time.start.msec}V,
    "ip": "%{req.http.Fastly-Client-IP}V",
    "url": "%{if(req.is_ssl, "https", "http")}V://%v%U%q",
    "method": "%{json.escape(req.method)}V",
    "userAgent": "%{json.escape(req.http.User-Agent)}V",
    "host": "%{if(req.http.Fastly-Orig-Host, req.http.Fastly-Orig-Host, req.http.Host)}V"
  }
  • Timestamp format: %Y-%m-%dT%H:%M:%S.000 (this is the default one, no change needed)
  • Bucket name: copy-paste here the bucket name from the modal in ContentKing that was generated in the steps above.
  • Access Method: User Credentials
  • Access key: copy-paste here the Access key from the modal in ContentKing that was generated in the steps above.
  • Secret key: copy-paste here the Access key from the modal in ContentKing that was generated in the steps above.
  • Period: 60 seconds
Screenshot illustrating how to edit datasets in the S3 endpoint
Screenshot illustrating how to edit datasets in the S3 endpoint
5. Configure additional S3 settings

Click on the Advanced options and edit more properties:

  • Path: / (this is default, no need to change this)
  • Domain: copy-paste here the Domain from the modal in ContentKing that was generated in the steps above.
  • PGP public key: keep this empty (this is default, no need to change this)
  • Select a log line format: Blank (this is default, no need to change this)
  • Compression: Gzip
  • The rest of the settings: keep the default ones
Screenshot illustrating how to edit advanced settings in the S3 endpoint
6. Save the settings

Once done, click Update

Filter away non-search engine traffic

Setting up the response condition

To configure a response condition, so only search engine traffic is sent to the S3 bucket, follow the steps below:

Although, ContentKing filters out all non-search engine traffic, more on this here (opens in a new tab), we also require setting up the condition to filter out all non-search engine traffic directly in your Fastly account, so no other data is streamed to the S3 bucket.

1. Open Conditions

In the left-hand nav bar select Conditions

Screenshot illustrating how to select conditions
2. Create a condition

In the Condition screen, click Create condition

Screenshot illustrating how to create a condition
3. Configure the condition to filter away non-search traffic

In the Condition details screen fill in the following condition:

  • Type: Response
  • Name: any name, e.g. "Is Crawler"
  • Apply if… Paste the exact condition below

req.http.user-agent ~ "bingbot" || req.http.user-agent ~ "googlebot"

4. Save the condition

To save the condition, click Save

Screenshot illustrating how to set up the condition

Attaching the condition to the needed endpoint

To attach the condition to the created endpoint follow these steps:

1. Open the Logging endpoints screen and attach the condition

Open the Logging endpoints screen by clicking on Logging in the left-hand nav bar, and click Attach condition for the endpoint you've just created

Screenshot illustrating how to attach a condition
2. Select the needed condition to attach

In the Add a condition screen select the condition you've just set up

Screenshot illustrating how to select and attach the needed condition
3. Save all changes

To save all changes, just click Activate

Screenshot illustrating how to activate the attached condition

If everything has been configured correctly, you should see a success message

Screenshot illustrating a succesfull condition configution

Reinstalling the Fastly Real-Time Log Streaming

If you want to change the AWS S3 bucket region, or reinstall the Fastly Real-Time Log Steaming, you can do it in the following way:

  1. Click on the website on which you want to reinstall the Fastly Real-Time Log Steaming in the Websites section (opens in a new tab) of ContentKing
  2. Click on Log File Analysis in Settings, and then on the reinstall link under Log Sources
  3. If needed change the region, and click on Create bucket
  4. Create a new Real-Time Log stream by following the steps above

Disabling Log File Analysis

Same as with enabling Log File Analysis, you need to disable the feature in ContentKing and then remove the Fastly Real-Time Log Streaming in the Fastly UI.

Disabling Log File Analysis

  1. Click on the website on which you want to disable Log File Analysis in the Websites section (opens in a new tab) of ContentKing
  2. Click on the Log File Analysis in the Settings section
  3. Move the Log File Analysis toggle to Disabled state

Once this is done, ContentKing will automatically disable Fastly Real-Time Log Streaming access to the AWS S3 bucket where the data was streamed.

Removing the Fastly Real-Time Log Streaming

If you have disabled the Log File Analysis feature, you still need to remove the Fastly Real-Time Log Streaming in your Fastly account.

This needs to be done manually, as ContentKing doesn't have access to your Fastly account.

For the most common security-related questions about ContentKing's Log File Analysis, refer to the FAQ section in the Log File Analysis support article

Need help?

In case you have any questions regarding the Fastly integration that are not covered by our documentation, don’t hesitate to contact us!