To deploy gProfiler in a Docker container, first ensure that you have Docker set up on your machine or cluster. Then, after signing up for your free gProfiler account, click on Install Service on the left hand menu, then Docker under Installation Methods.
Here you will see your unique API key. Choose a service name and then run the following in your terminal, replacing the value with your API key string and the value with your chosen service name string:
docker pull granulate/gprofiler:latest
docker run --name granulate-gprofiler -d --restart=on-failure:10 \
--pid=host --userns=host --privileged \
-v /lib/modules:/lib/modules:ro -v /usr/src:/usr/src:ro \
-v /var/run/docker.sock:/var/run/docker.sock \
granulate/gprofiler:latest -cu --token <token> --service-name <service>
After running the above (with the replaced values) on each node you want to continuously profile, Docker will pull the ‘granulate/gprofiler’ image and mount it to the container you created.
Wait a few minutes as gProfiler receives and processes the profiling data from your container.
For profiling with eBPF, kernel headers must be accessible from within the container at /lib/modules/$(uname -r)/build. On Ubuntu, this directory is a symlink pointing to /usr/src. The command above mounts both of these directories.
To check that your container is up, run docker ps to see all running containers, and find the container named ‘granulate-profiler’. To SSH into the container and view its PID, run docker exec -it granulate-gprofiler pgrep docker.
Once you’ve confirmed gProfiler is set up and running, go to Profiles on the gProfiler interface. You should see profiling data from your service when filtering for data in the Last Hour. On the gProfiler Overview page, you should also see your service listed, with a Create Date of ‘Today’, and ‘Analyzing’ in the Optimization Potential column.
Copy link