# DataSourceConfig

Configuration for the data source used in online evaluation.

Use the static factory methods to create data source configurations:
- `DataSourceConfig.fromAgentRuntimeEndpoint()` for AgentCore Runtime (recommended)
- `DataSourceConfig.fromAgentRuntimeEndpointName()` for AgentCore Runtime using endpoint name string
- `DataSourceConfig.fromCloudWatchLogs()` for external agents or custom log groups

- Source: [`aws-bedrockagentcore/lib/evaluation/data-source.ts`](https://github.com/aws/aws-cdk/blob/v2.275.0/packages/aws-cdk-lib/aws-bedrockagentcore/lib/evaluation/data-source.ts#L45)
- Type last changed: v2.255.0 · 19 May 2026

## Example

```ts
// CloudWatch Logs data source (for external agents)
const dataSource = agentcore.DataSourceConfig.fromCloudWatchLogs({
  logGroupNames: ['/aws/my-external-agent/logs'],
  serviceNames: ['my-external-agent'],
});
```

## Properties

- `cloudWatchLogsConfig`: [CloudWatchLogsDataSourceConfig](/cdk/api/v2/docs/aws-cdk-lib.aws_bedrockagentcore.CloudWatchLogsDataSourceConfig.html) — The CloudWatch Logs configuration.

## Methods

- `bind(): DataSourceConfigBindResult` — Binds the data source configuration to produce the L1 property.

- `fromAgentRuntimeEndpoint(runtime: IBedrockAgentRuntime, endpoint?: IRuntimeEndpoint): DataSourceConfig // chainable` (static) — Creates a data source configuration from an AgentCore Runtime and optional endpoint.

  This is the recommended way to configure evaluation for AgentCore Runtime agents.
  It automatically derives the CloudWatch log group and service name from the runtime and endpoint.

  **Parameters**

  - `runtime` — - The AgentCore Runtime construct.
  - `endpoint` — - The RuntimeEndpoint construct.

  **Returns:** A DataSourceConfig instance

  ```ts
  // Using a specific endpoint
  declare const runtime: agentcore.Runtime;
  const endpoint = runtime.addEndpoint('PROD');
  const dataSource = agentcore.DataSourceConfig.fromAgentRuntimeEndpoint(runtime, endpoint);
  ```

- `fromAgentRuntimeEndpointName(runtime: IBedrockAgentRuntime, endpointName: string): DataSourceConfig // chainable` (static) — Creates a data source configuration from an AgentCore Runtime and an endpoint name string.

  Use this method when you want to reference an endpoint by name without
  having a construct reference. For construct references, prefer `fromAgentRuntimeEndpoint()`.

  **Parameters**

  - `runtime` — - The AgentCore Runtime construct.
  - `endpointName` — - The name of the runtime endpoint.

  **Returns:** A DataSourceConfig instance

  ```ts
  declare const runtime: agentcore.Runtime;
  const dataSource = agentcore.DataSourceConfig.fromAgentRuntimeEndpointName(runtime, 'PROD');
  ```

- `fromCloudWatchLogs(config: CloudWatchLogsDataSourceConfig): DataSourceConfig // chainable` (static) — Creates a CloudWatch Logs data source configuration.

  Use this when your agent traces are stored in CloudWatch Logs,
  such as for external agents or when you need to specify log groups directly.

  **Parameters**

  - `config` — - The CloudWatch Logs data source configuration.

  **Returns:** A DataSourceConfig instance

  ```ts
  const dataSource = agentcore.DataSourceConfig.fromCloudWatchLogs({
    logGroupNames: ['/aws/bedrock-agentcore/runtimes/myRuntime-abc123-DEFAULT'],
    serviceNames: ['myRuntime.DEFAULT'],
  });
  ```
