Set up Openflow Connector for Amazon Kinesis Data Streams¶
참고
이 커넥터에는 `Snowflake Connector 약관<https://www.snowflake.com/legal/snowflake-connector-terms/>`_이 적용됩니다.
This topic describes how to set up Openflow Connector for Amazon Kinesis Data Streams.
Openflow Connector for Amazon Kinesis Data Streams is designed for JSON message ingestion from Kinesis streams to Snowflake tables, with schema evolution capabilities.
Set up the Openflow Connector for Kinesis¶
전제 조건¶
Openflow Connector for Amazon Kinesis Data Streams 섹션을 검토합니다.
Ensure that you have Openflow - BYOC 설정 or Set up Openflow - Snowflake Deployments.
If you are using Openflow - Snowflake Deployments, ensure that you have reviewed configuring required domains and have granted access to the required domains for the Kinesis connector.
Set up IAM roles and policies in AWS¶
AWS 계정 관리자는 AWS 계정에서 다음 작업을 수행합니다.
Create an AWS IAM user or role that Openflow will use to access the Kinesis data stream. For more information, see Creating IAM users in the AWS documentation.
Ensure that the AWS user has configured Access Key credentials.
Grant the AWS user the following IAM permissions:
Service
Actions
Resources (ARNs)
Purpose
Amazon Kinesis Data Streams
kinesis:DescribeStream,kinesis:DescribeStreamConsumer,kinesis:GetRecords,kinesis:GetShardIterator,kinesis:ListShards,kinesis:RegisterStreamConsumerarn:aws:kinesis:${REGION}:${ACCOUNT_ID}:stream/${STREAM_NAME}Discovers shards, reads records through shared-throughput polling, resolves the stream ARN, registers an Enhanced Fan-Out consumer, and polls consumer status during registration.
Amazon Kinesis Data Streams
kinesis:DeregisterStreamConsumer,kinesis:DescribeStreamConsumer,kinesis:SubscribeToShardarn:aws:kinesis:${REGION}:${ACCOUNT_ID}:stream/${STREAM_NAME}/consumer/*Describes, subscribes to, and deregisters Enhanced Fan-Out consumers by consumer ARN.
Amazon DynamoDB
dynamodb:CreateTable,dynamodb:DeleteTable,dynamodb:DescribeTable,dynamodb:GetItem,dynamodb:PutItem,dynamodb:Query,dynamodb:Scan,dynamodb:UpdateItemarn:aws:dynamodb:${REGION}:${ACCOUNT_ID}:table/${APPLICATION_NAME},arn:aws:dynamodb:${REGION}:${ACCOUNT_ID}:table/${APPLICATION_NAME}_migrationCreates and manages the checkpoint/lease table (shard leases, node heartbeats, checkpoints) and a temporary migration table used during one-time migration from legacy checkpoint tables.
Example IAM policy:
Before using the example policy, replace the following placeholders:
Placeholder
설명
${REGION}Your AWS region (for example,
us-east-1)${ACCOUNT_ID}Your AWS account ID (for example,
123456789012)${STREAM_NAME}The value of the AWS Kinesis Stream Name connector parameter
${APPLICATION_NAME}The value of the AWS Kinesis Application Name connector parameter. Used as the DynamoDB checkpoint table name and as the Enhanced Fan-Out registered consumer name.
참고
The
${APPLICATION_NAME}_migrationtable is a temporary DynamoDB table created only during a one-time migration from legacy checkpoint tables to the new schema. It’s deleted automatically when migration completes. If your deployment has never used the legacy KCL-based connector, you can omit the migration table ARN from the policy.The
dynamodb:DeleteTableaction is used during the migration process and can be removed from the policy after migration is confirmed complete.The
kinesis:DeregisterStreamConsumeraction is invoked when the processor is removed from the canvas. If the IAM principal doesn’t have this permission, the consumer must be deregistered manually through the AWS console or CLI.
Snowflake 계정 설정하기¶
Snowflake 계정 관리자는 다음 작업을 수행합니다.
유형이 SERVICE 인 새 Snowflake 서비스 사용자를 생성합니다.
Create a new role or use an existing role and grant the database privileges.
The connector requires the user to create the destination table. Make sure the user has the required privileges for managing Snowflake objects:
오브젝트
권한
참고
데이터베이스
USAGE
스키마
USAGE
테이블
OWNERSHIP
Required for the connector to ingest data into a table.
Snowflake recommends creating a separate user and role for each Kinesis stream for better access control.
다음 스크립트를 사용하여 사용자 지정 역할을 생성하고 구성할 수 있습니다(SECURITYADMIN 또는 이와 동등한 요구 사항 필요):
참고
Privileges must be granted directly to the connector role and can’t be inherited.
Configure the destination table
We highly recommend using server-side schema evolution for schema changes and an error table for DML error logging.
The example below shows how to create a table and add OWNERSHIP permissions.
These connectors provide support for automatic schema detection and evolution. The structure of tables in Snowflake is defined and evolved automatically to support the structure of new data loaded by the connector. It will automatically map the record content’s first-level keys to table columns matching by name (case-insensitive).
With Schema evolution enabled, Snowflake can automatically expand the destination table by adding new columns that are detected in the incoming stream and dropping NOT NULL constraints to accommodate new data patterns. For more information, see Table schema evolution.
If ENABLE_SCHEMA_EVOLUTION is not enabled, then you have to create the schema manually by extending the table definition. The connector tries to match the record content’s first-level keys to the table columns by name. If keys from the JSON do not match the table columns, the connector ignores the keys.
(Optional) Configure a secrets manager
Snowflake는 이 단계를 강력히 권장합니다. Openflow에서 지원하는 시크릿 관리자(예: AWS, Azure, Hashicorp)를 구성하고 공개 및 개인 키를 시크릿 스토어에 저장합니다.
Once the secrets manager is configured, determine how you will authenticate to it. On AWS, it’s recommended that you use the EC2 instance role associated with Openflow as this way no other secrets have to be persisted.
In the Openflow canvas, configure a Parameter Provider associated with this Secrets Manager, from the hamburger menu in the upper right. Navigate to Controller Settings » Parameter Provider and then fetch your parameter values.
이 시점에서 모든 자격 증명은 연결된 매개 변수 경로로 참조할 수 있으며 민감한 값은 Openflow 내에서 유지될 필요가 없습니다.
Grant access to users
Any other Snowflake users who require access to the raw ingested data by the connector (for example, for custom processing in Snowflake), should be granted the role created in step 2.
커넥터 설정하기¶
데이터 엔지니어는 다음 작업을 수행하여 커넥터를 설치하고 구성합니다.
커넥터 설치하기¶
Navigate to the Openflow overview page. In the Featured connectors section, select View more connectors.
On the Openflow connectors page, find the Openflow connector for Amazon Kinesis Data Streams and select Add to runtime.
In the Select runtime dialog, select your runtime from the Available runtimes drop-down list and click Add.
참고
Before you install the connector, ensure that you have created a database, schema, and a table in Snowflake for the connector to store ingested data.
Authenticate to the deployment with your Snowflake account credentials and select Allow when prompted to allow the runtime application to access your Snowflake account. The connector installation process takes a few minutes to complete.
Snowflake 계정 자격 증명으로 런타임에 인증합니다.
커넥터 프로세스 그룹이 추가된 Openflow 캔버스가 표시됩니다.
커넥터 구성¶
If needed, customize the connector configuration before configuring the built-in parameters.
Populate the process group parameters
Right-click on the imported process group and select Parameters.
Fill out the required parameter values.
Common parameters¶
매개 변수 |
설명 |
필수 |
|---|---|---|
AWS 액세스 키 ID |
The AWS Access Key ID to connect to your Kinesis Stream and DynamoDB. |
예 |
AWS Kinesis Region |
The AWS Region to connect to. Use regular AWS region format, for example: |
예 |
AWS 시크릿 액세스 키 |
The AWS Secret Access Key to connect to your Kinesis Stream and DynamoDB. |
예 |
AWS Kinesis Application Name |
The name that is used as the DynamoDB table name for tracking the application’s progress on Kinesis Stream consumption. |
예 |
AWS Kinesis Consumer Type |
The strategy used to read records from a Kinesis Stream. Must be one of the following values: SHARED_THROUGHPUT, ENHANCED_FAN_OUT. For more information, see Differences between shared throughput consumer and enhanced fan-out consumer. |
예 |
AWS Kinesis Initial Stream Position |
The initial stream position from which the data starts replication. This takes effect only during the initial start for a given AWS Kinesis Application Name. 가능한 값은 다음과 같습니다. LATEST: Latest stored record, TRIM_HORIZON: Earliest stored record. |
예 |
AWS Kinesis Stream Name |
The AWS Kinesis Stream Name to consume data from. |
예 |
Snowflake Destination Database |
데이터가 유지될 데이터베이스입니다. Snowflake에 이미 존재해야 합니다. 이름은 대소문자를 구분합니다. 따옴표로 묶지 않은 식별자의 경우 이름을 대문자로 입력합니다. |
예 |
Snowflake Destination Schema |
데이터가 유지될 스키마로, Snowflake에 이미 존재해야 합니다. 이름은 대소문자를 구분합니다. 따옴표로 묶지 않은 식별자의 경우 이름을 대문자로 입력합니다. 다음 예제를 참조하세요.
|
예 |
Snowflake Destination Table |
The table where data will be persisted. It must already exist in Snowflake. The name is case-sensitive. For unquoted identifiers, provide the name in uppercase. |
예 |
Start the connector¶
Right-click on the plane and select Enable all Controller Services.
Right-click on the plane and select Start. The connector starts data ingestion.
Understanding KINESISMETADATA column¶
The connector populates the KINESISMETADATA structure with metadata about the Kinesis record. The structure contains the following information:
필드 이름 |
필드 유형 |
예제 값 |
설명 |
|---|---|---|---|
stream |
String |
|
레코드의 출처인 Kinesis 스트림의 이름입니다. |
shardId |
String |
|
레코드의 출처인 스트림에 있는 shard의 식별자입니다. |
approximateArrival |
String |
|
레코드가 스트림에 삽입된 대략적인 시간(ISO 8601 형식)입니다. |
partitionKey |
String |
|
레코드에 대해 데이터 생산자가 지정한 파티션 키입니다. |
sequenceNumber |
String |
|
Kinesis Data Streams가 shard의 레코드에 할당한 고유한 시퀀스 번호입니다. |
subSequenceNumber |
숫자 |
|
레코드의 하위 시퀀스 번호입니다(동일한 시퀀스 번호를 가진 집계된 레코드에 사용됨). |
shardedSequenceNumber |
String |
|
레코드의 시퀀스 번호와 하위 시퀀스 번호의 조합입니다. |
Measuring ingestion latency¶
For change tracking, incremental processing, and Time Travel queries based on row modification time, the ROW_TIMESTAMP feature can be used.
It can be enabled by running the following command on your destination table:
After row timestamps are enabled, tables expose the METADATA$ROW_LAST_COMMIT_TIME column, which returns the timestamp when each row was last modified.
For more information, see Row timestamps.
참고
Row timestamp isn’t available for interactive tables. For more information, see 대화형 테이블의 제한 사항.
Using the connector with Apache Iceberg™ tables¶
The connector can ingest data into Snowflake-managed Apache Iceberg™ tables but must meet the following requirements:
You must have been granted the USAGE privilege on the external volume associated with your Apache Iceberg™ table.
You must create an Apache Iceberg™ table before running the connector.
Grant usage on an external volume¶
For example, if your Iceberg table uses the kinesis_external_volume external volume and the connector uses the role openflow_kinesis_connector_role_1, run the following statement:
Create an Apache Iceberg™ table for ingestion¶
The connector does not create Iceberg tables automatically and does not support schema evolution. Before you run the connector, you must create an Iceberg table manually.
When you create an Iceberg table, you can use Iceberg data types (including VARIANT) or compatible Snowflake types.
예를 들어, 다음 메시지를 생각해 보십시오.
To create an Iceberg table for the example message, use one of the following statements:
Using the connector with Interactive Tables¶
Interactive tables are a special type of Snowflake table optimized for low-latency, high-concurrency queries. You can find out more about interactive tables in the interactive tables documentation.
Create an interactive table:
Important considerations:
Interactive tables have specific limitations and query restrictions. Review the interactive tables documentation before using them with the connector.
For interactive tables, any required transformations must be handled in the table definition.
Interactive warehouses are required to query interactive tables efficiently.
Using the connector with a customer-defined schema for the destination table¶
The connector treats each Kinesis record as a row to be inserted into a Snowflake table. For example, if you have a Kinesis topic with the content of the message structured like the following JSON:
By default you don’t have to specify all fields from the JSON. Schema evolution will take care of it. However, if you prefer a static schema, it can be created by running:
Using the connector with a customer-defined PIPE¶
If you choose to create your own pipe, you can define the data transformation logic in the pipe’s COPY INTO statement. You can rename columns as required and cast the data types as needed. For example:
When you define your own pipe your destination table columns do not have to match the JSON keys. You can rename the columns to your desired names and cast the data types if required.
To adjust the connector to work with a custom pipe, perform the following tasks:
Right-click on the PublishSnowpipeStreaming processor used in your Kinesis ingestion flow in the Openflow canvas.
Select Configure from the context menu.
Navigate to the Properties tab.
In the Destination type field, pick Pipe.
In the Pipe field, type the name of your pipe.
Select Apply to save the configuration.
Customizing error handling¶
Error handling is split between Openflow-side failures and server-side failures within the Snowpipe Streaming service.
Openflow Errors (Client-Side Failures): Errors such as unparseable payloads or custom transformation failures occur before records reach Snowflake. By default these records are discarded. It’s possible to process these errors in Openflow - use FlowFiles from the parse failure relationship in the ConsumeKinesis processor.
Snowpipe Streaming Errors (Server-Side Failures): Errors for records that successfully reach Snowflake but are incompatible with the destination table’s schema (for example, type mismatches) are captured by the Snowflake infrastructure. When error logging is enabled on the destination table (
error_logging = true), these failed rows are automatically ingested into the destination Error table.