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.
Confluent Cloud is available through AWS Marketplace or directly from Confluent.
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 Quick Start is for the fully-managed Confluent Cloud connector. If you are installing the connector locally for Confluent Platform, see Amazon CloudWatch Logs Source Connector for Confluent Platform.
- If you require private networking for fully-managed connectors, make sure to set up the proper networking beforehand. For more information, see Manage Networking for Confluent Cloud Connectors.
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, String and JSON (schemaless) output formats. Schema Registry must be enabled to use a Schema Registry-based format (for example, Avro). 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 and DNS. 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:
- My account: This setting allows your connector to globally access everything that you have access to. With a user account, the connector uses an API key and secret to access the Kafka cluster. This option is not recommended for production.
- Service account: This setting limits the access for your connector by using a service account. This option is recommended for production.
- Use an existing API key: This setting allows you to specify an API key and a secret pair. You can use an existing pair or create a new one. This method is not recommended for production environments.
- 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 streams 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": "STRING",
"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",
"log.message.format": "STRING",
"behavior.on.error": "FAIL",
"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, STRING, or JSON (schemaless). Schema Registry must be enabled to use a Schema Registry-based format (for example, Avro). 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 streams 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)."log.message.format"
: Specifies the format for log messages received from CloudWatch Log Streams. Valid values for this configuration areJSON
andSTRING
. The default value isSTRING
"behavior.on.error"
: Determines how errors are managed by the connector. It must be set to one of the following:IGNORE
orFAIL
. When set toFAIL
, the connector halts upon encountering an error while processing records. When set toIGNORE
, the connector continues processing subsequent sets of records despite encountering errors. If a record is malformed, it is directed to the error topic associated with the connector. The default value isFAIL
. Note: This configuration does not affect the connector’s behavior when log.message.format is set toSTRING
."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
Behavior On Errors¶
behavior.on.error
Error handling behavior setting for the connector. Must be configured to one of the following: IGNORE, FAIL
- Type: string
- Default: FAIL
- Valid Values: FAIL, IGNORE
- Importance: medium
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 or STRING. Note that you need to have Confluent Cloud Schema Registry configured if using a schema-based message format like AVRO.
- 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
log.message.format
Set the format of log messages ingested from CloudWatch Log Streams. Valid entries are JSON and STRING.
- Type: string
- Default: STRING
- Valid Values: JSON, 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.
Try Confluent Cloud on AWS Marketplace with $1000 of free usage for 30 days, and pay as you go. No credit card is required.