Google Cloud Observability uses application-specific log labels, metric labels, trace resource attributes, and alerting policy labels to construct dashboards and a topology map for applications registered with [App Hub](https://docs.cloud.google.com/app-hub/docs/overview.md.txt).

<br />

In the following sections, the notation `a.b.{x,y}` represents both `a.b.x` and
`a.b.y`.

## Log labels

Log data that Google Cloud infrastructure writes can store application information in the
following [`LogEntry`](https://docs.cloud.google.com/logging/docs/reference/v2/rest/v2/LogEntry.md.txt) fields:

- `apphub`
- `apphubDestination`
- `apphubSource`

Typically, the `apphub` field is populated. The other fields are populated only when
the log entry records edge-like data, such as with VPC Flow Logs. Each of these fields store
an [`AppHub`](https://docs.cloud.google.com/logging/docs/reference/v2/rest/v2/LogEntry.md.txt#AppHub) object,
which can list labels for an application, a service, and a workload.

The following illustrates the format of the `apphub` field:

```text
apphub: {
  application: {
    container: "projects/my-project"
    id: "my-app"
    location: "my-app-location"
  }
  workload: {
    criticalityType: "MEDIUM"
    environmentType: "STAGING"
    id: "my-workload-id"
  }
}
```

## Metric labels

Metric data from Google Cloud infrastructure includes the following metadata labels:

- `metadata.system_labels.apphub_application_{container,id,location}`
- `metadata.system_labels.apphub_{workload,service}_{criticality_type,environment_type,id}`

Metric data from instrumentation you added to your applications can include the following
metric labels:

- `metric.labels.apphub_application_{container,id,location}`
- `metric.labels.apphub_workload_{criticality_type,environment_type,id}`

## Trace resource attributes

Trace spans generated by instrumentation you added to your applications can include the following
resource attributes:

- `gcp.apphub.application.{container,id,location}`
- `gcp.apphub.{workload,service}.{criticality_type,environment_type,id}`

## Alerting policy labels

Service and workload labels aren't automatically attached to alerting policies.
However, you can associate an alerting policy with a specific workload or
service by attaching labels with the following keys to the
alerting policy:

- `apphub_application_location`
- `apphub_application_id`
- `apphub_service_id` or `apphub_workload_id`

When an alerting policy includes the previous keys, alerts for the
policy are shown on the Application Monitoring dashboards.

For more information, see
[Associate an alerting policy with a service or workload](https://docs.cloud.google.com/stackdriver/docs/observability/setup-application-monitoring.md.txt#alert).

## What's next

- [View telemetry](https://docs.cloud.google.com/stackdriver/docs/observability/application-monitoring.md.txt).

- [View application topology](https://docs.cloud.google.com/stackdriver/docs/observability/application-topology.md.txt).

- [Instrument an application for Application Monitoring](https://docs.cloud.google.com/stackdriver/docs/observability/instrument-for-application-monitoring.md.txt).

- [Application Monitoring supported infrastructure](https://docs.cloud.google.com/stackdriver/docs/observability/application-monitoring-services.md.txt).