Amazon CloudWatch Logs Source Connector for Confluent Cloud

The Kafka Connect Amazon CloudWatch Logs Source connector for Confluent Cloud imports data from Amazon CloudWatch Logs, and then writes the data into an Apache Kafka® topic. The connector sources data from a single log group and can write to one topic per log stream. There is a Kafka topic format property (CLI property kafka.topic.format) you can use to customize the topic names for each log stream.

The connector can start at one task to support all import data and can scale up to one task per log stream. One task per log stream raises the performance up to the greatest number of log streams that Amazon supports (100,000 logs per second or 10 MB per second).

Important

If you are still on Confluent Cloud Enterprise, please contact your Confluent Account Executive for more information about using this connector.

Features

The Amazon CloudWatch Logs Source connector provides the following features:

  • At least once delivery: The connector guarantees that records are delivered at least once to the Kafka topic.
  • Supports multiple tasks: The connector supports running one or more tasks. More tasks may improve performance. The connector can start at one task to support all import data and can scale up to one task per log stream. One task per log stream raises the performance up to the greatest number of log streams that Amazon supports (100,000 logs per second or 10 MB per second).
  • Customize topic format: The connector sources data from a single log group and can write to one topic per log stream. There is a Kafka topic format property (CLI property kafka.topic.format) you can use to customize the topic names for each log stream.
  • Supported data formats: The connector supports Avro, JSON Schema (JSON-SR), and JSON (schemaless) output formats. Schema Registry must be enabled to use a Schema Registry-based format (for example, Avro and JSON Schema).

See Configuration Properties for configuration property descriptions. See Cloud connector limitations for additional information.

Quick Start

Use this quick start to get up and running with the Confluent Cloud Amazon CloudWatch Logs Source connector. The quick start provides the basics of selecting the connector and configuring it to stream events.

Prerequisites

Using the Confluent Cloud Console

Step 1: Launch your Confluent Cloud cluster.

See the Quick Start for Apache Kafka using Confluent Cloud for installation instructions.

Step 2: Add a connector.

In the left navigation menu, click Data integration, and then click Connectors. If you already have connectors in your cluster, click + Add connector.

Step 3: Select your connector.

Click the Amazon CloudWatch Logs connector icon.

Amazon CloudWatch Logs Source Connector Icon

Step 4: Set up the connection.

