Amazon CloudWatch Logs Source Connector for Confluent Cloud¶
The fully-managed 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).
Note
This is a Quick Start for the fully-managed cloud connector. If you are installing the connector locally for Confluent Platform, see Amazon CloudWatch Logs Source Connector for Confluent Platform.
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 Schema Registry Enabled Environments for additional information.
For more information and examples to use with the Confluent Cloud API for Connect, see the Confluent Cloud API for Managed and Custom Connectors section.
Limitations¶
Be sure to review the following information.
- For connector limitations, see Amazon CloudWatch Logs Source Connector limitations.
- If you plan to use one or more Single Message Transforms (SMTs), see SMT Limitations.
- If you plan to use Confluent Cloud Schema Registry, see Schema Registry Enabled Environments.
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
Authorized access to a Confluent Cloud cluster on Amazon Web Services (AWS).
The Confluent CLI installed and configured for the cluster. See Install the Confluent CLI.
For networking considerations, see Networking, DNS, and service endpoints. To use a set of public egress IP addresses, see Public Egress IP Addresses for Confluent Cloud Connectors.
An AWS account configured with Access Keys. You use these access keys when setting up the connector. Note the IAM identity must have the following minimum permissions (IAM policies):
logs:GetLogEvents
logs:DescribeLogStreams
For details, see Using identity-based policies (IAM policies) for CloudWatch Logs.
Amazon CloudWatch connection details. For more information, see log groups and log streams.
Using the Confluent Cloud Console¶
Step 1: Launch your Confluent Cloud cluster.¶
See the Quick Start for Confluent Cloud for installation instructions.
Step 2: Add a connector.¶
In the left navigation menu, click Connectors. If you already have connectors in your cluster, click + Add connector.
Step 4: Enter the connector details.¶
Note
- Make sure you have all your prerequisites completed.
- An asterisk ( * ) designates a required entry.
At the Add CloudWatch Logs Source Connector screen, complete the following:
- Select the way you want to provide Kafka Cluster credentials. You can
choose one of the following options:
- Global Access: Allows your connector to access everything you have access to. With global access, connector access will be linked to your account. This option is not recommended for production.
- Granular access: Limits the access for your connector. You will be able to manage connector access through a service account. This option is recommended for production.
- Use an existing API key: Allows you to enter an API key and secret part you have stored. You can enter an API key and secret (or generate these in the Cloud Console).
- Click Continue.
Add the Amazon CloudWatch connection authentication details:
- AWS Access Key ID: The Amazon Access Key used to connect to Amazon CloudWwatch.
- AWS Secret Access Key: The Amazon Secret Key used to connect to Amazon CloudWwatch.
For information about how to set these up, see Access Keys.
Click Continue.
Add the following details:
- Select the output record value format (data going to the Kafka topic): AVRO, JSON, or JSON_SR (JSON Schema). Schema Registry must be enabled to use a Schema Registry-based format (for example, Avro, or JSON Schema). For additional information, see Schema Registry Enabled Environments.
- Amazon CloudWatch Logs Endpoint URL: The URL to use as the
endpoint for connecting to Amazon CloudWatch for Logs. For example,
https://logs.us-east-1.amazonaws.com
. - Amazon CloudWatch Logs Group Name: The name of the log group on Amazon CloudWatch under which the desired log streams are contained.
Show advanced configurations
Schema context: Select a schema context to use for this connector, if using a schema-based data format. This property defaults to the Default context, which configures the connector to use the default schema set up for Schema Registry in your Confluent Cloud environment. A schema context allows you to use separate schemas (like schema sub-registries) tied to topics in different Kafka clusters that share the same Schema Registry environment. For example, if you select a non-default context, a Source connector uses only that schema context to register a schema and a Sink connector uses only that schema context to read from. For more information about setting up a schema context, see What are schema contexts and when should you use them?.
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).Transforms and Predicates: See the Single Message Transforms (SMT) documentation for details.
For all property values and definitions, see Configuration Properties.
Click Continue.
Based on the number of topic partitions you select, you will be provided with a recommended number of tasks.
- To change the number of tasks, use the Range Slider to select the desired number of tasks.
- Click Continue.
Step 5: 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 Managed and Custom Connectors section.
Using the Confluent CLI¶
Complete the following steps to set up and run the connector using the Confluent CLI.
Note
Make sure you have all your prerequisites completed.
Step 1: List the available connectors.¶
Enter the following command to list available connectors:
confluent connect plugin list
Step 2: List the connector configuration properties.¶
Enter the following command to show the connector configuration properties:
confluent connect plugin describe <connector-plugin-name>
The command output shows the required and optional configuration properties.
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.auth.mode": "KAFKA_API_KEY",
"kafka.api.key": "<my-kafka-api-key>",
"kafka.api.secret": "<my-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.auth.mode"
: Identifies the connector authentication mode you want to use. There are two options:SERVICE_ACCOUNT
orKAFKA_API_KEY
(the default). To use an API key and secret, specify the configuration propertieskafka.api.key
andkafka.api.secret
, as shown in the example configuration (above). To use a service account, specify the Resource ID in the propertykafka.service.account.id=<service-account-resource-ID>
. To list the available service account resource IDs, use the following command:confluent iam service-account list
For example:
confluent iam service-account list Id | Resource ID | Name | Description +---------+-------------+-------------------+------------------- 123456 | sa-l1r23m | sa-1 | Service account 1 789101 | sa-l4d56p | sa-2 | Service account 2
"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 grouplog-group-1
and log streamlog-stream-1
maps to the topic nameconfluent.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). See Schema Registry Enabled Environments for additional information."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 is1000
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.
See Configuration Properties for all property values and descriptions.
Step 4: Load the properties file and create the connector.¶
Enter the following command to load the configuration and start the connector:
confluent connect cluster create --config-file <file-name>.json
For example:
confluent connect cluster create --config-file 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:
confluent connect cluster 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 Managed and Custom Connectors section.
Configuration Properties¶
Use the following configuration properties with the fully-managed connector. For self-managed connector property definitions and other details, see the connector docs in Self-managed connectors for Confluent Platform.
How should we connect to your data?¶
name
Sets a name for your connector.
- Type: string
- Valid Values: A string at most 64 characters long
- Importance: high
Schema Config¶
schema.context.name
Add a schema context name. A schema context represents an independent scope in Schema Registry. It is a separate sub-schema tied to topics in different Kafka clusters that share the same Schema Registry instance. If not used, the connector uses the default schema configured for Schema Registry in your Confluent Cloud environment.
- Type: string
- Default: default
- Importance: medium
Kafka Cluster credentials¶
kafka.auth.mode
Kafka Authentication mode. It can be one of KAFKA_API_KEY or SERVICE_ACCOUNT. It defaults to KAFKA_API_KEY mode.
- Type: string
- Default: KAFKA_API_KEY
- Valid Values: KAFKA_API_KEY, SERVICE_ACCOUNT
- Importance: high
kafka.api.key
Kafka API Key. Required when kafka.auth.mode==KAFKA_API_KEY.
- Type: password
- Importance: high
kafka.service.account.id
The Service Account that will be used to generate the API keys to communicate with Kafka Cluster.
- Type: string
- Importance: high
kafka.api.secret
Secret associated with Kafka API key. Required when kafka.auth.mode==KAFKA_API_KEY.
- Type: password
- Importance: high
How do you want to define topic names?¶
kafka.topic.format
Topic format to use for generating the names of the Apache Kafka® topics to publish data to. This format string can contain ${log-group} and ${log-stream} as a placeholder for the original log group and log stream names.
- Type: string
- Default: ${log-group}.${log-stream}
- Importance: high
Output messages¶
output.data.format
Sets the output Kafka record value format. Valid entries are AVRO, JSON_SR, or JSON. Note that you need to have Confluent Cloud Schema Registry configured if using a schema-based message format like AVRO and JSON_SR.
- Type: string
- Importance: high
AWS Credentials¶
aws.access.key.id
The Amazon Access Key used to connect to Amazon CloudWatch.
- Type: password
- Importance: high
aws.secret.access.key
The Amazon Secret Key used to connect to Amazon CloudWatch.
- Type: password
- Importance: high
How should we connect to Amazon CloudWatch Logs?¶
aws.cloudwatch.logs.url
The URL to use as the endpoint for connecting to Amazon CloudWatch for Logs. For example, https://logs.us-east-1.amazonaws.com.
- Type: string
- Importance: high
CloudWatch Logs details¶
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
List of the log stream(s) on Amazon CloudWatch under which the desired log records are sent through. If the field is left empty, all log streams under the log group will be tracked.
- Type: list
- Importance: high
aws.poll.interval.ms
Time in milliseconds to wait between two consecutive polls to the Amazon CloudWatch endpoint.
- Type: int
- Default: 1000 (1 second)
- Valid Values: [0,…]
- Importance: high
Number of tasks for this connector¶
tasks.max
Maximum number of tasks for the connector.
- Type: int
- Valid Values: [1,…]
- Importance: high
Next Steps¶
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 CLI to manage your resources in Confluent Cloud.