Skip to content

Dkairu/gcp-newrelic-logs-cloud_function

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

GCP function to forward Stackdriver logs to New Relic

The steps for this installation include

  • Creating a cloud function that will be triggered by Pub/Sub when new logs are written.
  • Creating a sink in Stackdriver that will route logs to the Pub/Sub Topic created.
  • Viewing your logs in New Relic.

1. Create a cloud function

Go to the cloud functions page and create a new function make sure to select Cloud Pub/Sub as a trigger alt text

On topic selection create a topic alt text

Add the inline code in the editor and use Node.js 8, make sure you have the same function name as the one you are exporting alt text

Click on the environment variables dropdown and enter the insights insert key with as INSIGHTS_API and click on create alt text

2. Create a sink in Stackdriver

In Stackdriver logging page create a filter for the logs that you want to export, then create a sink with pub/sub as the sink service. On the sink destination select a topic you created from cloud function. alt text

3. View your logs

That's it! In the code above I am sending the JSON as a string and it is stored under message field so you can easily search within the logs. You also have the parsed logs available for filtering. alt text

About

GCP cloud function to forward Stackdriver logs to New Relic

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published