> ## Documentation Index
> Fetch the complete documentation index at: https://docs-xcor.paloaltonetworks.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Ingest AWS CloudWatch metrics

> Learn how to send AWS CloudWatch metrics to Palo Alto Networks Cortex XCOR.

Palo Alto Networks Cortex XCOR receives Amazon CloudWatch metrics through
[CloudWatch Metrics Streams](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch-Metric-Streams.html).
Configure Amazon Web Services (AWS) to continuously stream metrics to Cortex XCOR
through the AWS Management Console or
[Terraform](https://docs-xcor.paloaltonetworks.com/tooling/infrastructure/terraform).

## Before you begin

Some AWS services publish metrics at intervals longer than the two-hour ingestion age
limit in Cortex XCOR. For example, Amazon S3 daily storage metrics can have timestamps
older than two hours when CloudWatch delivers them. Before streaming a metric, verify
that its publishing interval is shorter than the ingestion age limit.
Cortex XCOR can read S3 daily storage metrics from CloudWatch instead: see
[S3 daily storage metrics](#s3-daily-storage-metrics).

### Control metric volume

CloudWatch Metric Streams generate metrics that consume Standard Metrics License
capacity. Before configuring ingestion, optionally create a
[drop rule](https://docs-xcor.paloaltonetworks.com/control/shaping/shape-metrics/rules/drop-rules.md)
for unwanted metrics.

The following
[Chronoctl](https://docs-xcor.paloaltonetworks.com/tooling/chronoctl) YAML resource
definition creates a drop rule that drops all metrics from CloudWatch Metric Streams
except the `AWS/CloudWatch/MetricStreams` and `AWS/Firehose` namespaces required by
the validation dashboards.

```yaml Chronoctl example icon="square-terminal" theme={null}
api_version: v1/config
kind: DropRule
spec:
  slug: drop-cloudwatch-metric-stream-metrics
  name: Drop CloudWatch Metric Stream metrics
  mode: ENABLED
  filters:
    - name: aws_exporter_arn
      value_glob: arn:aws:cloudwatch:*
    - name: Namespace!
      value_glob: '{AWS/CloudWatch/MetricStreams,AWS/Firehose}'
```

Modify the rule to allow more metrics from other AWS namespaces. This example also
allows metrics from the AWS ECS namespace.

```yaml Chronoctl example icon="square-terminal" theme={null}
api_version: v1/config
kind: DropRule
spec:
  slug: drop-cloudwatch-metric-stream-metrics
  name: Drop CloudWatch Metric Stream metrics
  mode: ENABLED
  filters:
    - name: aws_exporter_arn
      value_glob: arn:aws:cloudwatch:*
    - name: Namespace!
      value_glob: '{AWS/CloudWatch/MetricStreams,AWS/Firehose,AWS/ECS}'
```

To reduce the AWS cost of streaming unwanted metrics, configure CloudWatch Metric
Streams to include or exclude specific namespaces:

1. In the AWS Management Console, go to **Streams**.
2. Edit the Metric Stream.
3. Under **Metrics to be streamed**, include or exclude namespaces.

## Configure CloudWatch Metric Streams

In each AWS account and region you want to collect metrics from, a CloudWatch Metric
Stream sends data to Amazon Data Firehose. The Firehose stream forwards the data to
the CloudWatch ingest endpoint in your Cortex XCOR tenant.

Cortex XCOR processes the metrics and makes them available for queries, monitors,
and dashboards.

```mermaid actions={false} theme={null}
graph LR
  accTitle: AWS CloudWatch metrics delivery
  accDescr: CloudWatch Metric Streams in AWS regions send metrics through Amazon Data Firehose to the Cortex XCOR CloudWatch ingest API.
  subgraph AWS-account
    subgraph US-EAST-2
      cms1[CloudWatch
          Metrics Stream]
      adf1[AWS Data
          Firehose]
    end
    subgraph US-WEST-2
      cms2[CloudWatch
          Metrics Stream]
      adf2[AWS Data
          Firehose]
    end
      cms1 --> adf1
      cms2 --> adf2
  end
  subgraph op[Cortex XCOR]
    subgraph Tenant
      adf3[AWS Data
          Firehose
          ingest API]
      ccp[Cortex XCOR Control
          Plane]
    end
  end
    adf3 --> ccp
    adf1 & adf2 --> adf3

classDef greenFill stroke:#60E684,fill:#2FBF71,stroke-width:2px,color:#FFFFFF
class adf3,ccp greenFill;

classDef greenFillDark stroke:#60E684,fill:#2FBF71,stroke-width:2px,color:#FFFFFF
class op greenFillDark;

classDef blueFill fill:#000243,stroke-width:2px,color:#FFFFFF
class adf1,adf2,cms1,cms2,AWS-account blueFill;

classDef orange stroke-width:2px,color:#FFFFFF,stroke:#FF9D1C
class adf1,adf2,cms1,cms2,AWS-account orange
```

### CloudWatch roles and permissions

To use CloudWatch Metric Streams in Cortex XCOR, you must configure a
CloudWatch Metric Stream in each AWS account and region. The account you use to set
up the CloudWatch Metric Stream must either have the `CloudWatchFullAccess` policy
and `iam:PassRole` permission, or it must have the following list of permissions:

* `iam:PassRole`
* `cloudwatch:PutMetricStream`
* `cloudwatch:DeleteMetricStream`
* `cloudwatch:GetMetricStream`
* `cloudwatch:ListMetricStreams`
* `cloudwatch:StartMetricStreams`
* `cloudwatch:StopMetricStreams`
* `iam:CreateRole`
* `iam:PutRolePolicy`

### Cortex XCOR authentication

Create or use an API token for a Cortex XCOR restricted service account with
write-only permission. For more information, see
[Create a restricted service account](https://docs-xcor.paloaltonetworks.com/administer/accounts-teams/service-accounts.md#create-a-restricted-service-account).

You must also provide your Cortex XCOR organization name. This is the `<ORG_NAME>`
segment in `https://<ORG_NAME>.chronosphere.io`.

### AWS resources and IAM roles

The setup creates the following resources and Identity and Access Management (IAM)
roles:

#### AWS resources

* Amazon S3 bucket: Stores eligible failed deliveries from Amazon Data Firehose.
* CloudWatch log group: Stores logs from the Firehose stream.
* Amazon Data Firehose stream: Sends metrics to Cortex XCOR through an HTTP
  endpoint and stores eligible failed deliveries in the S3 bucket.
* IAM role for Amazon Data Firehose: Grants the Firehose stream these permissions
  to access the S3 bucket and CloudWatch Logs:
  * `s3:AbortMultipartUpload`
  * `s3:GetBucketLocation`
  * `s3:GetObject`
  * `s3:ListBucket`
  * `s3:ListBucketMultipartUploads`
  * `s3:PutObject`
  * `logs:PutLogEvents`

#### IAM roles

The setup also creates an IAM role with these permissions so CloudWatch Metric Streams
can publish data to the Firehose stream:

* `firehose:PutRecord`
* `firehose:PutRecordBatch`

### Apply the configuration

Choose the Terraform or AWS Management Console setup.

> [tab] Terraform
>
> 1. Set values for the following
>    [Terraform](https://docs-xcor.paloaltonetworks.com/tooling/infrastructure/terraform)
>    variables, and then apply the configuration.
>
>    ```terraform expandable Terraform example icon="square-terminal" theme={null}
>    # Variables
>
>    variable "chronosphere_org_name" {
>      type        = string
>      description = "The name of your Cortex XCOR organization, which is the subdomain name before .chronosphere.io."
>    }
>
>    variable "chronosphere_api_token" {
>      type        = string
>      sensitive   = true
>      description = "The API token for a Cortex XCOR Restricted Service Account with write-only permission."
>    }
>
>    variable "failed_data_bucket_name" {
>      type        = string
>      description = "The name of the S3 bucket to create to store data that couldn't be delivered to Cortex XCOR. If not specified, a random name will be generated."
>      default     = ""
>    }
>
>    variable "common_resource_attributes" {
>      type        = map(string)
>      description = "Key-value pairs to apply as OpenTelemetry Resource Attributes on all metrics in this stream."
>      default     = {}
>    }
>
>    # IAM Policy Documents
>
>    data "aws_iam_policy_document" "kinesis-firehose-stream-role-trust-policy" {
>      statement {
>        sid     = "AllowRoleAssumptionByKinesisFirehose"
>        effect  = "Allow"
>        actions = ["sts:AssumeRole"]
>
>        principals {
>          type        = "Service"
>          identifiers = ["firehose.amazonaws.com"]
>        }
>      }
>    }
>
>    data "aws_iam_policy_document" "kinesis-firehose-stream-role-s3-policy" {
>      statement {
>        sid     = "AllowFirehoseS3Access"
>        effect  = "Allow"
>        actions = [
>          "s3:AbortMultipartUpload",
>          "s3:GetBucketLocation",
>          "s3:GetObject",
>          "s3:ListBucket",
>          "s3:ListBucketMultipartUploads",
>          "s3:PutObject"
>        ]
>
>        resources = [
>          aws_s3_bucket.kinesis-firehose-stream-failed-data.arn,
>          "${aws_s3_bucket.kinesis-firehose-stream-failed-data.arn}/*"
>        ]
>      }
>
>      statement {
>        sid       = "AllowFirehoseCloudWatchLogs"
>        effect    = "Allow"
>        actions   = ["logs:PutLogEvents"]
>        resources = ["${aws_cloudwatch_log_group.kinesis-firehose-stream.arn}:*"]
>      }
>    }
>
>    data "aws_iam_policy_document" "cloudwatch-metric-stream-role-trust-policy" {
>      statement {
>        sid     = "AllowRoleAssumptionByCloudWatchMetricStream"
>        effect  = "Allow"
>        actions = ["sts:AssumeRole"]
>
>        principals {
>          type        = "Service"
>          identifiers = ["streams.metrics.cloudwatch.amazonaws.com"]
>        }
>      }
>    }
>
>    data "aws_iam_policy_document" "cloudwatch-metric-stream-role-firehose-policy" {
>      statement {
>        sid    = "AllowCloudWatchFirehoseAccess"
>        effect = "Allow"
>        actions = [
>          "firehose:PutRecord",
>          "firehose:PutRecordBatch"
>        ]
>
>        resources = [
>          aws_kinesis_firehose_delivery_stream.kinesis-firehose-stream.arn
>        ]
>      }
>    }
>
>    # S3
>
>    resource "random_id" "default_bucket_name_suffix" {
>      byte_length = 8
>    }
>
>    resource "aws_s3_bucket" "kinesis-firehose-stream-failed-data" {
>      bucket = var.failed_data_bucket_name != "" ? var.failed_data_bucket_name : "chronosphere-cw-stream-failed-data-${random_id.default_bucket_name_suffix.hex}"
>    }
>
>    resource "aws_s3_bucket_public_access_block" "kinesis-firehose-stream-failed-data" {
>      bucket                  = aws_s3_bucket.kinesis-firehose-stream-failed-data.id
>      block_public_acls       = true
>      block_public_policy     = true
>      ignore_public_acls      = true
>      restrict_public_buckets = true
>    }
>
>    resource "aws_s3_bucket_server_side_encryption_configuration" "kinesis-firehose-stream-failed-data" {
>      bucket = aws_s3_bucket.kinesis-firehose-stream-failed-data.id
>
>      rule {
>        apply_server_side_encryption_by_default {
>          sse_algorithm = "AES256"
>        }
>
>        bucket_key_enabled = false
>      }
>    }
>
>    resource "aws_s3_bucket_lifecycle_configuration" "kinesis-firehose-stream-failed-data" {
>      bucket = aws_s3_bucket.kinesis-firehose-stream-failed-data.id
>
>      rule {
>        id = "Cleanup"
>
>        expiration {
>          days = 90
>        }
>
>        status = "Enabled"
>      }
>    }
>
>    # CloudWatch Logs
>
>    resource "aws_cloudwatch_log_group" "kinesis-firehose-stream" {
>      name              = "/aws/kinesisfirehose/chronosphere-cloudwatch-firehose"
>      retention_in_days = 14
>    }
>
>    resource "aws_cloudwatch_log_stream" "kinesis-firehose-stream" {
>      name           = "HttpEndpointDelivery"
>      log_group_name = aws_cloudwatch_log_group.kinesis-firehose-stream.name
>    }
>
>    # Kinesis Firehose Delivery Stream
>
>    resource "aws_iam_role" "kinesis-firehose-stream-role" {
>      name               = "cloudwatch-firehose-stream-role"
>      assume_role_policy = data.aws_iam_policy_document.kinesis-firehose-stream-role-trust-policy.json
>
>      tags = {
>        Name = "cloudwatch-firehose-stream-role"
>      }
>    }
>
>    resource "aws_iam_role_policy" "kinesis-firehose-stream-role-s3-policy" {
>      name   = "KinesisFirehose-S3Access"
>      role   = aws_iam_role.kinesis-firehose-stream-role.id
>      policy = data.aws_iam_policy_document.kinesis-firehose-stream-role-s3-policy.json
>    }
>
>    resource "aws_kinesis_firehose_delivery_stream" "kinesis-firehose-stream" {
>      name        = "chronosphere-cloudwatch-firehose"
>      destination = "http_endpoint"
>
>      http_endpoint_configuration {
>        name               = "chronosphere-http-endpoint"
>        url                = "https://${var.chronosphere_org_name}.chronosphere.io/data/metrics/api/v1/cloudwatch/firehose"
>        access_key         = var.chronosphere_api_token
>        buffering_size     = 1  # MiB
>        buffering_interval = 60 # seconds
>        role_arn           = aws_iam_role.kinesis-firehose-stream-role.arn
>        s3_backup_mode     = "FailedDataOnly"
>        retry_duration     = 300 # seconds
>
>        s3_configuration {
>          role_arn           = aws_iam_role.kinesis-firehose-stream-role.arn
>          bucket_arn         = aws_s3_bucket.kinesis-firehose-stream-failed-data.arn
>          buffering_size     = 10  # MiB
>          buffering_interval = 300 # seconds
>          compression_format = "GZIP"
>        }
>
>        request_configuration {
>          content_encoding = "GZIP"
>
>          dynamic "common_attributes" {
>            for_each = var.common_resource_attributes
>            iterator = attribute
>            content {
>              name  = attribute.key
>              value = attribute.value
>            }
>          }
>        }
>
>        cloudwatch_logging_options {
>          enabled         = true
>          log_group_name  = aws_cloudwatch_log_group.kinesis-firehose-stream.name
>          log_stream_name = aws_cloudwatch_log_stream.kinesis-firehose-stream.name
>        }
>      }
>
>      server_side_encryption {
>        enabled = true
>      }
>    }
>
>    # CloudWatch Metric Stream
>
>    resource "aws_iam_role" "cloudwatch-metric-stream-role" {
>      name               = "cloudwatch-metric-stream-role"
>      assume_role_policy = data.aws_iam_policy_document.cloudwatch-metric-stream-role-trust-policy.json
>
>      tags = {
>        Name = "cloudwatch-metric-stream-role"
>      }
>    }
>
>    resource "aws_iam_role_policy" "cloudwatch-metric-stream-role-firehose-policy" {
>      name   = "MetricStreams-FirehosePutRecords"
>      role   = aws_iam_role.cloudwatch-metric-stream-role.id
>      policy = data.aws_iam_policy_document.cloudwatch-metric-stream-role-firehose-policy.json
>    }
>
>    resource "aws_cloudwatch_metric_stream" "cloudwatch-metric-stream" {
>      name          = "chronosphere-cloudwatch-metric-stream"
>      role_arn      = aws_iam_role.cloudwatch-metric-stream-role.arn
>      firehose_arn  = aws_kinesis_firehose_delivery_stream.kinesis-firehose-stream.arn
>      output_format = "opentelemetry1.0"
>    }
>    ```

> [tab] AWS Management Console
>
> To configure CloudWatch Metric Streams using the AWS Management Console:
>
> 1. Open the [CloudWatch console](https://console.aws.amazon.com/cloudwatch/).
> 2. In the navigation pane, go to **Metrics > Streams**.
> 3. Select **Create metric stream**.
> 4. Select **Custom setup with Firehose**.
> 5. To create an Amazon Data Firehose stream, select **Set up an Amazon Data Firehose stream**
>    under **Select your Amazon Data Firehose stream**.
> 6. In **Create Firehose Stream**, set the following options:
>    * **Set source:** `Direct PUT`
>    * **Destination:** `HTTP Endpoint`
>    * **Firehose stream name:** `chronosphere-cloudwatch-firehose`
>    * **Destination settings:**
>      * **HTTP endpoint name:** `Cortex XCOR CloudWatch Endpoint`
>      * **HTTP endpoint URL:** `https://<ORG_NAME>.chronosphere.io/data/metrics/api/v1/cloudwatch/firehose`.
>        Replace `<ORG_NAME>` with your Cortex XCOR organization name.
>      * **Authentication:** `Use access key`
>      * **Access key:** Enter your Cortex XCOR Restricted Service Account's
>        API token.
>      * **Content encoding:** `GZIP`
>      * **Retry duration:** `300 seconds`
>      * Expand **Buffering Hints**.
>        * **Buffer size:** `1 MiB`
>        * **Buffer interval:** `60 seconds`
>    * **Backup settings:**
>      * **Source record backup in Amazon S3:** `Failed data only`
>      * **S3 backup bucket:** Select a bucket, or create a new bucket. If you create
>        a new bucket, provide a unique name and leave all default settings.
>      * Expand **Buffer hints, compression and encryption**.
>        * **Buffer size:** `10 MiB`
>        * **Buffer interval:** `300 seconds`
>        * **Compression for data records:** `GZIP`
> 7. Select **Create Firehose stream**.
> 8. Return to **Create a metric stream**.
> 9. In **Select your Amazon Data Firehose stream**, select `chronosphere-cloudwatch-firehose`.
>    This is the Amazon Data Firehose stream you created previously.
> 10. Expand **Change output format** and verify that the output format is
>     `OpenTelemetry 1.0`.
> 11. Under **Metrics to be streamed**, select **All metrics** to stream all CloudWatch
>     metrics, or **Select metrics** to define which metrics to include or exclude in
>     the metrics stream.
> 12. Set the **Custom metric stream name** to `chronosphere-cloudwatch-metric-stream`.
> 13. Select **Create metric stream**.

## Validate CloudWatch Metric Stream ingestion

After setup, wait for data to arrive in Cortex XCOR. Validate ingestion with the
operational dashboards in Cortex XCOR and the AWS Management Console.

> [!NOTE]
>
> The included dashboards query the default CloudWatch metric names. For tenants
> configured for Datadog-compatible naming, validate the `snake_case` metric names in
> Metrics Explorer.

The integration also includes a Metrics Overview dashboard that shows CloudWatch Metric Streams
delivery volume and publish errors by account, region, and stream. It's available from the
Amazon Web Services integration in the Integrations Hub.

### Validate the CloudWatch Metrics Ingestion & Health dashboard

The CloudWatch Metrics Ingestion & Health dashboard displays operational information
about the health of your CloudWatch Metrics Streams integration with Cortex XCOR.

The CloudWatch Metric Streams and Data Firehose panel groups rely on
CloudWatch metrics sent from those services to Cortex XCOR. To populate
these charts, include metrics from the `AWS/Firehose` and
`AWS/CloudWatch/MetricStreams` namespaces in your CloudWatch Metrics Streams
configuration.

1. In Cortex XCOR, go to **Dashboards**.

2. In the search bar, enter **CloudWatch**, and then select the
   **CloudWatch Metrics Ingestion & Health** dashboard.

   The metrics ingestion panel group displays information about the CloudWatch
   metrics Cortex XCOR received.

3. Use the **Data Firehose records received by Amazon Resource Name** chart to
   confirm that the ingestion API received Data Firehose records.

4. Use the **CloudWatch metric updates received** chart to confirm the number of
   CloudWatch metric updates Cortex XCOR extracts from the Data Firehose
   records.

5. Confirm that the **Transformed metrics** chart shows no **Rejected Data Points**.

6. Use the **Unique time series by AWS metric namespace** chart to confirm that
   metrics from the AWS namespaces you want are in the stream that Cortex XCOR received.

### Validate the Metric Stream dashboard

In the AWS Management Console, use the **Metric Updates** chart for specific
metrics to validate that metrics are streaming.

1. In the AWS Management Console, go to
   **CloudWatch > Metric Streams**.
2. Select `chronosphere-cloudwatch-metric-stream` to view the status and operational
   statistics.
3. Verify that the **Status** is `Running`.
4. Verify how many updates have been sent in the **Metric Updates** chart. If the
   stream is working, the chart should report a non-zero number of updates.
5. Verify whether any errors were reported in the **Errors** chart. The value should
   be 0.

### Validate the Amazon Data Firehose status

In the AWS Management Console, use the Firehose charts to validate that metrics are
streaming.

1. In the AWS Management Console, go to
   **Amazon Data Firehose > Firehose Streams**.
2. Select `chronosphere-cloudwatch-firehose` to view status and operational statistics
   for the Amazon Data Firehose.
3. The **Incoming bytes**, **Incoming put requests**, and **Incoming records** charts
   should all report non-zero values.
4. The **HTTP endpoint delivery success** chart should report 100%.
5. The **Records delivered to HTTP endpoint** chart should report a non-zero value.

### Query metrics about AWS CloudWatch Metric Streams

Query metrics about AWS CloudWatch Metric Streams in Cortex XCOR. These metrics won't
appear in the Cortex XCOR Metrics Explorer
if you've defined a drop rule to drop all AWS metrics. Modify the rule to allow some
metrics, such as all metrics from the `AWS/CloudWatch/MetricStreams` namespace. For
examples, see [Control metric volume](#control-metric-volume).

1. In Cortex XCOR, go to
   ** Explorers > Metrics Explorer**.
2. In the query box, enter `aws_cloudwatch_metricstreams` to view a list of AWS
   metrics received from the CloudWatch Metric Stream.
3. Select the metric you want to query to add it to the query prompt.

Write a query around the selected metric. For default metric naming, run this query
to report the rate of CloudWatch metric updates:

```text theme={null}
rate(aws_cloudwatch_metricstreams_MetricUpdate_sum[5m])
```

For Datadog-compatible metric naming, run:

```text theme={null}
rate(aws_cloudwatch_metricstreams_metric_update_sum[5m])
```

## Metric semantics

### Metric naming conventions

Metric names of ingested CloudWatch metrics in Cortex XCOR follow the
prefix naming pattern:

```text theme={null}
<namespace>_<MetricName>_<statistic>
```

* `<namespace>`: The namespace is lowercased, and Cortex XCOR replaces
  all forward slash (`/`) and period (`.`) characters in the CloudWatch namespace
  with underscores (`_`).

  All AWS service namespaces follow the naming convention `AWS/<ServiceName>`, where
  `<ServiceName>` is replaced with the service name. In Cortex XCOR,
  the ingested metrics therefore begin with `aws_<servicename>`. For a list of AWS
  services and their respective namespaces, see
  [AWS services that publish CloudWatch metrics](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/aws-services-cloudwatch-metrics.html).

  If you create custom metrics, the namespace you set for the metric becomes the
  metric name prefix in Cortex XCOR.
* `<MetricName>`: By default, Cortex XCOR preserves the CloudWatch metric name's
  case. Tenants configured for Datadog-compatible naming receive the metric name in
  `snake_case`.
* `<statistic>`: Cortex XCOR appends the CloudWatch statistic's name
  (`count`, `sum`, `maximum`, `minimum`, `average`). If you define additional statistics
  for a metric, Cortex XCOR appends the corresponding CloudWatch metric
  statistic name (`pXX`).

For examples, see [Example metric names](#example-metric-names).

### Metric labeling conventions

Cortex XCOR adds CloudWatch metric dimensions as labels to the time series
following the pattern `dimension_<DimensionName>`. For examples, see
[Example metric names](#example-metric-names).

### Stream resource attributes

CloudWatch Metric Streams include OpenTelemetry Protocol (OTLP) resource attributes,
which Cortex XCOR merges into the time series. Cortex XCOR
replaces periods (`.`) with underscores (`_`) in attribute key names.

Amazon Data Firehose includes the following resource attributes in every post:

* `aws_exporter_arn`: The Amazon Resource Name (ARN) of the CloudWatch Metric Stream,
  which uniquely identifies the metric writer instance.
* `cloud_account_id`: The AWS account associated with the CloudWatch Metric Stream,
  such as `123456789012`.
* `cloud_provider`: The value is always `aws`.
* `cloud_region`: The AWS region of the Amazon Data Firehose sending the stream,
  such as `us-east-2`.

For examples, see [Example metric names](#example-metric-names).

#### Add custom resource attributes using stream parameters

Define custom key-value pairs as parameters for Amazon Data Firehose to include in
each HTTP request. Cortex XCOR treats all additional parameters
as resource attributes and merges them into the time series.

> [!NOTE]
>
> Your custom parameters take precedence over the default CloudWatch metrics resource
> attributes. Avoid parameter names that conflict with default CloudWatch attribute
> names.

Configure additional parameters through Terraform or the AWS Management Console.

> [tab] Terraform
>
> To configure parameters using Terraform:
>
> 1. Edit the Terraform module.
> 2. In the `aws_kinesis_firehose_delivery_stream` resource definition, modify the
>    `request_configuration` block to define additional `common_attributes`. The
>    AWS Management Console names this setting **Parameters**, while the API name is
>    `common_attributes`.
>
>    The following example configures the `content_encoding` parameter as `GZIP` and
>    defines two `common_attributes`, `testname` and `testname2`:
>
>    ```terraform Terraform example icon="square-terminal" theme={null}
>    request_configuration {
>      content_encoding = "GZIP"
>
>      common_attributes {
>        name  = "testname"
>        value = "testvalue"
>      }
>
>      common_attributes {
>        name  = "testname2"
>        value = "testvalue2"
>      }
>    }
>    ```

> [tab] AWS Management Console
>
> To configure parameters using the AWS Management Console:
>
> 1. Navigate to the Amazon Data Firehose service.
> 2. Select the stream sending CloudWatch metrics
>    (`chronosphere-cloudwatch-firehose`).
> 3. Select the **Configuration** tab in the Firehose stream details view.
> 4. In the **Destination settings** panel, select **Add parameters**.
> 5. In the **Edit destination settings** view, select **Add parameter**.
> 6. Enter the key and value. To add more parameters, select **Add parameter**.
> 7. Select **Save changes**.

### Example metric names

Given a CloudWatch metric with the following attributes:

* The namespace `AWS/EBS` (AWS Service)
* The metric name `VolumeReadBytes`
* The dimension `VolumeId`
* The custom Firehose destination parameter `environment`
* The CloudWatch metric resource attributes `aws_exporter_arn`, `cloud_account_id`,
  `cloud_provider`, and `cloud_region`

Cortex XCOR creates metrics with these names and labels:

```text theme={null}
aws_ebs_VolumeReadBytes_count{dimension_VolumeId="xyz", aws_exporter_arn="abc123", cloud_account_id="123456789012", cloud_provider="aws", cloud_region="us-east-2", environment="staging"}
aws_ebs_VolumeReadBytes_sum{dimension_VolumeId="xyz", aws_exporter_arn="abc123", cloud_account_id="123456789012", cloud_provider="aws", cloud_region="us-east-2", environment="staging"}
aws_ebs_VolumeReadBytes_maximum{dimension_VolumeId="xyz", aws_exporter_arn="abc123", cloud_account_id="123456789012", cloud_provider="aws", cloud_region="us-east-2", environment="staging"}
aws_ebs_VolumeReadBytes_minimum{dimension_VolumeId="xyz", aws_exporter_arn="abc123", cloud_account_id="123456789012", cloud_provider="aws", cloud_region="us-east-2", environment="staging"}
aws_ebs_VolumeReadBytes_average{dimension_VolumeId="xyz", aws_exporter_arn="abc123", cloud_account_id="123456789012", cloud_provider="aws", cloud_region="us-east-2", environment="staging"}
```

Given a CloudWatch metric with the following attributes:

* The namespace `Buildkite` (custom metrics)
* The metric name `RunningJobsCount`
* The custom Firehose destination parameter `environment`
* No dimension
* CloudWatch resource metric attributes `aws_exporter_arn`, `cloud_account_id`,
  `cloud_provider`, and `cloud_region`

Cortex XCOR creates metrics with these names and labels:

```text theme={null}
buildkite_RunningJobsCount_count{aws_exporter_arn="abc123", cloud_account_id="123456789012", cloud_provider="aws", cloud_region="us-east-2", environment="staging"}
buildkite_RunningJobsCount_sum{aws_exporter_arn="abc123", cloud_account_id="123456789012", cloud_provider="aws", cloud_region="us-east-2", environment="staging"}
buildkite_RunningJobsCount_maximum{aws_exporter_arn="abc123", cloud_account_id="123456789012", cloud_provider="aws", cloud_region="us-east-2", environment="staging"}
buildkite_RunningJobsCount_minimum{aws_exporter_arn="abc123", cloud_account_id="123456789012", cloud_provider="aws", cloud_region="us-east-2", environment="staging"}
buildkite_RunningJobsCount_average{aws_exporter_arn="abc123", cloud_account_id="123456789012", cloud_provider="aws", cloud_region="us-east-2", environment="staging"}
```

## S3 daily storage metrics

Amazon S3 publishes its daily storage metrics, `BucketSizeBytes` and
`NumberOfObjects`, to CloudWatch once a day, and they don't arrive in Cortex
XCOR through CloudWatch Metric Streams. Cortex XCOR can read them from
CloudWatch in your AWS accounts instead, with the same AWS read role it uses to
read your resource tags.

> [!NOTE]
>
> Cortex XCOR Support turns on these reads for your tenant. To request them, contact
> [Cortex XCOR Support](https://docs-xcor.paloaltonetworks.com/support.md).

When Cortex XCOR Support turns on these reads, it also excludes both metrics
from the aggregation recommendations for your tenant, because their values
arrive after the window aggregation uses.

### Prerequisites for S3 daily storage metrics

Cortex XCOR reads the AWS accounts and regions where it reads your AWS resource
tags directly from AWS. Each account needs the Cortex XCOR AWS read role at
template version 1.1.0 or later, which grants the read-only
`cloudwatch:ListMetrics` and `cloudwatch:GetMetricData` actions these reads use.

* AWS bills `GetMetricData` requests to your account per metric requested. Cortex
  XCOR requests each bucket's metrics once or twice a day.
* S3 publishes a bucket's storage metrics only in the bucket's own region. Cortex
  XCOR reads no buckets in a region it doesn't read your resource tags in.

### S3 daily storage metric names

| Metric | Value | Unit |
| - | - | - |
| `aws_s3_bucket_size_bytes_average` | The data a bucket stores in one storage class, from `BucketSizeBytes` with the `Average` statistic. | Bytes |
| `aws_s3_number_of_objects_average` | The objects a bucket stores in every storage class, from `NumberOfObjects` with the `Average` statistic. | Count |

Each time series has these labels:

* `bucketname`: The bucket's name.
* `storagetype`: The storage class, such as `StandardStorage` or
  `GlacierStorage`. For `aws_s3_number_of_objects_average`, it's always
  `AllStorageTypes`.
* `Namespace` (always `AWS/S3`), `cloud_provider` (always `aws`),
  `cloud_account_id` and `cloud_region`.
* `aws_account_alias`: The alias Cortex XCOR Support set for the account, or
  else its AWS account alias. It's absent if the account has neither, or if the
  account's read role isn't allowed `iam:ListAccountAliases`, which read role
  template 1.2.0 grants.
* The bucket's resource tags, where Cortex XCOR reads them.

These time series don't have `dimension_*` labels or the stream resource
attributes that streamed metrics have.

### S3 daily storage timestamps

Cortex XCOR writes each UTC day's value with a timestamp one hour after the day
ends. For example, the value for November 16 has the timestamp November 17,
01:00 UTC. CloudWatch timestamps the same value at the start of its day, so
the CloudWatch console shows it a day earlier than Cortex XCOR does.

Cortex XCOR reads each day once or twice between about 01:05 and 03:00 UTC the
next day. After Cortex XCOR Support turns on these reads, the first value
arrives between about 01:05 and 02:05 UTC the next day, for the day that was in
progress when they were turned on. If they're turned on before about 03:00 UTC,
Cortex XCOR might also write the value for the day before. It doesn't write
values for earlier days.

If AWS publishes a day's value later than about 01:55 UTC the next day, the
day might be missing. If AWS changes a day's value after that, Cortex XCOR keeps
the value it read.

### Query S3 daily storage metrics

Each value has one data point a day, so queries need a lookback of more than a
day:

* To show each day's value at the end of its day in a time series panel, and to
  line it up with other metrics, add `offset -1h` to the selector:

  ```text theme={null}
  sum by (bucketname) (aws_s3_bucket_size_bytes_average{storagetype="StandardStorage"} offset -1h)
  ```

* To show the latest value in a stat panel, a table, or a monitor, use
  `last_over_time` over 27 hours, with no offset. A day's value can arrive up
  to about two hours after its timestamp, so a window of one day returns no
  data each day from 01:00 UTC until that day's value arrives. An instant query
  without `last_over_time` returns no data for most of each day.

  ```text theme={null}
  sum by (bucketname) (last_over_time(aws_s3_bucket_size_bytes_average{storagetype="StandardStorage"}[27h]))
  ```

### Validate S3 daily storage ingestion

After 03:10 UTC on the day after Cortex XCOR Support turns on these reads, run
this query. It returns the number of buckets with a value in the last 27 hours:

```text theme={null}
count(last_over_time(aws_s3_number_of_objects_average[27h]))
```

## Monitor drop rules

To view the number of data points per second that Cortex XCOR drops with the example
CloudWatch Metric Streams drop rule, use the following PromQL query:

```text theme={null}
sum by (policy_name) (rate(chrono_policies_count{dropped="yes", policy_name="Drop CloudWatch Metric Stream metrics"}[5m]))
```


## Related topics

- [Amazon CloudWatch Logs and Metrics destination plugin](https://docs-xcor.paloaltonetworks.com/ingest/pipeline/plugins/destination-plugins/amazon-cloudwatch.md)
- [Cortex XCOR-managed dashboards](https://docs-xcor.paloaltonetworks.com/observe/dashboards/managed-dashboards.md)
- [Ingest metric and trace data](https://docs-xcor.paloaltonetworks.com/ingest/metrics-traces.md)
- [Integrate with Cortex XCOR](https://docs-xcor.paloaltonetworks.com/integrate.md)
- [Ingest AWS logs](https://docs-xcor.paloaltonetworks.com/ingest/xcor/integrations/server/aws/logs.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.