Log streaming: New Relic Logs
Last updated September 30, 2020
Fastly's Real-Time Log Streaming feature can send log files to New Relic Logs.
NOTE: Fastly does not provide direct support for third-party services. See Fastly's Terms of Service for more information.
Prerequisites
Before adding New Relic Logs as a logging endpoint for Fastly services, you will need to:
- Register for a New Relic account.
- Obtain your license key or optionally create an Insert API key.
Adding New Relic Logs as a logging endpoint
Follow these instructions to add New Relic Logs as a logging endpoint:
- Review the information in our Setting Up Remote Log Streaming guide.
-
Click the New Relic Logs Create endpoint button. The Create a New Relic Logs endpoint page appears.
-
Fill out the Create a New Relic Logs endpoint fields as follows:
- In the Name field, enter a human-readable name for the endpoint.
- In the Log format field, enter the data to send to New Relic Logs. See the example format section for details.
- In the License key / Insert key field, enter your New Relic license key or Insert API key.
- Click the Advanced options link of the Create a New Relic Logs endpoint page. The Advanced options appear.
- In the Placement area, select where the logging call should be placed in the generated VCL. Valid values are Format Version Default, None, and waf_debug (waf_debug_log). Selecting None creates a logging object that can only be used in custom VCL. See our guide on WAF logging for more information about
waf_debug_log
. - Click the Create button to create the new logging endpoint.
- Click the Activate button to deploy your configuration changes.
Example format
Data sent to New Relic Logs must be serialized as a JSON object. Here's an example format string for sending data to New Relic Logs:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
{
"time_elapsed":%{time.elapsed.usec}V,
"is_tls":%{if(req.is_ssl, "true", "false")}V,
"client_ip":"%{req.http.Fastly-Client-IP}V",
"geo_city":"%{client.geo.city}V",
"geo_country_code":"%{client.geo.country_code}V",
"request":"%{req.request}V",
"host":"%{req.http.Fastly-Orig-Host}V",
"url":"%{json.escape(req.url)}V",
"request_referer":"%{json.escape(req.http.Referer)}V",
"request_user_agent":"%{json.escape(req.http.User-Agent)}V",
"request_accept_language":"%{json.escape(req.http.Accept-Language)}V",
"request_accept_charset":"%{json.escape(req.http.Accept-Charset)}V",
"cache_status":"%{regsub(fastly_info.state, "^(HIT-(SYNTH)|(HITPASS|HIT|MISS|PASS|ERROR|PIPE)).*", "\\2\\3") }V"
}
Logging a timestamp
If a timestamp field is present in the Fastly log, it must be specified as millisecond or seconds since Epoch to override the New Relic timestamp. If not included, Fastly will generate a timestamp.
Back to Top