Amazon CloudWatch Metrics Sink Connector for Confluent Cloud¶
The Amazon CloudWatch Metrics Sink connector is used to export data to Amazon CloudWatch metrics
from an Apache Kafka® topic. The connector will only accept Struct objects as the Kafka
record. The record must consist of the fields name
, type
, timestamp
,
dimensions
, and values
. The values
field refers to metric values
which are also expected to be Struct objects. For more details about
values
, see Defined schemas.
The following example shows a sample input Struct object record.
{
"name": string,
"type": string,
"timestamp": long,
"dimensions": {
"<dimension-1>": string,
...
},
"values": {
"<datapoint-1>": double,
"<datapoint-2>": double,
...
}
}
The connector can start with one task and scale horizontally by adding more tasks. Note that even with multiple tasks, performance is limited by Amazon to 150 transactions per second. Contact Amazon to increase this transaction limit for your account.
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 Metrics Sink connector provides the following features:
- At least once delivery: This connector guarantees that records from the Kafka topic are delivered at least once.
- Supports multiple tasks: The connector supports running one or more tasks. More tasks may improve performance. Note that performance is limited by Amazon to 150 transactions per second. Contact Amazon to increase this transaction limit for your account.
- Supported data formats: The connector supports Avro, JSON Schema (JSON-SR), and Protobuf input message formats. Schema Registry must be enabled to use these Schema Registry-based formats.
See Configuration Properties configuration property descriptions. See Confluent Cloud connector limitations for additional information.
Defined schemas¶
The connector attempts to fit the values
Struct into one of the four defined
schemas (Gauge, Meter, Histogram, Timer) depending on the type
field. The
supported types are gauge
, meter
, histogram
, timer
or
custom
.
Note
- If the value for
type
iscustom
, there is a catchall mechanism that accounts for any type of schema, but thetype
field’s value must becustom
. - Each value in the
values
Struct must be typedouble
.
Gauge schema¶
{
"doubleValue": double
}
Meter schema¶
{
"count": double,
"oneMinuteRate": double,
"fiveMinuteRate": double,
"fifteenMinuteRate": double,
"meanRate": double
}
Histogram schema¶
{
"count": double,
"max": double,
"min": double,
"mean": double,
"stdDev": double,
"sum": double,
"median": double,
"percentile75th": double,
"percentile95th": double,
"percentile98th": double,
"percentile99th": double,
"percentile999th": double,
}
Timer schema¶
{
"count": double,
"oneMinuteRate": double,
"fiveMinuteRate": double,
"fifteenMinuteRate": double,
"meanRate": double,
"max": double,
"min": double,
"mean": double,
"stdDev": double,
"sum": double,
"median": double,
"percentile75th": double,
"percentile95th": double,
"percentile98th": double,
"percentile99th": double,
"percentile999th": double
}
Sample custom schema¶
{
"posts": double,
"puts": double,
"patches": double,
"deletes": double,
}
Record mapping¶
Each value in the values
Struct is mapped to its own MetricDatum
object using the same timestamp
and dimensions
fields, with the name
field as a prefix. For example, the following will be mapped to five separate
MetricDatum
objects, since there are five values in the values
Struct:
{
"name": "sample_meter_metric",
"type": "meter",
"timestamp": 23480239402348234,
"dimensions": {
"service": "ec2-2312",
"method": "update"
},
"values": {
"count": 12,
"oneMinuteRate": 5.2,
"fiveMinuteRate": 4.7,
"fifteenMinuteRate": 4.9,
"meanRate": 5.1"
}
}
The following is an example of how the oneMinuteRate
field is mapped to a separate MetricDatum
object:
{
"name": "sample_meter_metric_oneMinuteRate",
"timestamp": 23480239402348234,
"dimensions": {
"service": "ec2-2312",
"method": "update"
},
"value": 5.2
}
Quick Start¶
Use this quick start to get up and running with the Confluent Cloud Amazon CloudWatch Metrics Sink connector. The quick start provides the basics of selecting the connector and configuring it to send records to Amazon CloudWatch.
- Prerequisites
- Authorized access to a Confluent Cloud cluster on AWS.
- The Confluent Cloud CLI installed and configured for the cluster. See Install the Confluent Cloud CLI.
- Schema Registry must be enabled to use a Schema Registry-based format (for example, Avro, JSON_SR (JSON Schema), or Protobuf).
- For networking considerations, see Internet access to resources. To use static egress IPs, see Static Egress IP Addresses.
- An AWS account configured with Access Keys.
- The Amazon CloudWatch Metrics region must in the same region where your Confluent Cloud cluster is located (where you are running the connector). Note that the hard-coded endpoint URL for the connector is set to
https://monitoring.{kafka-cluster-region}.amazonaws.com
. This sets the Amazon CloudWatch region to your Kafka cluster region.
- Kafka cluster credentials. You can use one of the following ways to get credentials:
- Create a Confluent Cloud API key and secret. To create a key and secret, you can use the Confluent Cloud CLI or you can autogenerate the API key and secret directly in the Cloud Console when setting up the connector.
- Create a Confluent Cloud service account for the connector. Make sure to review the ACL entries required in the service account documentation. Some connectors have specific ACL requirements.
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.¶
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.
Complete the following steps and click Continue.
Select one or more topics.
Enter a Connector Name.
Select an Input message format (data coming from the Kafka topic): AVRO, JSON_SR (JSON Schema), or PROTOBUF. A valid schema must be available in Schema Registry to use a schema-based message format.
Enter your Kafka Cluster credentials. The credentials are either the API key and secret or the service account API key and secret.
Enter your AWS credentials. For information about how to set these up, see Access Keys.
Enter the Amazon CloudWatch Metrics namespace. This is a metrics namespace that is valid for your CloudWatch Metrics region. For more information, see AWS services that publish CloudWatch metrics.
Select the way you want errors (malformed metrics) handled. The connector can log the error and continue processing the next record. Or, you can have the connector fail when an error occurs.
Enter the number of tasks for the connector to use. More tasks may improve performance.
Note
Performance is limited by Amazon to 150 transactions per second. Contact Amazon to increase this transaction limit for your account.
Step 6: Check the connector status.¶
The status for the connector should go from Provisioning to Running.
Step 7: Check Amazon CloudWatch metrics.¶
Check for metrics in Amazon CloudWatch.
For more information and examples to use with the Confluent Cloud API for Connect, see the Confluent Cloud API for Connect section.
Tip
When you launch a connector, a Dead Letter Queue topic is automatically created. See Dead Letter Queue for details.
See Configuration Properties configuration property descriptions.
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.
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 CloudWatchMetricsSink
Example output:
Following are the required configs:
connector.class: CloudWatchMetricsSink
input.data.format
name
kafka.api.key
kafka.api.secret
aws.access.key.id
aws.secret.access.key
aws.cloudwatch.metrics.namespace
tasks.max
topics
Step 3: Create the connector configuration file.¶
Create a JSON file that contains the connector configuration properties. The following example shows the required connector properties.
{
"connector.class": "CloudWatchMetricsSink",
"name": "CloudWatchMetricsSink_0",
"input.data.format": "AVRO"
"topics": "<my_topic_0>"
"kafka.api.key": "****************",
"kafka.api.secret": "*************************************************",
"aws.access.key.id": "****************",
"aws.secret.access.key": "********************************************",
"aws.cloudwatch.metrics.namespace": "<namespace>",
"tasks.max": "1"
}
Note the following required property definitions:
"connector.class"
: Identifies the connector plugin name."name"
: Sets a name for your new connector."input.data.format"
: Sets the input message format (data coming from the Kafka topic). Valid entries are AVRO, JSON_SR (JSON Schema), and PROTOBUF. You must have Confluent Cloud Schema Registry configured if using a schema-based message format."topics"
: Identifies the topic name or a comma-separated list of topic names."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.metrics.namespace"
: Enter a valid namespace for your CloudWatch Metrics region."tasks.max"
: Enter the number of tasks for the connector to use. More tasks may improve performance.Note
Performance is limited by Amazon to 150 transactions per second. Contact Amazon to increase this transaction limit for your account.
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 amazon-cloudwatch-metrics-sink-config.json
Example output:
Created connector CloudWatchMetricsSink_0 lcc-ix4dl
Step 5: Check the connector status.¶
Enter the following command to check the connector status:
ccloud connector list
Example output:
ID | Name | Status | Type
+-----------+-------------------------+---------+------+
lcc-ix4dl | CloudWatchMetricsSink_0 | RUNNING | sink
Step 6: Check Amazon CloudWatch metrics.¶
Check for metrics in Amazon CloudWatch.
For more information and examples to use with the Confluent Cloud API for Connect, see the Confluent Cloud API for Connect section.
Tip
When you launch a connector, a Dead Letter Queue topic is automatically created. See Dead Letter Queue for details.
See Configuration Properties configuration property descriptions.
Configuration Properties¶
The following connector configuration properties are used with the Amazon CloudWatch Metrics Sink 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)
- Type: string
- Importance: high
aws.cloudwatch.metrics.namespace
The Amazon CloudWatch Metrics namespace associated with the desired metrics.
- Type: String
- Importance: High
behavior.on.malformed.metric
The connector’s behavior if the metric does not contain an expected field. Must be configured to one of the following:
fail
Stops the connector when an error occurs.
log
Logs an error message and continues to process the next set of records. The error message is available in the event log.
- Type: string
- Default: fail
- Valid Values: one of [log, fail]
- Importance: medium
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.