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

# AWS X-Ray

> Configuring the AWS X-Ray backend (Managed)

### Getting Started

<img src="https://d15jtxgb40qetw.cloudfront.net/awsxray.svg" alt="xray" className="not-prose h-20" />

<Warning>
  Make sure that you have the necessary `AWS Credentials` and permissions set up.<br />
  AWS credentials are retrieved from the [default credential chain](https://docs.aws.amazon.com/sdk-for-go/v1/developer-guide/configuring-sdk.html#specifying-credentials).
</Warning>

**Setting up AWS credentials with AWS EKS (Elastic Kubernetes Service)**

The following command will create a link between your EKS cluster and your IAM account, effectively allowing the EKS cluster to assume IAM roles and access AWS services.

Replace `$EKS_CLUSTER_REGION` with the region of your EKS cluster and `$EKS_CLUSTER_NAME` with the name of your EKS cluster (or set them as environment variables).

```bash theme={null}
eksctl utils associate-iam-oidc-provider --region=$EKS_CLUSTER_REGION --cluster=$EKS_CLUSTER_NAME --approve
```

**Setting up the IAM policy**

```json theme={null}
{
  "Version": "2012-10-17",
  "Statement": {
    "Effect": "Allow",
    "Action": [
      "xray:PutTraceSegments",
      "xray:PutTelemetryRecords"
    ],
    "Resource": [
      "*"
    ]
  }
}
```

### Configuring Destination Fields

<Accordion title="Supported Signals:">
  ✅ Traces
  ❌ Metrics
  ❌ Logs
  ❌ Profiles
</Accordion>

* **AWS\_XRAY\_REGION** `string` : Region. Send segments to AWS X-Ray service in a specific region.
  * This field is optional
* **AWS\_XRAY\_ENDPOINT** `string` : Endpoint. Optionally override the default X-Ray service endpoint.
  * This field is optional
* **AWS\_XRAY\_PROXY\_ADDRESS** `string` : Proxy Address. Upload segments to AWS X-Ray through a proxy.
  * This field is optional
* **AWS\_XRAY\_RESOURCE\_ARN** `string` : Resource ARN. Amazon Resource Name (ARN) of the AWS resource running the collector.
  * This field is optional
* **AWS\_XRAY\_ROLE\_ARN** `string` : Role ARN. IAM role to upload segments to a different account.
  * This field is optional
* **AWS\_XRAY\_EXTERNAL\_ID** `string` : External ID. Shared identitier used when assuming an IAM role in an external AWS account.
  * This field is optional
* **AWS\_XRAY\_LOG\_GROUPS** `string[]` : Log Groups. List of log group names for CloudWatch.
  * This field is optional
* **AWS\_XRAY\_DISABLE\_SSL** `boolean` : Disable SSL Verification. Enable or disable TLS certificate verification.
  * This field is optional and defaults to `False`
* **AWS\_XRAY\_LOCAL\_MODE** `boolean` : Local Mode. Local mode to skip EC2 instance metadata check.
  * This field is optional and defaults to `False`
* **AWS\_XRAY\_TELEMETRY\_ENABLED** `boolean` : Telemetry - Enabled. Whether telemetry collection is enabled at all.
  * This field is optional and defaults to `False`
* **AWS\_XRAY\_TELEMETRY\_INCLUDE\_METADATA** `boolean` : Telemetry - Include Metadata. Whether to include metadata in the telemetry (InstanceID, Hostname, ResourceARN)
  * This field is optional and defaults to `False`
* **AWS\_XRAY\_TELEMETRY\_HOSTNAME** `string` : Telemetry - Hostname. Sets the Hostname included in the telemetry.
  * This field is optional
* **AWS\_XRAY\_TELEMETRY\_INSTANCE\_ID** `string` : Telemetry - Instance ID. Sets the InstanceID included in the telemetry.
  * This field is optional
* **AWS\_XRAY\_TELEMETRY\_RESOURCE\_ARN** `string` : Telemetry - Resource ARN. Sets the Amazon Resource Name (ARN) included in the telemetry.
  * This field is optional
* **AWS\_XRAY\_TELEMETRY\_CONTRIBUTORS** `string[]` : Telemetry - Contributors. List of X-Ray component IDs contributing to the telemetry (ex. for multiple X-Ray receivers: awsxray/1, awsxray/2)
  * This field is optional
* **AWS\_XRAY\_INDEX\_ALL\_ATTRIBUTES** `boolean` : Index All Attributes. Enable or disable conversion of all OpenTelemetry attributes to X-Ray annotations.
  * This field is optional and defaults to `False`
* **AWS\_XRAY\_INDEXED\_ATTRIBUTES** `string[]` : Indexed Attributes. List of attribute names to be converted to X-Ray annotations.
  * This field is optional

<Note>
  **Traces and logs correlation**

  AWS X-Ray can be integrated with CloudWatch Logs to correlate traces with logs.

  For this integration to work, the X-Ray segments must have the AWS Property `cloudwatch_logs` set. This property is set using the AWS X-Ray exporter with the following values that are evaluated in this order:

  1. `aws.log.group.arns` resource attribute.
  2. `aws.log.group.names` resource attribute.
  3. `aws_log_groups` configuration property.

  `aws.log.group.arns` and `aws.log.group.names` are slice resource attributes, alternatively those resource attributes can be set using the [OTEL\_RESOURCE\_ATTRIBUTES environment variable](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/resource/sdk.md#specifying-resource-information-via-an-environment-variable).

  To set multiple log group names / log group arns, you can use `&` to separate them.<br />
  For example 3 log groups: `log-group1`, `log-group2`, and `log-group3` are set in the following command:

  ```bash theme={null}
  export OTEL_RESOURCE_ATTRIBUTES="aws.log.group.names=log-group1&log-group2&log-group3"
  ```
</Note>

### Adding Destination to Odigos

There are two primary methods for configuring destinations in Odigos:

##### **Using the UI**

<Steps>
  <Step>
    Use the [Odigos CLI](https://docs.odigos.io/cli/odigos_ui) to access the UI

    ```bash theme={null}
    odigos ui
    ```
  </Step>

  <Step>
    Click on `Add Destination`, select `AWS X-Ray` and follow the on-screen instructions
  </Step>
</Steps>

##### **Using Kubernetes manifests**

<Steps>
  <Step>
    Save the YAML below to a file (e.g. `xray.yaml`)

    ```yaml theme={null}
    apiVersion: odigos.io/v1alpha1
    kind: Destination
    metadata:
      name: xray-example
      namespace: odigos-system
    spec:
      data: {}
      destinationName: xray
      signals:
      - TRACES
      type: xray
    ```
  </Step>

  <Step>
    Apply the YAML using `kubectl`

    ```bash theme={null}
    kubectl apply -f xray.yaml
    ```
  </Step>
</Steps>
