Instrument an application for Application Monitoring Stay organized with collections Save and categorize content based on your preferences.
About application-specific labels
Application-specific labels refer to labels or attributes that is injectedinto log, metric, or trace data. These labels identify the service or workloadthat generated the data. You can use application-specific labels like any otherlabels. For example, you can filter data by the ID of an application.Telemetry generated bysupported infrastructureautomatically includes these labels. With instrumentation, metrics and traceswritten by your application can include these labels.
In this section,interpreta.b.{x,y} asa.b.x anda.b.y.
Metric data from instrumentation you added to your applications can include the followingmetric labels:
metric.labels.apphub_application_{container,id,location}metric.labels.apphub_workload_{criticality_type,environment_type,id}
Trace spans generated by instrumentation you added to your applications can include the followingresource attributes:
gcp.apphub.application.{container,id,location}gcp.apphub.{workload,service}.{criticality_type,environment_type,id}
About OpenTelemetry HTTP server metrics
There are no system metrics for workloads that run on Google Kubernetes Enginethat can report the traffic level, server error rate, or thelatency for HTTP requests. However, the values for these golden signalscan be derived from thehttp.server.request.duration,which is a metric automatically collected by theOpenTelemetry HTTP clientlibrary.
Thegooglemanagedprometheus exporter converts thehttp.server.request.duration OpenTelemetry metric into a Prometheus metric thathas the following properties:
- Name:
prometheus/http_server_request_duration_seconds/histogram - Metric:
prometheus.googleapis.com/http_server_request_duration_seconds/histogram - Resource types:
prometheus_target - Unit:
s - Kind:
CUMULATIVE - Value type:
DISTRIBUTION
When your Google Cloud project contains thehttp_server_request_duration_secondsmetric, then your Application Monitoring dashboards display the traffic level,server error rate and the latency for HTTP requests.
To learn how to configure your application to export thehttp_server_request_duration_seconds metric,see theUse OpenTelemetry on Kubernetes section of this document.
Add application labels to metric data
Google Cloud Observability attempts to identify the source of Prometheus metrics by comparingthe attributes attached to Prometheus metrics that are sent to your projectwith data returned from the App Hub API.The remainder of this section lists configurations that letGoogle Cloud Observability identify the App Hub application.
Use OpenTelemetry on Kubernetes
Note: We recommend that you use this approach with the Google-Built OpenTelemetry Collector. If yourun workloads on Google Kubernetes Engine, then this approach exports the HTTP servermetric that Application Monitoring uses to generate values for the traffic level,server error rate, and the latency for HTTP requests.To have Google Cloud Observability attach application labels to metric data generated by yourapplication's workloads that run in Google Kubernetes Engine, do the following:
Instrument the application with OpenTelemetry.
- For general information, seeInstrumentation and observability.
- For links to Go, Java, Node.js, and Python samples along with informationabout those samples, seeInstrumentation samples overview.
Deploy either the Google-built Collector or the OpenTelemetry Collector, andconfigure the collector as follows:
- Export metric data with the
googlemanagedprometheusexporter. - Configure the
k8sattributesprocessor to extract metadata,like thenamespace, from the environment. - Configure the
transform/collisionprocessor to set theproject_id,location,cluster, andnamespaceattributes. - Configure the
transform/aco-gkeprocessor to populate thetop_level_controller_nameandtop_level_controller_typelabels.
For an example, see
otlp-k8s-ingest/config/collector.yaml,which is the configuration file for the Google-built Collector. To learnmore about this collector, seeDeploy Google-Built OpenTelemetry Collector on GKE.- Export metric data with the
Register your application's workloads withApp Hub.
Use Google Cloud Managed Service for Prometheus on GKE
To have Google Cloud Observability attach application labels to metric data generated by yourapplication's workloads that runs on Google Kubernetes Engine clusters, do the following:
UseGoogle Cloud Managed Service for Prometheus with managed collection.
Deploy your workloads on a Google Kubernetes Engine cluster whose version is atleast
1.32.1-gke.1439000.Register your application's workloads withApp Hub.
Google Cloud Managed Service for Prometheus discoversthe values of the application labels throughservice discoverymetadata and then adds thetop_level_controller_{name,type} labels to thetargetLabels.metadata.During metric ingestion, Google Cloud Observability uses thetop_level_controller_{name,type} labels and the App Hub API to identifyyour App Hub application and to add the appropriate labels to yourmetric data.
Use Cloud Run
To have Google Cloud Observability attach application labels to metric data generated by yourCloud Run workloads, do the following:
Instrument your application by using either OpenTelemetry or theManaged Service for Prometheus sidecar for Cloud Run.For information about these approaches, see the following documents:
Register your application's workloads withApp Hub.
Verify metric labels
To verify that your application is sending Prometheus metrics, to your project,do the following:
- Verify that your application is sending Prometheus metrics to your project:
In the Google Cloud console, go to theleaderboard Metrics explorer page:
If you use the search bar to find this page, then select the result whose subheading isMonitoring.
- In the toolbar of the Google Cloud console, select your Google Cloud project. ForApp Hub configurations, select the App Hub host project or the app-enabled folder's management project.
- In theMetric element, expand theSelect a metric menu, enter
Prometheus Targetin the filter bar, and then use the submenus to select a specific resource type and metric:- In theActive resources menu, selectPrometheus Target.
- To select a metric, use theActive metric categories andActive metrics menus.
- ClickApply.
To add filters, which remove time series from the query results, use theFilter element.
- Configure how the data is viewed.
To view labels, expand theFilter menu.Each entry in theFilter corresponds to a label.
For more information about configuring a chart, seeSelect metrics when using Metrics Explorer.
If you aren't seeing any Prometheus metrics, then review your configuration.
If your Prometheus metrics don't contain application labels, then do thefollowing:
Verify that you registered your workload or service withApp Hub.
Examine your logs to determine whether there are any errors.
For example, if you deploy an OpenTelemetry Collector or theGoogle-built Collector and are running on Google Kubernetes Engine, then you might dothe 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.
- Select your collector deployment, and then select theLogs tab.
If you are using an OpenTelemetry Collector or the Google-built Collector, thenreview the configuration of your collector. Your collector must do thefollowing:
- Export metric data with the
googlemanagedprometheusexporter. - Configure the
k8sattributesprocessor to extract metadata,like thenamespace, from the environment. - Configure the
transform/collisionprocessor to set theproject_id,location,cluster, andnamespaceattributes. - Configure the
transform/aco-gkeprocessor to populate thetop_level_controller_nameandtop_level_controller_typelabels.
For an example, see Google-built Collector configuration file:
otlp-k8s-ingest/config/collector.yaml.- Export metric data with the
Add application attributes to trace spans
To have Cloud Trace attach application-specific resource attributes to tracedata generated by application's services and workloads, do the following:
- Register your services and workloads withApp Hub.
Instrument your application with OpenTelemetry and send the trace data collectedfrom your application to your project by using theTelemetry (OTLP) API.
Note: You must send trace data to your Google Cloud project by using theTelemetry API. If you use the Cloud Trace exporter or theCloud Trace API, then your trace data won't contain application attributes.To learn how to modify your application to use the Telemetry API, seeMigrate from the Cloud Trace exporter to the OTLP endpoint.Configure the OpenTelemetry Collector or the Google-built Collectorsuch that the exported span data includes theOpenTelemetry resource attributesthat identify thesupported Google Cloud resourcesthat are used by your application. The resource attributes must includethe following:
cloud.account.id- One of
cloud.{availability_zone,region} - Resource-specific attributes. For example, for a Kubernetes workload,spans must have the
k8s.cluster.name,k8s.namespace, and the type ofKubernetes deployment set.
Use processors to have the collector attach resource-specific attributesto your spans. To learn more, see
resourcedetectionprocessorandk8sattributesprocessor.Google Cloud Observability uses the preceding resource attributes and the App Hub APIto identify your App Hub application. Application-specific attributesare added to trace data when an application is identified.
For more information about these attributes, seeGoogle Cloud App Hub semantic conventions.
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 2025-12-15 UTC.