Our next-gen architecture is built to help you make sense of your ever-growing data Watch a 4-min demo video!

Back to All Integrations

GCP Log Explorer GCP Log Explorer

Last Updated: Aug. 21, 2022

Log Explorer is one of the first tools to use to troubleshoot issues and find a solution quickly to problems you might be facing. Coralogix came up with an easy way to help you export Log Explorer logs to help you visualize and filter them and create dashboards to see trends and issues that might arise. Following the steps below will guide you through how to set up log explorer integration.

prerequisites

  • Installation of GCP CLI
  • Permissions to configure a function

1) Create a bucket in the same region as the login project
2) Search for cloud storage in the search bar.
3) Click ‘create bucket’.

Complete the info for your bucket

bucket info

In the search, look for Logging

Select ‘Logs Router’ and then ‘Create Sink’

sink logs router

Give the SINK a name and point it to the bucket you created earlier.

sink name and destination

After that, you want to create a function.
By using the Google CLI you have the abillity to create a function by cloning our git repo (where the source code is located) and deploy it as a function to GCP.
View the full code repository here.
Copy the following script and make sure to fill in the necessary fields:

#First lets clone the repository
git clone https://github.com/coralogix/coralogix-gcp-serverless.git &&
	cd coralogix-gcp-serverless

gcloud functions deploy gcp-log-exporter \
	--project=<YOUR_GCP_PROJECT_ID> \
	--region=<GCP_REGION_NAME> \
	--runtime=python39 \
	--memory=1024MB \
	--timeout=300s \
	--entry-point=to_coralogix \
	--trigger-bucket=<YOUR_STORAGE_BUCKET_NAME> \
	--source=gcp-log-exporter \
	--set-env-vars="private_key=<YOUR_PRIVATE_KEY>,app_name=<APP_NAME>,sub_name=<SUB_NAME>"
# additional variables available and their defaults: 'newline_pattern=(?:\r\n|\r|\n)', 'CORALOGIX_LOG_URL=https://<Cluster URL>/api/v1/logs'

There are 2 things to to notice:

  • First, the newline pattern in this function will split the logs and send it line by line.
    In order to override such behavior, create a new enviornment variable with a different pattern as such:
newline_pattern ^\d\w\D\W*
  • Second, the default cluster in this function is EU (meaning: the URL is- https://api.coralogix.com/api/v1/logs.
    in order to change that create a new enviornment variable as such:
CORALOGIX_LOG_URL <cluster URL>/api/v1/logs

Endpoints

Regioncluster URL
EUhttps://api.coralogix.com
EU2https://api.eu2.coralogix.com
UShttps://api.coralogix.us
INhttps://api.coralogix.in
SGhttps://api.coralogixsg.com

On this page