Download profile data
This document describes how you can download your profile data to your local system, and how you can programmatically retrieve profile data by using a Go application.
Download profiles by using the Google Cloud console
To download the profile displayed in the flame graph, click Download get_app.
Profiler uses the following naming convention for the downloaded file:
profiler_[SERVICE_NAME]_[PROFILE_TYPE]_[FROM_DATE]_[TO_DATE]_[ZONE]_[VERSION].pb.gz
In this expression:
SERVICE_NAMEcontains your Service selectionPROFILE_TYPEcontains your Profile type selectionFROM_DATEandTO_DATEcontains your time-range specificationsZONEcontains your Zone selectionVERSIONcontains your Version selection
Example: profiler_docdemo-service_HEAP_2018-04-22T20_25_31Z_2018-05-22T20_25_31Z_us-east1-c.pb.gz
Download profiles programmatically
To retrieve profile data, use the ListProfiles API method. The following
sample Go program demonstrates the use of this API.
The sample program creates a folder in the directory from where it is run, and
generates a set of numbered pprof files. Each file has a naming
convention similar to profile000042.pb.gz. Each directory contains profile data
and a metadata file - metadata.csv, which contains information about the
downloaded files.
The sample program accepts the following command line arguments:
project: The project from which the profiles are retrieved. Required.page_size: The maximum number of profiles retrieved per API call. The maximum value ofpage_sizeis 1000. When not specified, this field is set to 100.page_token: A string token generated by a previous run of the program to resume downloads. Optional.max_profiles: The maximum number of profiles to retrieve. If a non-positive integer is provided, then the program attempts to retrieve all profiles.
Optional.
Run the sample application
To run the sample application, do the following:
Clone the repository:
git clone https://github.com/GoogleCloudPlatform/golang-samples.gitChange to the directory that contains the sample program:
cd golang-samples/profiler/exportRun the program after you replace YOUR_GCP_PROJECT with the ID of your Google Cloud project:
go run main.go -project YOUR_GCP_PROJECT -page_size 1000 -max_profiles 10000
The program might take considerable time to complete. The program outputs a token for the next page after retrieving the current page. You can use the token to resume the process if the program is interrupted.
View the downloaded profiles
To read a downloaded file, which is written in the
serialized protocol buffer format, use the open source
pprof tool.