Kafka
Produce Dataflow's events to a Kafka topic over TLS, with a SASL user whose ACLs only allow writing to it.
Each event becomes one record on your topic. Dataflow connects over TLS and signs in with SASL (SCRAM or PLAIN).
Set up Kafka
Open a TLS listener with SASL to the internet
Dataflow connects with TLS and SASL, on port 9092, 9093, 9094 or 9096 (or 5671). Every broker of the cluster must be reachable this way, not only those you list: Kafka hands out the addresses in its advertised listeners, and Dataflow connects to them too. Each must resolve to a public address, on one of those ports, with a certificate valid for its host name and issued by a public certificate authority.
Supported SASL mechanisms: SCRAM-SHA-512 (default), SCRAM-SHA-256 and PLAIN.
Create the topic and a SASL user
kafka-topics.sh --bootstrap-server broker-1.example.com:9093 --command-config admin.properties \
--create --topic dataflow-events --partitions 3
kafka-configs.sh --bootstrap-server broker-1.example.com:9093 --command-config admin.properties \
--alter --entity-type users --entity-name dataflow \
--add-config 'SCRAM-SHA-512=[password=A_LONG_RANDOM_PASSWORD]'On a managed service, create the user or API key in its console instead.
Allow it to write to that topic only
kafka-acls.sh --bootstrap-server broker-1.example.com:9093 --command-config admin.properties \
--add --allow-principal User:dataflow \
--operation Write --operation Describe --topic dataflow-eventsWrite sends records and Describe reads the topic's metadata. Nothing else is needed: deliveries do not use transactions or idempotent writes.
Add the destination
curl https://dataflow.piloterr.com/v1/destinations \
-H "x-api-key: YOUR_API_KEY" -H "content-type: application/json" \
-d '{
"type": "kafka",
"config": {
"brokers": ["broker-1.example.com:9093", "broker-2.example.com:9093"],
"topic": "dataflow-events",
"sasl_mechanism": "scram-sha-512",
"tls": true
},
"credentials": { "username": "dataflow", "password": "A_LONG_RANDOM_PASSWORD" },
"topics": ["*"]
}'| Field | Required | Secret | Holds |
|---|---|---|---|
config.brokers | yes | no | Up to 10 bootstrap brokers, host:port. |
config.topic | yes | no | The topic's name. |
config.sasl_mechanism | no | no | scram-sha-512 (default), scram-sha-256 or plain. |
config.tls | no | no | true by default, and required. |
credentials.username | yes | yes | The SASL user name (or a managed service's API key). |
credentials.password | yes | yes | Its password (or API secret). |
Credentials are stored encrypted and shown masked. To change them, send both again with PATCH. See Credentials.
Network
Dataflow connects from our egress address, 116.203.84.164 (exit_ips of GET /v1/destinations/types): allow it on the brokers' port in your firewall. Private addresses, names that resolve to one, TLS turned off and other ports are refused when you save (422 validation_failed) for the brokers you list; an advertised broker that breaks these rules makes deliveries fail.
What the topic receives
- Value: the event payload, as JSON.
- Key: the event id, the payload's
id. Records of the same event go to the same partition. - Headers:
content-type(application/json),event-id(deduplicate on it),topic(such asrun.completed) andtimestamp(when it was sent, RFC 3339).
Records are produced without waiting for the broker's acknowledgement (acks=0): OK in the delivery log means the record was sent, not that the broker stored it. A record over the topic's max.message.bytes is dropped by the broker: raise it above 1 MiB if you subscribe to run.results.
Test it
Send a test event from the dashboard, or POST /v1/destinations/{id}/test (details), then read the topic:
kafka-console-consumer.sh --bootstrap-server broker-1.example.com:9093 --consumer.config client.properties \
--topic dataflow-events --from-beginning --property print.headers=truecode or error | Fix |
|---|---|
422 validation_failed on config.brokers.0 | Write each broker as host:port, with a public host and an open port. |
dns_error, connection_refused, timeout | Check the brokers, their advertised listeners, and that your firewall allows our address. |
tls_error | Use certificates from a public authority, valid for each broker's host name. |
auth_failed | Check the user, the password and the SASL mechanism. |
topic_not_found | Create the topic, or check its name. |
message_too_large | Raise the topic's max.message.bytes. |
Other errors: Errors.