docs.netlify.com Open in urlscan Pro
2a05:d014:275:cb01::c8  Public Scan

Submitted URL: https://hellofrom.netlify.com/api/mailings/click/PMRGSZBCHIZDQMZSGAYCYITVOJWCEORCNB2HI4DTHIXS6ZDPMNZS43TFORWGSZTZFZRW63JPNVXW4...
Effective URL: https://docs.netlify.com/monitor-sites/log-drains/
Submission: On January 25 via manual from US — Scanned from DE

Form analysis 2 forms found in the DOM

<form id="search-form" role="search" class="algolia-search-wrapper search-form"><label class="search-form__label"><svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 32 32"
      class="search-form__label-icon-search">
      <path
        d="M20.571 15.143c0-4.411-3.589-8-8-8s-8 3.589-8 8 3.589 8 8 8 8-3.589 8-8zM29.714 30c0 1.25-1.036 2.286-2.286 2.286-0.607 0-1.196-0.25-1.607-0.679l-6.125-6.107c-2.089 1.446-4.589 2.214-7.125 2.214-6.946 0-12.571-5.625-12.571-12.571s5.625-12.571 12.571-12.571 12.571 5.625 12.571 12.571c0 2.536-0.768 5.036-2.214 7.125l6.125 6.125c0.411 0.411 0.661 1 0.661 1.607z"
        fill="rgba(175, 180, 182, 0.87)"></path>
    </svg> <span class="algolia-autocomplete" style="position: relative; display: inline-block; direction: ltr;"><input id="algolia-search-input" placeholder="Search our docs by topic..." class="search-form__input ds-input" autocomplete="off"
        spellcheck="false" role="combobox" aria-autocomplete="list" aria-expanded="false" aria-label="search input" aria-owns="algolia-autocomplete-listbox-0" dir="auto" style="position: relative; vertical-align: top;">
      <pre aria-hidden="true"
        style="position: absolute; visibility: hidden; white-space: pre; font-family: Mulish, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, Helvetica, Arial, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;, &quot;Segoe UI Symbol&quot;; font-size: 17.5px; font-style: normal; font-variant: normal; font-weight: 400; word-spacing: 0px; letter-spacing: normal; text-indent: 0px; text-rendering: auto; text-transform: none;"></pre>
      <span class="ds-dropdown-menu" role="listbox" id="algolia-autocomplete-listbox-0" style="position: absolute; top: 100%; z-index: 100; display: none; left: 0px; right: auto;">
        <div class="ds-dataset-1"></div>
      </span>
    </span></label> <button tabindex="-1" type="reset" class="search-form__label-icon-close"><span class="visuallyhidden">Close search</span> <svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 18 18">
      <g fill="#A3A9AC" transform="scale(-1 1) rotate(45 .571 -12.959)">
        <rect width="2.333" height="18.667" x="8.164" y=".003"></rect>
        <polygon points="8.164 .003 10.497 .003 10.497 18.67 8.164 18.67" transform="rotate(-90 9.33 9.336)"></polygon>
      </g>
    </svg></button>
  <div class="search-form__content-overlay"></div>
</form>

Name: feedbackPOST

<form class="form form--floating-labels feedback__form--appear" method="post" name="feedback"><input type="hidden" name="form-name" value="feedback"> <input type="hidden" name="path" value="/monitor-sites/log-drains/"> <input type="hidden"
    name="vote" value=""> <label class="visuallyhidden"> Do not fill in this field <input name="verification" value=""></label>
  <div class="form__field"><label>
      <div class="form__label"> What else would you like to tell us about this doc? </div> <textarea name="feedback" class="form__textarea"></textarea>
    </label></div>
  <div class="btn-group"><button disabled="disabled" class="btn"> Send </button></div>
</form>

Text Content

Netlify Docs


Close search

Menu
 * Log in
 * Sign up

 * Welcome
 * Git
 * Environment Variables
 * Configure builds
 * Site deploys
 * Monitor sites
    * Analytics
       * How it works
       * Usage & billing
   
    * Monitor builds
    * Lighthouse
    * Logs
       * Log Drains
   
    * Notifications
    * Status badges

 * Domains & HTTPS
 * Static routing
 * Visitor access
 * Forms
 * Functions
 * Edge Functions
 * Large Media
 * Integrations
 * CLI
 * API
 * Netlify Labs
 * Accounts & billing
 * Get help

