Log Drains for function and CDN logs from Netlify, which have native SumoLogic collectors available, are included with Enterprise level subscriptions. However, there is a quantum jump in subscription costs between the Teams or Pro Editions of Netlify and the Enterprise Edition.
If you are deploying a JAMStack app in Netlify, the odds are each page will include an API call (using Netlify functions), and for authenticated pages, the request will include a Bearer Token.
Create a logging module that exports functions that can be used by any of your Netlify functions to log verbose data to the console (seen in the function log output in the Netlify app) and to push log events to a Hosted SumoLogic Collector Source. This will allow you to see verbose logs for each function call and CDN logs for each page load.
Steps to deploy this solution are detailed here:
Step 1. Set up a Collector and Source
Set up a Custom HTTP Collector and Source in SumoLogic (copy the source URL) using the SumoLogic web interface; see the documentation here: https://help.sumologic.com/03Send-Data/Sources/02Sources-for-Hosted-Collectors/HTTP-Source/Upload-Data-to-an-HTTP-Source.
Step 2. Create Netlify Environment Variable(s)
Create a build time environment variable in Netlify for the Sumo Source URL you generated in Step 1 (in this case, I have called it
Step 3. Create a logging module
Create your logging module (this example is in TypeScript, but you could implement the same logic in any other language/runtime). In this case, we will unpack the request event and send the fields to the collector source.
Step 4. Import and use the logging module
Now import and use the
logRequest function at the beginning of each Netlify function you deploy.
You will now get verbose logs (similar to CDN logs) to the Netlify console and to Sumo Logic!
You can implement similar functions for each request to log the
userInfo from the Bearer Token. This will allow you to see the user information for each request in SumoLogic.
Your http response header should include:
if you have enjoyed this post, please consider buying me a coffee ☕ to help me keep writing!