gRPC server Stay organized with collections Save and categorize content based on your preferences.
This document describes how to configure your Google Kubernetes Engine deploymentso that you can use Google Cloud Managed Service for Prometheus to collect metrics from thegRPC requests served by your application. This document describeshow to do the following:
- Set up the gRPC Prometheus middleware forGo and Java.
- Configure a PodMonitoring resource for Managed Service for Prometheus to collect the exported metrics.
- View theApplication dashboard for your GKE Deployment.
These instructions apply only if you are usingmanaged collectionwith Managed Service for Prometheus.
For more information about gRPC, seegrpc.io.
Set up
To collect metrics from your gRPC server, you must configure theappropriate gRPC middleware.
- If you are using Go, then seego-grpc-middleware.
- If you are using Java, then seejava-grpc-prometheus.
To verify that your gRPC server is emitting metrics on the expectedendpoints, do the following:
- Set up port forwarding by using the following command:
kubectl -nNAMESPACE_NAME port-forward deploy/GRPC_SERVER_DEPLOYMENT_NAMEPROMETHEUS_PORT_NUMBER
- Access
localhost:PROMETHEUS_PORT_NUMBERby using the browser or thecurlutility in another terminal session.
Define a PodMonitoring resource
For target discovery, the Managed Service for Prometheus Operatorrequires a PodMonitoring resource that corresponds to thegRPC server in the same namespace.
You can use the following PodMonitoring configuration:
apiVersion: monitoring.googleapis.com/v1kind: PodMonitoringmetadata: name:my-prometheus-grpc-app labels: app.kubernetes.io/name:my-prometheus-grpc-app app.kubernetes.io/part-of: google-cloud-managed-prometheusspec: endpoints: - port: prometheus scheme: http interval: 30s path: /metrics selector: matchLabels: app.kubernetes.io/name:my-prometheus-grpc-app
Ensure that the values of theport andMatchLabelsfields match those of the gRPC application that you want tomonitor.
To apply configuration changes from a local file, run the following command:
kubectl apply -nNAMESPACE_NAME -fFILE_NAME
You can alsouse Terraformto manage your configurations.
View application metrics
To view request, error-rate, and latency metrics from your gRPC application, do the following:
In the Google Cloud console, go to theWorkloads page:
If you use the search bar to find this page, then select the result whose subheading isKubernetes Engine.
- Click a Deployment in the list of workloads. TheType column in the list indicates the type of the workload.
- On theDeployment details page, click theObservability tab.
- SelectApplication in the dashboard selector.
For more information, seeUse application performance metrics.
Troubleshooting
For information about troubleshooting metric ingestion problemsin Managed Service for Prometheus, seeProblems with collection from exporters inTroubleshooting ingestion-side problems.
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2026-02-19 UTC.