Contact

 * Forums
 * Contact support
 * Research program

 * Log in
 * Sign up

On this page
 1. Configure a log drain
    * Datadog
    * New Relic
    * Sumo Logic
    * Logflare
    * Amazon S3
    * General HTTP endpoint
 2. Edit a log drain
 3. Remove a log drain
 4. Traffic log output
 5. Function log output
 6. Edge Function log output


LOG DRAINS

This feature may not be available on all plans.

The Log Drains feature allows you to connect site traffic logs, function logs,
and edge function logs from Netlify’s CDN to third-party monitoring services for
analysis, alerting, and data persistence.

Once you’ve configured a log drain for a site, Netlify batches the site’s log
records and posts them to an endpoint in JSON/NDJSON format in near real-time. A
configured external monitoring provider receives these records from the intake
endpoint and makes them available for processing. The site traffic log output
tracks visitor requests for assets and pages, while the function log output
tracks information such as function invocations, and the edge function log
output tracks edge functions that output console log statements.


# CONFIGURE A LOG DRAIN

To set up a log drain, you must be a Netlify team Owner and have an account and
API key provisioned with an external monitoring provider. Netlify supports
integration with:

 * Datadog
 * New Relic
 * Sumo Logic
 * Logflare
 * Amazon Simple Storage Service (Amazon S3)
 * General HTTP endpoints


# DATADOG

 1. For your selected site, go to Site settings > Log Drains and select Enable a
    log drain.

 2. Select Datadog as the Log drain service.

 3. Select the Log type. You can drain your site’s traffic logs, function logs,
    and edge function logs.

 4. Under Service settings, select the Region where your Datadog site is
    located.

 5. Enter the unique API key for your logging service provider account. Verify
    that you are entering your API key instead of the Datadog application key.

 6. Optional: Add key/value pairs under Tags to tag your logs with certain
    attributes. These become query parameters in requests to the logs intake
    endpoint.
    
    Available keys for Datadog:
    
    Key Tag Description Example value ddtag tags associated with logs, grouped
    into a single list with the value ddtags env:prod service name of the
    application or service generating the log events mysubdomain

 7. Select Connect.


# NEW RELIC

 1. For your selected site, go to Site settings > Log Drains and select Enable a
    log drain.

 2. Select New Relic as the Log drain service.

 3. Select the Log type. You can drain your site’s traffic logs, function logs,
    and edge function logs.

 4. Under Service settings, select the Region that applies to your New Relic
    account.

 5. Enter a License API key, also called INGEST-LICENSE, for your New Relic
    account. Verify that you’re entering your License API key and not your
    License API key ID or user key.

 6. Optional: To add a tag for your log drain, under Tags, enter the key and
    value. Then select Add tag. Any tags you add become query parameters in log
    drain requests to New Relic.
    
    Example tags for New Relic:
    
    Key Value Tag description environment production environment type service
    mysubdomain name of the application or service generating the log events

For guided help on optimizing your New Relic dashboard for your site’s logs,
install the Netlify Logs quickstart on New Relic.

 7. Select Connect.


# SUMO LOGIC

To configure a log drain that sends logs to your Sumo Logic account, you need
to:

 1. Configure your HTTP Logs and Metrics Source in Sumo Logic
 2. Set up the log drain in the Netlify UI

# CONFIGURE YOUR HTTP LOGS AND METRICS SOURCE IN SUMO LOGIC

 1. If you haven’t already, create a hosted collector to collect your data in
    Sumo Logic.

 2. In the Sumo Logic web app, add and configure your HTTP Logs and Metrics
    Source using Sumo Logic’s docs.

 3. Ensure that you copy your HTTP Source Address to use in the Netlify UI.

# SET UP THE LOG DRAIN IN THE NETLIFY UI

