

# Prerequisites for profiles in Omni

Profiles in Omni need profile data in the account and Region of your space, and the permission to read it.

Profile data  
Omni reads the profile data in the `default` CloudWatch Dataset of the space's account and Region. You don't configure a profile pipeline in Omni. By default, this profile data appears in your space. For the collection paths, see [Publish profile data to Amazon CloudWatch](CloudWatch-Profiles-publish.md). To profile a Java application end to end, see [Tutorials: Profile Java applications](CloudWatch-Profiles-getting-started.md).

Permission to read profiles  
Reading a profile requires the `cloudwatch:GetProfileRecords` permission. Two AWS managed policies grant it:  
+ `CloudWatchOmniSpaceAccessPolicy`, for the space itself. Like the other space permissions, it requires the `cloudwatch:HasAccessGrant` condition.
+ `CloudWatchOmniAWSIntegrationPolicyV2`, for the space operator role, which also grants read access to the logs and traces in the `default` Dataset. If your space operator role still has `CloudWatchOmniAWSIntegrationPolicy`, replace it with the V2 policy.
For both policies, see [AWS managed policies for CloudWatch Omni](omni-aws-managed-policies-for-cloudwatch-omni.md).

Encrypted profile data  
If the Dataset is encrypted with a customer managed AWS KMS key, the identity that reads profiles also needs `kms:Decrypt` through CloudWatch for that key. `CloudWatchOmniAWSIntegrationPolicyV2` includes it for the `default` Dataset. For more information, see [Encryption at rest for OpenTelemetry metrics and profiles](cmk-encryption.md).

**Note**  
A space covers one account and one Region, and profiles follow that boundary like the rest of your telemetry. To read profiles from more than one account or Region, see [Set up Omni for your organization](omni-set-up-omni-for-your-organization.md).

## Recommended resource attributes for correlation
<a name="omni-profiles-get-started-attributes"></a>

Omni places a profile on a service by its service name, account, Region, and service namespace. Set the same `service.name`, and the same `service.namespace` if you use one, on your profile data as on the service's traces and metrics, so that Omni shows the profiles on that service, for example in the application map and the service drawer. See [Open a profile](omni-profiles-open.md). Profiles store resource attributes as labels with the `@resource.` prefix. See [Profile type IDs and labels](CloudWatch-Profiles-overview.md#CloudWatch-Profiles-overview-labels).

Set the following resource attributes on your profile data. CloudWatch and the CloudWatch agent set some of them for you.
+ **Service name**: `@resource.service.name` is required. Use the same service name as your traces and metrics. If profile data arrives at the CloudWatch agent without a service name, the agent sets it to `unknown_service`. On Kubernetes, the agent first tries to derive it from pod annotations, `app.kubernetes.io` labels, or the workload, such as the deployment name. Profiles named `unknown_service` don't appear on any service in Omni, but you can still query them in **Explore**. Profile data sent to CloudWatch directly without a service name is rejected.
+ **Account, Region, and cloud attributes**: `@aws.account` and `@aws.region` are the account and Region that received the data. In a centralized copy, that's the destination account and Region. `@resource.cloud.account.id` and `@resource.cloud.region` identify the source account and Region where your resource is deployed, when your sender sets them. For more information, see [Profile type IDs and labels](CloudWatch-Profiles-overview.md#CloudWatch-Profiles-overview-labels) and [Cross-account cross-Region profiles centralization in Amazon CloudWatch](CloudWatchProfiles_Centralization.md).

  When you send through the CloudWatch agent, the agent sets `@resource.cloud.provider`, `@resource.cloud.account.id`, and `@resource.cloud.region` for you. With an OpenTelemetry Collector, add a `resourcedetection` processor (for example, the `ec2` or `ecs` detector) to set them.
+ **Service namespace**: `@resource.service.namespace` is recommended. It's a logical group of services, such as an application name. Set it in the application with `OTEL_RESOURCE_ATTRIBUTES=service.namespace={{name}}`, where {{name}} is your namespace value. Or set it in the CloudWatch agent with the `resource_attributes` field of the `opentelemetry` section. See [CloudWatch agent configuration file: OpenTelemetry section](CloudWatch-Agent-Configuration-File-OpenTelemetrysection.md). On Kubernetes, if you don't set it, the agent uses the `resource.opentelemetry.io/service.namespace` pod annotation or, failing that, the Kubernetes namespace.
+ **Deployment environment**: `@resource.deployment.environment.name` is recommended, such as `prod` or `beta`. Set it the same ways as the service namespace.

  If you don't set it and the CloudWatch agent detects the platform (on Kubernetes, also the cluster name and namespace), the agent sets a default derived from the platform. The default starts with the `cloud.platform` value and a colon. The Auto Scaling group, Amazon ECS cluster, or Kubernetes cluster and namespace follows the colon. For example, `aws_ec2:default`, `aws_ec2:{{asg-name}}`, `aws_ecs:{{cluster-name}}`, or `aws_eks:{{cluster-name}}/{{namespace}}`.

  This default isn't the same as the one that Application Signals uses, such as `ec2:default`, so set your own value to match the environment on your other telemetry. The agent checks only `deployment.environment.name`, so it adds its default even if your SDK sets the older `deployment.environment` key.

If the application sets the service namespace or the deployment environment, the agent keeps that value instead of adding its default. A value in the agent's `resource_attributes` field replaces the value that the application sent, for every service that sends through that agent. For the attributes that the agent detects, such as `cloud.*` and `host.*`, the detected value replaces any value set in the application or in `resource_attributes`.

The following table lists the resource attributes to set on your profile data, and which ones CloudWatch or the CloudWatch agent sets for you.


**Resource attributes for profiles in Omni**  

| **Label** | **Set by** | 
| --- | --- | 
| `@resource.service.name` | Your profiler, from the service name you configure (for example, `OTEL_SERVICE_NAME`) | 
| `@aws.account`, `@aws.region` | CloudWatch | 
| `@resource.cloud.provider`, `@resource.cloud.account.id`, `@resource.cloud.region` | The CloudWatch agent, when it runs on Amazon EC2 or Amazon ECS, including Kubernetes nodes on Amazon EC2 where the agent can read instance metadata | 
| `@resource.service.namespace` | You (on Kubernetes, the CloudWatch agent sets a default if it's missing) | 
| `@resource.deployment.environment.name` | You (the CloudWatch agent sets a default if it's missing and it detects the platform) | 