Compute@Edge log streaming: New Relic Logs

Fastly's Real-Time Log Streaming feature for Compute@Edge services can send log files to New Relic Logs.

NOTE

Fastly does not provide direct support for third-party services. Read Fastly's Terms of Service for more information.

Prerequisites

Before adding New Relic Logs as a logging endpoint for Fastly Compute@Edge services, you will need to:

Adding New Relic Logs as a logging endpoint

Follow these instructions to add New Relic Logs as a logging endpoint:

  1. Review the information in our guide to setting up remote log streaming for Compute@Edge. Additionally, our developer documentation provides more information about logging with Compute@Edge code written in Rust, AssemblyScript, and JavaScript.
  2. Click the New Relic Logs Create endpoint button. The Create a New Relic Logs endpoint page appears.
  3. Fill out the Create a New Relic Logs endpoint fields as follows:
    • In the Name field, enter the endpoint name you specified in your Compute@Edge code. For example, in our Rust code example, the name is my_endpoint_name.
    • In the License key / Insert key field, enter your New Relic license key or Insert API key.
  4. Click the Create button to create the new logging endpoint.
  5. Click the Activate button to deploy your configuration changes.

Using New Relic Instant Observability's prebuilt Fastly dashboard

New Relic I/O is an open source ecosystem of a wide variety of community-contributed monitoring quickstarts. We worked with New Relic to develop a prebuilt dashboard that highlights key metrics. Because the code is open source, you can customize it.

New Relic Fastly Dashboard

Configure Your Log Messages

Data sent to New Relic Logs must be serialized as a JSON object. The JSON object should include the following fields:

  • timestamp: when the request occurred. The timestamp must be specified as milliseconds since Epoch to override the New Relic timestamp. If timestamp is not included, Fastly will generate a timestamp.
  • client_ip: the IP address of the client making the HTTP request.
  • url: the URL of the request.
  • resp_status: the HTTP status code of the request.
  • client_resp_header_size_write: the size of the response header.
  • client_resp_body_size_write: the size of the response body.
  • fastly_datacenter: the three-character identifying code of the FASTLY_POP in which the current instance is running.
  • time_elapsed: the time since the request started.
  • service_id: the identifier for the Fastly service that is processing the current request.
  • logtype: set to accesslogs, the main hint for identifying logs and matching New Relic parsing rules.

An example of the suggested more descriptive JSON log object is shown below.

1{
2 "timestamp": 1661976797605,
3 "logtype": "accesslogs",
4 "cache_status": "ERROR",
5 "client_ip": "127.0.0.1",
6 "client_device_type": "Chromebook",
7 "client_os_name": "Ubuntu",
8 "client_os_version": "17.10 (Artful Aardvark)",
9 "client_browser_name": "Firefox",
10 "client_browser_version": "113.0",
11 "client_as_name": "zayo bandwidth",
12 "client_as_number": "1234",
13 "client_connection_speed": "broadband",
14 "client_port": 63850,
15 "client_rate_bps": 0,
16 "client_recv_bytes": 74,
17 "client_requests_count": 1,
18 "client_resp_body_size_write": 56789,
19 "client_resp_header_size_write": 1234,
20 "client_resp_ttfb": 1.342,
21 "client_rtt_us": 6818,
22 "content_type": "text/html; charset=utf-8",
23 "domain": "example.com",
24 "fastly_datacenter": "HNL",
25 "fastly_host": "cache-hnl00001",
26 "fastly_is_edge": true,
27 "fastly_region": "US-Pacific",
28 "fastly_server": "cache-hnl00001-HNL",
29 "host": "example.com",
30 "origin_host": "example.com",
31 "origin_name": "n/a",
32 "request": "GET",
33 "request_method": "GET",
34 "request_accept_charset": "utf-8",
35 "request_accept_language": "en-US",
36 "request_referer": "",
37 "request_user_agent": "curl/7.68.0",
38 "resp_status": "503",
39 "response": "Backend unavailable, connection timeout",
40 "service_id": "000q0j0WE0f00z0KEVj5I0",
41 "service_version": "29",
42 "status": "503",
43 "time_start": "2023-05-18T23:21:52Z",
44 "time_end": "2023-05-18T23:21:53Z",
45 "time_elapsed": 237,
46 "tls_cipher": "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256",
47 "tls_version": "TLS 1.2",
48 "url": "/",
49 "user_agent": "curl/7.68.0",
50 "user_city": "san francisco",
51 "user_country_code": "US",
52 "user_continent_code": "NA",
53 "user_region": "CA"
54}

While the prebuilt dashboard won't break if the JSON object doesn't include all of the expected fields, certain charts won't have data.

In addition to the suggested fields, you can include fields of your choosing in the JSON object for your own purposes or to maintain backward compatibility with existing dashboards you've built.

Install the Fastly dashboard

Follow these instructions to install the Fastly dashboard quickstart:

  1. Select the Fastly dashboard quickstart from the New Relic marketplace or navigate directly to the Fastly dashboard page. The Fastly CDN page appears.
  2. Click the Install quickstart button. The Quickstart installation page appears.
  3. Click the Begin installation button. The Installation plan window appears.
  4. Click the Done button or the Skip this step link.
  5. Click the See your data button. The Fastly dashboard appears.
Was this guide helpful?

Do not use this form to send sensitive information. If you need assistance, contact support.