For security, Netlify hides the full HTTP Source Address in the Netlify UI.
After you configure your log drain, only the base URL is visible in the Netlify
UI.

 1. On Netlify, for your selected site, go to Site settings > Log Drains and
    select Enable a log drain.
 2. Select Sumo Logic as the Log drain service.
 3. Select the Log type. You can drain your site’s traffic logs, function logs,
    and edge function logs.
 4. In the Full URL field, enter the HTTP Source Address you copied from Sumo
    Logic.
 5. Select Connect.


# LOGFLARE

 1. For your selected site, go to Site settings > Log Drains and select Enable a
    log drain.
 2. Select Logflare as the Log drain service.
 3. Select the Log type. You can drain your site’s traffic logs, function logs,
    and edge function logs.
 4. Under Service settings, enter your Logflare Ingest API key.
 5. To specify where you want your logs to go, enter the Logflare Source ID for
    your logs.
 6. Select Connect.


# AMAZON S3

To configure a log drain that sends logs to your Amazon S3 account as
Gzip-compressed files, you need to:

 1. Create an Amazon S3 bucket and set up a bucket policy
 2. Configure the log drain in the Netlify UI

# CREATE AN AMAZON S3 BUCKET AND SET UP A BUCKET POLICY

 1. In the AWS Management Console, create an S3 bucket.
    * Object Ownership for the bucket should be set to either Bucket owner
      enforced or Bucket owner preferred.
    * Make note of the bucket name to use in your Netlify configuration.
 2. Go to your bucket’s Permissions and under Bucket policy select Edit.
 3. Copy and paste the following bucket policy, replacing YOUR_BUCKET_NAME with
    the name of your Amazon S3 bucket:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "NetlifyLogDrains",
      "Effect": "Allow",
      "Principal": {
        "AWS": "arn:aws:iam::128866310339:role/log-shipper"
      },
      "Action": "s3:PutObject",
      "Resource": "arn:aws:s3:::YOUR_BUCKET_NAME/*",
      "Condition": {
        "StringEquals": {
          "s3:x-amz-acl": "bucket-owner-full-control"
        }
      }
    }
  ]
}

Copy to Clipboard  

 4. Select Save Changes.

Bucket lifecycle

For cost control reasons, we recommend deleting logs after a period of 90 days.
You can configure your Amazon S3 bucket to delete logs automatically by setting
lifecycle rules.

# CONFIGURE THE LOG DRAIN IN THE NETLIFY UI

 1. For your selected site, go to Site settings > Log Drains and select Enable a
    log drain.
 2. Select Amazon AWS S3 as the Log drain service.
 3. Select the Log type. You can drain your site’s traffic logs, function logs,
    and edge function logs.
 4. Under Service settings, select the Bucket region where your bucket is
    located.
 5. Enter your S3 Bucket name.
 6. Optional: Enter your S3 Bucket path. We recommend using
    YOUR_BUCKET_NAME/logs/netlify/. If no path is specified, the logs will be
    written to the root of the S3 bucket.
 7. Select Verify bucket and connect.



 8. Use the provided path to navigate to your S3 bucket’s verification file.
 9. Copy and paste the contents of the file into the Verification token field,
    then select Verify.


# GENERAL HTTP ENDPOINT

Netlify’s General HTTP endpoint support allows you to set up a custom log drain
with any external monitoring provider that accepts log drain requests in JSON or
NDJSON format.

To set up a custom log drain, you must provide a full URL for your external
monitoring provider’s endpoint and include your third-party API key as a query
parameter. For example, this URL includes an API key and a tag as query
parameters:

http://YOUR_ENDPOINT_RESOURCE_PATH?api-key=YOUR_API_KEY&environment=production

Copy to Clipboard  

For security, Netlify hides the full endpoint in the Netlify UI. After you
configure your log drain, only the base URL is visible in the Netlify UI.

 1. For your selected site, go to Site settings > Log Drains and select Enable a
    log drain.
 2. Select General HTTP endpoint as the Log drain service.
 3. Select the Log type. You can drain your site’s traffic logs, function logs,
    and edge function logs.
 4. Enter the Full URL for your endpoint, including your API key and any
    optional tags as query parameters.
 5. Select the Log Drain Format that your endpoint accepts.
 6. Select Connect.


