Monitor the Openflow Connector for Kafka

The connector writes the metrics described on this page to your Openflow event table. For generic Openflow telemetry, see Openflow telemetry.

Metrics for consuming data from Kafka

All metrics include the same resource and connector attributes as application metrics. Additionally, they include Kafka-specific metric attributes.

MetricTypeResolutionDescription
kafka.records.consumer.lagGaugeTopic and partitionHighest number of records this consumer was behind during the reporting interval. Reported every 60 seconds for partitions that returned records since the last report.
kafka.records.consumedCounterTopic and partitionNumber of Kafka messages consumed during the reporting interval. Reported every 60 seconds for every topic and partition that consumed messages since the last report.
kafka.bytes.consumedCounterTopic and partitionNumber of bytes consumed during the reporting interval. The value is the length of the message key plus the length of the message value, after the Kafka client decompresses the batch. Message headers aren’t included. Reported every 60 seconds for every topic and partition that consumed messages since the last report.
kafka.records.parsed.errorsCounterTopic and partitionNumber of records that failed to parse during the reporting interval. Reported every 60 seconds for every topic and partition with a parse error since the last report.

These metrics support up to 10,000 topic and partition combinations in a single runtime. Above that limit, further combinations are reported together.

The connector reports these metrics when it reads the data, before the batch is committed. A batch that is read again is counted again.

Kafka-specific metric attributes

Kafka metrics include the following metric attributes:

AttributeDescription
kafka.topicName of the Kafka topic.
kafka.partitionPartition of the topic.

Metrics for pushing data to Snowpipe Streaming

All metrics include the same resource and connector attributes as application metrics. Additionally, they can also include source and destination metric attributes.

These metrics are reported when the Metric Resolution property is Destination or Source and Destination. This property can be set on the PublishSnowpipeStreaming processor inside your connector or custom flow.

MetricTypeResolutionDescription
snowpipe.streaming.rows.sentCounterDestinationNumber of rows sent to Snowpipe Streaming after a successful insert. Reported every 60 seconds for every destination that received data since the last report.
snowpipe.streaming.bytes.sentCounterDestinationNumber of uncompressed bytes sent to Snowpipe Streaming, measured before compression. Reported every 60 seconds for every destination that received data since the last report.
snowpipe.streaming.last.push.timeGaugeDestinationTime when rows were last pushed to Snowpipe Streaming, in milliseconds since the UNIX epoch. Reported every 60 seconds for up to 3 days after the last push, even when no new rows are pushed.
snowpipe.streaming.consume.to.push.latencyGaugeDestinationHighest time, in milliseconds, from when the connector read the data until the rows were pushed to Snowpipe Streaming. Reported every 60 seconds for every destination that received data since the last report.

These metrics support up to 10,000 destinations in a single runtime. Above that limit, metrics might be lost.

The connector reports these metrics after a successful insert using Snowpipe Streaming.

How the lag and latency metrics relate

A record passes through consecutive stages: it waits in the source until the connector reads it, the connector processes it and pushes it to Snowpipe Streaming, and then Snowpipe Streaming makes the rows queryable. The metrics cover these stages as follows:

  • Consumer lag (kafka.records.consumer.lag) covers how far the connector is behind the latest record in the partition. It’s measured in records, not time, so you can’t add it to the push latency.
  • Push latency (snowpipe.streaming.consume.to.push.latency) covers the time from when the connector reads the data until the rows are pushed to Snowpipe Streaming.

The time until pushed rows become queryable doesn’t have its own metric, and there’s no end-to-end latency metric. A reported push doesn’t mean that the rows are queryable yet.

Each metric reports the highest value in each 1-minute reporting interval. Because these are maximums, and the consumer lag is reported per topic and partition while the push latency is reported per destination, the values don’t add up exactly.

Source and destination metric attributes

These metrics can include the following metric attributes:

AttributeDescription
destination.database.nameName of the destination database.
destination.schema.nameName of the destination schema.
destination.pipe.nameName of the pipe. When the destination is a table, this is the default pipe in the form of {table}-STREAMING.
source.nameValue of the Source Name property.

