For the complete documentation index, see llms.txt. This page is also available as Markdown.

Snowflake Integration

How to integrate Snowflake with Connectware by producing shop floor data to a Kafka topic and ingesting it into a Snowflake table with the Snowflake Kafka connector and Snowpipe Streaming.

This guide describes how to integrate Snowflake with Connectware. You configure a service commissioning file that produces shop floor data from MQTT topics to a Kafka topic, and the Snowflake Kafka connector ingests that topic into a Snowflake table with Snowpipe Streaming. A complete example file for the Connectware side is available at the end of this guide.

Objectives

  • Streaming shop floor data from an ISA-95-style topic hierarchy to a Kafka topic with the Kafka connector.

  • Configuring the Snowflake Kafka connector to ingest the topic into a Snowflake table with Snowpipe Streaming.

  • Querying the ingested rows in Snowflake.

Prerequisites

To follow this guide, you will need the following:

  • A running instance of Cybus Connectware.

  • A Kafka cluster that is reachable from Connectware, and a Kafka Connect environment where you can deploy the Snowflake Kafka connector. This can be self-managed Kafka or a managed service such as Confluent Cloud.

  • A Snowflake account, and a role that can create tables in the target schema.

  • Access to the Admin UI with sufficient user permissions.

  • Basic knowledge of MQTT and the Connectware services concept (for example, service commissioning files, connections, and endpoints).

Connectware and Snowflake Integration

Snowflake does not ingest MQTT natively, and row-by-row INSERT statements would keep a warehouse running for a use case that is pure streaming. The recommended path is Kafka, which both Connectware and Snowflake support natively:

  1. Connectware subscribes to the shop floor topics and produces every message to a Kafka topic through the Kafka connector.

  2. The Snowflake Kafka connector, deployed in your Kafka Connect environment, consumes the topic and streams the records into a Snowflake table.

With the Snowpipe Streaming ingestion method, the rows are written directly into the table without files, stages, or a running warehouse, and become queryable within seconds. Kafka also decouples the two sides: if Snowflake is briefly unavailable, the data waits in the topic instead of getting lost.

The MQTT topics in this guide follow an ISA-95-style equipment hierarchy (<enterprise>/<site>/<area>/<line>/<cell>). The mapping subscribes with named wildcards across all levels, so any machine in the hierarchy is picked up without changing the integration, and the topic levels travel inside each Kafka record.

Producing Production Events to Kafka

This guide shows the producer setup with SASL SCRAM authentication. For creating the Kafka topic, other security configurations such as mutual TLS, and the details of the record format, see the Apache Kafka Integration guide, or the Confluent Cloud Integration guide if your cluster runs on Confluent Cloud.

We add the connection values as parameters to the service commissioning file, so you can set them when you install the service.

Do not worry about copying the service commissioning file snippets together into one, the complete example file is available at the end of this guide.

  • brokers: The broker address of your Kafka cluster.

  • saslUsername and saslPassword: The SASL credentials of the Connectware client.

  • produceTopic: The Kafka topic that the Snowflake Kafka connector ingests. Defaults to factory.production-events.

  • topicRoot: The root of the MQTT topic hierarchy. Defaults to enterprise.

The write endpoint produces to the Kafka topic, and the mapping feeds it from the topic hierarchy. It uses named wildcards, so the topic levels are available in the $context.vars object of the transform rule. The rule builds the record in the format that the Kafka connector expects, a value array of records:

  • value: The record content as a string, built with the JSONata $string function. It combines the topic levels with the event_type and value fields of the machine payload into one JSON document, which Snowflake later parses back into a queryable object.

  • key: The equipment path. Kafka keeps all records with the same key on the same partition, which preserves the order of events per cell.

Any message published to a matching topic, for example enterprise/hamburg/assembly/line-1/press-01/production-events, now becomes one record on the Kafka topic. The machine payload only needs the event fields, the topic provides the rest:

Ingesting the Kafka Topic into Snowflake

The Snowflake Kafka connector runs in your Kafka Connect environment, not in Connectware. It authenticates to Snowflake with a key pair: generate one, assign the public key to the Snowflake user, and give the connector the private key. The user needs a role with USAGE on the target database and schema and CREATE TABLE on the schema. See the Snowflake Kafka connector documentation for the full installation and key setup.

The following configuration ingests the topic with Snowpipe Streaming, for example submitted to the Kafka Connect REST API:

  • ${SNOWFLAKE_PRIVATE_KEY}: The private key of the key pair as one line without the PEM header and footer. Provide it through the secret handling of your Kafka Connect environment rather than in plain text.

  • snowflake.url.name: Your account identifier followed by snowflakecomputing.com.

  • snowflake.topic2table.map: Maps the Kafka topic to the target table. Without this setting, the connector derives the table name from the topic name.

The connector creates the table if it does not exist, with two VARIANT columns: RECORD_CONTENT holds the JSON document that Connectware produced, and RECORD_METADATA holds the Kafka metadata, including the record key, topic, partition, offset, and the CreateTime timestamp of the record.

A view gives downstream users typed columns instead of raw JSON:

The connector can also write the JSON keys into real table columns instead of RECORD_CONTENT. Set snowflake.enable.schematization to true if you prefer typed columns over the view. See the Snowflake Kafka connector documentation for the trade-offs.

Verifying the Integration

  1. Install the service and set the parameters with the values of your Kafka cluster.

  2. Check that the connection is in the Connected state on the service details page in the Admin UI.

  3. Publish a test message with the machine payload shown in this guide to enterprise/hamburg/assembly/line-1/press-01/production-events, for example with an MQTT client or the Admin UI. The result of every produce request is published to the /res topic of the endpoint; a failed request carries an error property.

  4. Check that the record arrived on the Kafka topic, for example with kafka-console-consumer or the topic view of your managed Kafka service.

  5. Check that the row arrived in Snowflake, for example with SELECT * FROM FACTORY.SHOP_FLOOR.PRODUCTION_EVENTS_FLAT ORDER BY event_time DESC LIMIT 10 in a Snowsight worksheet. With Snowpipe Streaming, the row appears within seconds. If it does not, check the connector status and logs in Kafka Connect.

Service Commissioning File Example

Last updated

Was this helpful?