# EDIT A LOG DRAIN

If you need to adjust the settings for an existing log drain, under Site
Settings > Log Drains, select Edit settings. Configuration changes become active
within approximately five minutes.

To stop sending specific log data to your external monitoring provider, clear
the Log type you no longer need and select Verify bucket and save.


# REMOVE A LOG DRAIN

To terminate an existing log drain configuration for a site, under Site Settings
> Log Drains, select Delete log drain. All log types associated with the site’s
log drain will be removed. Saved logs are accessible in your logging service
provider account.


# TRAFFIC LOG OUTPUT

Drained site traffic logs include the following fields parsed from our CDN logs:

 * account_id: ID of the Netlify team that the site belongs to.
 * client_ip: IP address of the client.
 * content_type: Content-Type of the request (for example, text/html).
 * deploy_id: ID of the deploy (for example, 61153ae8b0f6a900088386e8).
 * duration: duration of the request in milliseconds.
 * log_type: indicates the type of log. The value is traffic.
 * method: request method.
 * referrer: referrer on the request.
 * request_id: Netlify request ID (for example, 01FDWR77JMF2DA1CHF5YA6H07C).
 * request_size: size of the request in bytes.
 * response_size: size of the response in bytes.
 * site_id: ID of the site.
 * status_code: status code of the HTTP response.
 * timestamp: timestamp of the request, formatted with RFC 3339 (for example,
   2021-08-24T18:54:34.831Z).
 * url: URL of the request.
 * user_agent: user-agent that made the request.


# FUNCTION LOG OUTPUT

Drained function logs include the following fields parsed from our CDN logs:

 * account_id: ID of the Netlify team that the function belongs to.
 * deploy_id: ID of the deploy (for example, 61153ae8b0f6a900088386e8).
 * duration: amount of time it took for AWS Lambda to execute the function.
 * function_name: name of the function.
 * function_type: type of function. The value for function logs is standard.
 * level: level of the log line (for example, INFO, ERROR, WARN, REPORT).
 * log_message: log message.
 * log_type: field indicating the type of log. All function types will have the
   value functions.
 * method: method of the request (for example, GET).
 * path: path of the request (for example,
   /.netlify/functions/your-awesome-function).
 * request_id: Netlify request ID (for example, 01FDWR77JMF2DA1CHF5YA6H07C).
 * site_id: ID of the site.
 * status_code: status code of the HTTP response.
 * timestamp: timestamp of the request, formatted with RFC 3339 (for example,
   2021-08-24T18:54:34.831Z).

Note that function log output is limited to 4 KB total per invocation. If a
log’s output exceeds 4 KB, only the last 4 KB of the log is sent to the logging
service and the log message will be truncated.


# EDGE FUNCTION LOG OUTPUT

Edge Functions are in BETA.

Drained edge function logs include the following fields parsed from our CDN
logs:

 * account_id: ID of the Netlify team that the edge function belongs to.
 * branch: name of the branch. This field is only present for non-production
   branches.
 * deploy_id: ID of the deploy (for example, 61153ae8b0f6a900088386e8).
 * function_name: name of the edge function.
 * function_type: type of function. The value for edge function logs is edge.
 * level: level of the log line (for example, INFO, ERROR, WARN, REPORT).
 * log_type: field indicating the type of log. All function types, including
   edge functions, will have the value functions.
 * request_id: Netlify request ID (for example, 01FDWR77JMF2DA1CHF5YA6H07C).
 * request_path: path of the request (for example, /log).
 * site_id: ID of the site.
 * timestamp: timestamp of the request, formatted with RFC 3339 (for example,
   2021-08-24T18:54:34.831Z).

Log messages will appear in the content field for your logging service.

← Logs

DID YOU FIND THIS DOC USEFUL?

Your feedback helps us improve our docs.


Do not fill in this field
What else would you like to tell us about this doc?
Send
 * Netlify
 * Careers
 * Blog
 * Terms
 * Privacy

Select a theme

SystemLightDark

© 2023 Netlify