The destination.* attributes are included when Metric Resolution on PublishSnowpipeStreaming processor is Destination or Source and Destination. source.name is included only when Metric Resolution is Source and Destination.

In this connector, set the Source Name property to ${kafka.topic}. A merge keeps Source Name when every merged FlowFile has the same value. A merge of different sources can drop Source Name. If Source Name is blank or missing, including when a merge drops it, the rows are still counted and the source.name attribute is omitted.

Example queries

The following queries assume that Openflow sends telemetry to the default event table, SNOWFLAKE.TELEMETRY.EVENTS. If you use a different event table, substitute its name.

Count messages consumed

This query returns the number of messages consumed for each topic and partition per hour in the last 24 hours. Each value covers one 60-second interval, so the query sums the values:

SELECT
  DATE_TRUNC(hour, timestamp) AS hour,
  record_attributes:"connector.name"::STRING AS connector,
  record_attributes:"kafka.topic"::STRING AS topic,
  record_attributes:"kafka.partition"::STRING AS partition,
  SUM(value::NUMBER) AS messages
FROM SNOWFLAKE.TELEMETRY.EVENTS
WHERE timestamp > DATEADD(day, -1, SYSDATE())
  AND record_type = 'METRIC'
  AND record:metric:name = 'kafka.records.consumed'
GROUP BY hour, connector, topic, partition
ORDER BY hour;

Plot consumer lag over time

This query returns how many records this consumer was behind for each topic and partition over the last 24 hours. To plot it, show the results as a line chart with timestamp on the X-axis and records_behind on the Y-axis.

SELECT
  timestamp,
  record_attributes:"connector.name"::STRING AS connector,
  record_attributes:"kafka.topic"::STRING AS topic,
  record_attributes:"kafka.partition"::STRING AS partition,
  value::NUMBER AS records_behind
FROM SNOWFLAKE.TELEMETRY.EVENTS
WHERE timestamp > DATEADD(day, -1, SYSDATE())
  AND record_type = 'METRIC'
  AND record:metric:name = 'kafka.records.consumer.lag'
ORDER BY timestamp;

Count rows sent to each destination

This query returns the number of rows sent for each destination per hour in the last 24 hours. Each value covers one 60-second interval, so the query sums the values:

SELECT
  DATE_TRUNC(hour, timestamp) AS hour,
  record_attributes:"connector.name"::STRING AS connector,
  record_attributes:"destination.database.name"::STRING AS destination_database,
  record_attributes:"destination.schema.name"::STRING AS destination_schema,
  record_attributes:"destination.pipe.name"::STRING AS destination_pipe,
  SUM(value::NUMBER) AS rows_sent
FROM SNOWFLAKE.TELEMETRY.EVENTS
WHERE timestamp > DATEADD(day, -1, SYSDATE())
  AND record_type = 'METRIC'
  AND record:metric:name = 'snowpipe.streaming.rows.sent'
GROUP BY hour, connector, destination_database, destination_schema, destination_pipe
ORDER BY hour;

Plot push latency over time

This query returns the highest time from when the connector read the data until it was pushed to Snowpipe Streaming, for each destination over the last 24 hours. To plot it, show the results as a line chart with timestamp on the X-axis and latency_seconds on the Y-axis.

SELECT
  timestamp,
  record_attributes:"connector.name"::STRING AS connector,
  record_attributes:"destination.database.name"::STRING AS destination_database,
  record_attributes:"destination.schema.name"::STRING AS destination_schema,
  record_attributes:"destination.pipe.name"::STRING AS destination_pipe,
  value::NUMBER / 1000 AS latency_seconds
FROM SNOWFLAKE.TELEMETRY.EVENTS
WHERE timestamp > DATEADD(day, -1, SYSDATE())
  AND record_type = 'METRIC'
  AND record:metric:name = 'snowpipe.streaming.consume.to.push.latency'
ORDER BY timestamp;