HTTP 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 theHTTP requests served by your application. This document describeshow to do the following:
- Set up your application to export HTTP metrics in a predefined format.
- 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.
Set up
To collect metrics from your HTTP server that can be displayed ontheApplication dashboard, you must export the following metrics asdescribed:
http_requests_totalof typecounter, with the labelscodeandmethod.http_request_duration_seconds_bucketof typehistogram, with the labelmethod.
For an example that collects these metrics by using the Prometheus Goclient, seeprometheus-example-app.
To verify that your HTTP 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/HTTP_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 theHTTP server in the same namespace.
You can use the following PodMonitoring configuration:
apiVersion: monitoring.googleapis.com/v1kind: PodMonitoringmetadata: name:my-prometheus-http-app labels: app.kubernetes.io/name:my-prometheus-http-app app.kubernetes.io/part-of: google-cloud-managed-prometheusspec: endpoints: - port: web scheme: http interval: 30s path: /metrics selector: matchLabels: app.kubernetes.io/name: prometheus-example-app
Ensure that the values of theport andMatchLabelsfields match those of the HTTP 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 HTTP 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-18 UTC.