Search code examples
javagoogle-cloud-platformgoogle-kubernetes-enginegoogle-cloud-profiler

GCP Profiler does not find my profiler agent running in GKE


I have a java 11 microservice running in GKE and I've been attempting to attach the java profiling agent provided by GCP.

My Dockerfile is as follows:

FROM openjdk:11-jdk

# Default to UTF-8 file.encoding
ENV LANG C.UTF-8

WORKDIR /app

COPY ./build/libs/*.jar /app/app.jar
RUN mkdir -p /opt/cprof && \ 
   wget -q -O- https://storage.googleapis.com/cloud-profiler/java/latest/profiler_java_agent.tar.gz \
  | tar xzv -C /opt/cprof

EXPOSE 80

CMD ["java", "-agentpath:/opt/cprof/profiler_java_agent.so=-cprof_service=sprofile-test-svc,-cprof_service_version=1.0.0,-cprof_project_id=project-id,-cprof_cpu_use_per_thread_timers=true,-cprof_enable_heap_sampling=true,-logtostderr,-minloglevel=2", \
 "-jar", "/app/app.jar" ]

However, when I go to the Profiler dashboard in GCP, it says the following

No profiling data is found for project "txd-boss-dev", likely because no profiling agent has been configured or the timespan selected includes no profiles


Solution

  • After a while, we found out that there were no issues on either the Dockerfile nor the deployment.yaml file. The microservice had a specific service account and it needed to have the cloudprofiler.agent role added.