Amazon CloudWatch Logs Source Connector for Confluent Cloud

Note

This is a Quick Start for the managed cloud connector. If you are installing the connector locally for Confluent Platform, see Amazon CloudWatch Logs Source Connector for Confluent Platform.

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).

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 Connect section.

Limitations

Be sure to review the following 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 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 card.

Amazon CloudWatch Logs Source Connector Card

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:

  1. 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).
  2. 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 Connect 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.
  • The example commands use Confluent CLI version 2. For more information see, Confluent CLI v2.

Step 1: List the available connectors.

Enter the following command to list available connectors:

confluent connect plugin list

Step 2: Show the required connector configuration properties.

Enter the following command to show the required connector properties:

confluent connect plugin describe <connector-catalog-name>

For example:

confluent connect plugin describe CloudWatchLogsSource

Example output:

Following are the required configs:
connector.class: CloudWatchLogsSource
name
kafka.auth.mode
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.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 or KAFKA_API_KEY (the default). To use an API key and secret, specify the configuration properties kafka.api.key and kafka.api.secret, as shown in the example configuration (above). To use a service account, specify the Resource ID in the property kafka.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 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). 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 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.

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 create --config <file-name>.json

For example:

confluent connect 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:

confluent connect 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

Use the following configuration properties with this connector.

Note

These are properties for the managed cloud connector. If you are installing the connector locally for Confluent Platform, see Amazon CloudWatch Logs Source Connector 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

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
  • 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
  • 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
  • Type: int
  • Valid Values: [1,…]
  • Importance: high

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 CLI to manage your resources in Confluent Cloud.

../_images/topology.png