Note

  • Make sure you have all your prerequisites completed.
  • An asterisk ( * ) designates a required entry.
  1. Enter a connector Name.
  2. Enter your Kafka Cluster credentials. The credentials are either the cluster API key and secret or the service account API key and secret.
  3. Enter the Kafka Topic Format. Topic format to use for generating the names of the Kafka topics. This format string can contain ${log-group} and ${log-stream} as a placeholder for the original log group and log stream names. For example, confluent.${log-group}.${log-stream} for the log group log-group-1 and log stream log-stream-1 maps to the topic name confluent.log-group-1.log-stream-1.
  4. Select an Output message format (data going to the Kafka topic): AVRO, JSON_SR (JSON Schema), or JSON (schemaless). Schema Registry must be enabled to use a Schema Registry-based format (for example, Avro and JSON_SR.
  5. Enter your AWS credentials. For information about how to set these up, see Access Keys.
  6. Enter the Amazon CloudWatch connection details:
    • CloudWatch Logs Endpoint URL: For example, https://logs.us-east-1.amazonaws.com. For additional information, see Amazon CloudWatch Logs endpoints and quotas.
    • CloudWatch Logs Group Name: Name of the log group on Amazon CloudWatch where the log streams are contained.
    • CloudWatch Log Stream Name(s): List of the log stream(s) on Amazon CloudWatch where you want to track log records. If the field is left empty, all log streams under the log group are tracked.
    • AWS Poll Interval in Milliseconds: Time in milliseconds (ms) the connector waits between polling the endpoint for updates. The default value is 1000 ms (1 second).
  7. Enter the number of tasks to use with the connector. The connector supports running one or more tasks. The connector can start at one task to support all import data and can scale up to one task per log stream. One task per log stream can raise the performance, up to the greatest number of log streams that Amazon supports (100,000 logs per second or 10 MB per second).
  8. Transforms and Predicates: See the Single Message Transforms (SMT) documentation for details.

Note

See Configuration Properties for configuration property descriptions.

Step 5: Launch the connector.

Verify the connection details and click Launch.

Launch the connector

Step 6: Check the connector status.

The status for the connector should go from Provisioning to Running.

Connector status

Step 7: Check for records.

Verify that records are being produced at the Kafka topic.

For more information and examples to use with the Confluent Cloud API for Connect, see the Confluent Cloud API for Connect section.

Using the Confluent Cloud CLI

Complete the following steps to set up and run the connector using the Confluent Cloud CLI.

Note

Make sure you have all your prerequisites completed.

Step 1: List the available connectors.

Enter the following command to list available connectors:

ccloud connector-catalog list

Step 2: Show the required connector configuration properties.

Enter the following command to show the required connector properties:

ccloud connector-catalog describe <connector-catalog-name>

For example:

ccloud connector-catalog describe CloudWatchLogsSource

Example output:

Following are the required configs:
connector.class: CloudWatchLogsSource
name
kafka.api.key
kafka.api.secret
output.data.format
aws.access.key.id
aws.secret.access.key
aws.cloudwatch.logs.url
aws.cloudwatch.log.group
tasks.max

Step 3: Create the connector configuration file.

Create a JSON file that contains the connector configuration properties. The following entry shows a typical connector configuration. When launched, the connector consumes data from streams stream-1 and stream-2 of log group cloudwatch-group. It produces the data to Kafka topic logs.cloudwatch-group.stream-1 and topic logs.cloudwatch-group.stream-2.

{
  "name": "CloudWatchLogsSourceConnector_0",
  "config": {
    "connector.class": "CloudWatchLogsSource",
    "name": "CloudWatchLogsSourceConnector_0",
    "kafka.api.key": "<INSERT KAFKA API KEY>",
    "kafka.api.secret": "<INSERT KAFKA API SECRET>",
    "kafka.topic.format": "logs.${log-group}.${log-stream}",
    "output.data.format": "JSON",
    "aws.access.key.id": "<INSERT AWS API KEY>",
    "aws.secret.access.key": "<INSERT AWS API SECRET>",
    "aws.cloudwatch.logs.url": "https://logs.us-east-1.amazonaws.com",
    "aws.cloudwatch.log.group": "cloudwatch-group",
    "aws.cloudwatch.log.streams": "stream-1, stream-2",
    "aws.poll.interval.ms": "1500",
    "tasks.max": "1"
  }
}

Note the following property definitions:

  • "connector.class": Identifies the connector plugin name.
  • "name": Sets a name for your new connector.
  • "kafka.topic.format": Topic format to use for generating the names of the Kafka topics. This format string can contain ${log-group} and ${log-stream} as a placeholder for the original log group and log stream names. For example, confluent.${log-group}.${log-stream} for the log group log-group-1 and log stream log-stream-1 maps to the topic name confluent.log-group-1.log-stream-1.
  • "output.data.format": Enter an output data format (data going to the Kafka topic): AVRO, JSON_SR (JSON Schema), or JSON (schemaless). Schema Registry must be enabled to use a Schema Registry-based format (for example, Avro and JSON_SR.
  • "aws.access.key.id" and "aws.secret.access.key": Enter the AWS Access Key ID and Secret. For information about how to set these up, see Access Keys.
  • "aws.cloudwatch.logs.url": For example, https://logs.us-east-1.amazonaws.com. For additional information, see Amazon CloudWatch Logs endpoints and quotas.
  • "aws.cloudwatch.log.group": Name of the log group on Amazon CloudWatch where the log streams are contained.
  • "aws.cloudwatch.log.streams": List of the log stream(s) on Amazon CloudWatch where you want to track log records. If the property is not used, all log streams under the log group are tracked.
  • "aws.poll.interval.ms": Time in milliseconds (ms) the connector waits between polling the endpoint for updates. The default value is 1000 ms (1 second).
  • "tasks.max": Enter the number of tasks to use with the connector. The connector supports running one or more tasks. The connector can start at one task to support all import data and can scale up to one task per log stream. One task per log stream can raise the performance, up to the greatest number of log streams that Amazon supports (100,000 logs per second or 10 MB per second).

Single Message Transforms: See the Single Message Transforms (SMT) documentation for details about adding SMTs using the CLI.

Note

See Configuration Properties for configuration property descriptions.

Step 4: Load the properties file and create the connector.

Enter the following command to load the configuration and start the connector:

ccloud connector create --config <file-name>.json

For example:

ccloud connector create --config cloudwatch-logs-source-config.json

Example output:

Created connector CloudWatchLogsSourceConnector_0 lcc-do6vzd

Step 5: Check the connector status.

Enter the following command to check the connector status:

ccloud connector list

Example output:

ID           |             Name                 | Status  | Type  | Trace
+------------+-----------------------------   --+---------+--------+-------+
lcc-do6vzd   | CloudWatchLogsSourceConnector_0  | RUNNING | source |       |

Step 6: Check for records.

Verify that records are being produced at the Kafka topics logs.cloudwatch-group.stream-1 and logs.cloudwatch-group.stream-2.

For more information and examples to use with the Confluent Cloud API for Connect, see the Confluent Cloud API for Connect section.

Configuration Properties

The following connector configuration properties are used with the Amazon CloudWatch Source connector for Confluent Cloud.

aws.access.key.id

The AWS access key ID used to authenticate personal AWS credentials, such as IAM credentials.

  • Type: String
  • Importance: Medium
  • Default Value: “” (Empty String)
aws.secret.access.key

The secret access key used to authenticate personal AWS credentials, such as IAM credentials.

  • Type: Password
  • Importance: Medium
  • Default Value: “” (Empty String)
kafka.topic.format

A format string for the topic name(s) in Kafka, which may contain ${log-group} and ${log-stream} as a placeholder for the original log group and log stream names. For example, confluent.${log-group}.${log-stream} for the log group log-group-1 and log stream log-stream-1 will map to the topic name confluent.log-group-1.log-stream-1.

  • Type: String
  • Importance: High
  • Default Value: "{log-group}.{log-stream}" for each log stream
aws.cloudwatch.logs.url

The URL used as the endpoint to connect the Amazon CloudWatch Logs service to the source connector. For example, https://logs.us-east-1.amazonaws.com. See Amazon CloudWatch Logs endpoints and quotas.

  • Type: String
  • Importance: High
aws.cloudwatch.log.group

Name of the log group on Amazon CloudWatch under which the desired log streams are contained.

  • Type: String
  • Importance: High
aws.cloudwatch.log.streams

Name of the log stream(s) on Amazon CloudWatch that the log records are sent through. If the field is left empty, all log streams under the log group are tracked.

  • Type: List (List of streams to consume, separated by commas)
  • Importance: High
  • Default Value: Empty List
aws.poll.interval.ms

Time in milliseconds (ms) the connector waits between polling the endpoint for updates. The default value is 1000 ms (1 second).

  • Type: int
  • Importance: High
  • Default Value: 1000

Next Steps

See also

For an example that shows fully-managed Confluent Cloud connectors in action with Confluent Cloud ksqlDB, see the Cloud ETL Demo. This example also shows how to use Confluent Cloud CLI to manage your resources in Confluent Cloud.

../_images/topology.png