google-kubernetes-engineprometheusstackdrivermicrometerspring-micrometer

How to make Micrometer metrics exported to Stackdriver from a Spring boot application deployed in GKE be aware of the pod instances?


Background

I have a Spring boot application deployed in a GKE cluster, I have configured my deployment yaml file to maintain two instances of my application, and so I have two pods in my cluster. I use Google Operation Suite to monitor the metrics.

Question

I was able export the JVM metrics to Stackdriver using micrometer-registry-stackdriver library. But then the issue is when I look at the metrics from Google Cloud monitor, the JVM metrics from micrometer are not bifurcated based on the pods. How can I make the metrics segregated based on the pod instances?

Also when I am using Google Operation Suite for monitoring my logs and metrics, is there an advantage or use-case for using prometheus to scrape the metrics and sending it to stackdriver (when I can directly push my metrics to Stackdriver)?


Solution

  • You need to inject the pod name to Spring Boot (e.g.: through an env variable), then you can attach the name of the pod to your metrics using either a through a customizer or through properties.