

# Permissions for fleet cost and usage

The **Observability** tab calls AWS services from your browser with the credentials of your console session. Its queries can only read what your IAM identity can already read in the registry’s account. The tab adds no new AWS Agent Registry actions.

## Permissions to view fleet cost and usage
<a name="registry-cost-observability-permissions-view"></a>

Grant these permissions to the IAM identity that views the **Observability** tab. The identity must be in the account that owns the organization-scoped registry. The following table lists each action and why the tab needs it.


| Action | Why the tab needs it | 
| --- | --- | 
|  `agent-registry:GetRegistry`  | Reads the registry and its auto-detection status. | 
|  `agent-registry:ListRegistryRecords`  | Reads the registry’s records to name agents and link to them. | 
|  `logs:StartQuery`  | Runs the CloudWatch Logs Insights queries behind each view. | 
|  `logs:DescribeLogGroups`  | Finds the log groups that each query reads. Each query chooses its log groups with the `SOURCE` command, so CloudWatch Logs also checks this action, on the account rather than on a log group. | 
|  `logs:GetQueryResults`  | Reads the results of those queries. | 
|  `logs:StopQuery`  | Stops a running query when you change the date range or filters, choose **Refresh**, or leave the tab, so that it doesn’t keep scanning. | 
|  `logs:DescribeFieldIndexes`  | Checks whether the span log groups index the session ID, so that the **Sessions** view reads less data. | 
|  `organizations:DescribeOrganization`  | Identifies your organization and its management account. | 
|  `organizations:ListAccounts`  | Shows account names next to account IDs. | 
|  `organizations:ListAWSServiceAccessForOrganization`  | Checks that trusted access for CloudWatch is turned on. | 
|  `organizations:ListDelegatedAdministrators`  | Identifies the delegated administrator for AWS Agent Registry, which can own the organization-scoped registry. | 
|  `observabilityadmin:ListCentralizationRulesForOrganization`  | Checks that a healthy centralization rule copies spans into the registry’s account. | 

Only the management account and the delegated administrator for CloudWatch can read your organization’s centralization rules. If the registry’s account is neither, the tab can’t confirm the rule. It shows a warning, and it still shows the data that has reached the account.

The [CloudWatchLogsReadOnlyAccess](https://docs.aws.amazon.com/aws-managed-policy/latest/reference/CloudWatchLogsReadOnlyAccess.html) managed policy includes the `logs` actions in the table.

The following example policy grants the permissions to view the tab. Replace `111122223333` with the ID of the account that owns the registry, and `us-west-2` with the registry’s Region:

```json
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "ReadRegistry",
      "Effect": "Allow",
      "Action": [
        "agent-registry:GetRegistry",
        "agent-registry:ListRegistryRecords"
      ],
      "Resource": "arn:aws:agent-registry:us-west-2:111122223333:registry/*"
    },
    {
      "Sid": "RunCostQueries",
      "Effect": "Allow",
      "Action": [
        "logs:StartQuery",
        "logs:DescribeFieldIndexes"
      ],
      "Resource": "arn:aws:logs:us-west-2:111122223333:log-group:*"
    },
    {
      "Sid": "FindQueryLogGroups",
      "Effect": "Allow",
      "Action": "logs:DescribeLogGroups",
      "Resource": "arn:aws:logs:us-west-2:111122223333:*"
    },
    {
      "Sid": "ReadCostQueryResults",
      "Effect": "Allow",
      "Action": [
        "logs:GetQueryResults",
        "logs:StopQuery"
      ],
      "Resource": "*"
    },
    {
      "Sid": "CheckOrganizationSetup",
      "Effect": "Allow",
      "Action": [
        "organizations:DescribeOrganization",
        "organizations:ListAccounts",
        "organizations:ListAWSServiceAccessForOrganization",
        "organizations:ListDelegatedAdministrators",
        "observabilityadmin:ListCentralizationRulesForOrganization"
      ],
      "Resource": "*"
    }
  ]
}
```

Because the queries read every Standard log group in the account that holds span events, `logs:StartQuery` applies to the account’s log groups, not only to the centralized copies. Any identity that can call `logs:StartQuery` in the account can run the same queries in the CloudWatch console. Grant access to the **Observability** tab the way that you grant access to the account’s logs.

## Permissions to set up fleet cost and usage
<a name="registry-cost-observability-permissions-setup"></a>

You need the following permissions in the management account to complete [Setting up fleet cost and usage](registry-cost-observability-setup.md). The following table lists each action and why it’s needed.


| Action | Why it’s needed | 
| --- | --- | 
|  `organizations:EnableAWSServiceAccess`  | Turns on trusted access for CloudWatch (`observabilityadmin.amazonaws.com`). | 
|  `organizations:DisableAWSServiceAccess`  | Turns off trusted access for CloudWatch. Needed only to turn it off. | 
|  `iam:CreateServiceLinkedRole`  | Creates the `AWSServiceRoleForObservabilityAdmin` service-linked role. Limit it with the `iam:AWSServiceName` condition key set to `observabilityadmin.amazonaws.com`. | 
|  `iam:GetRole`  | Checks whether the service-linked role exists. | 
|  `observabilityadmin:CreateCentralizationRuleForOrganization`  | Creates the centralization rule in CloudWatch. The management account or the delegated administrator for CloudWatch can create the rule. | 

For more information about the permissions that CloudWatch Logs centralization needs, see [Cross-account cross-Region log centralization](https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/CloudWatchLogs_Centralization.html) in the *Amazon CloudWatch Logs User Guide*.

A service control policy (SCP) in your organization can deny any of these actions even when your IAM policy allows them. If the tab reports that access was denied for an action, check your SCPs as well as your IAM policy.