Apache Kafka is a stream-processing platform for handling real-time data. Using xk6-output-kafka extension, you can send k6 metrics in real-time to Kafka, and, optionally, ingest them from InfluxDB.
Build the k6 version
To build a k6 binary with the extension, first, ensure you have installed Go and Git; the following steps are:
xk6 will create the k6 binary in the local folder.
To learn more about how to build custom k6 versions, check out xk6
Run the k6 test
You can configure the broker (or multiple ones), topic and message format directly from the command line parameter like this:
or if you want multiple brokers:
You can also specify the message format k6 will use. By default, it will be the same as the JSON output, but you can also use the InfluxDB line protocol for direct "consumption" by InfluxDB:
You can even modify some of the format settings such as tagsAsFields:
Options
Here is the full list of options that can be configured and passed to the extension:
Name | Type | Description |
---|---|---|
K6_KAFKA_BROKERS | string | List of brokers |
K6_KAFKA_TOPIC | string | The name of the topic to be sent |
K6_KAFKA_AUTH_MECHANISM | string | Authentication mechanism. Default none. |
K6_KAFKA_SASL_USER | string | Kafka User |
K6_KAFKA_SASL_PASSWORD | string | Kafka User Password |
K6_KAFKA_SSL | boolean | |
K6_KAFKA_VERSION | string | Kafka version. Default the latest |
K6_KAFKA_INSECURE_SKIP_TLS_VERIFY | boolean | Whether should ignore TLS verifications |
K6_KAFKA_PUSH_INTERVAL | string | Interval of the metrics' aggregation and upload to the endpoint |
K6_KAFKA_FORMAT | string | Message format. json or influxdb |
K6_KAFKA_LOG_ERROR | boolean | Boolean indicating to log kafka errors |