Coder Social home page Coder Social logo

xk6-output-kafka's Introduction

xk6-output-kafka

This extension is extracted from the k6 kafka output so it can be used with xk6.

Build

To build a k6 binary with this extension, first ensure you have the prerequisites:

  1. Build with xk6:
xk6 build --with github.com/grafana/xk6-output-kafka

This will result in a k6 binary in the current directory.

  1. Run with the just built k6:
./k6 run -o xk6-kafka <script.js>

Instructions

You can configure the broker (or multiple ones), topic, and message format directly from the command line parameter like this:

./k6 run --out xk6-kafka=brokers=broker_host:9092,topic=k6

or if you want multiple brokers:

./k6 --out xk6-kafka=brokers={broker1,broker2},topic=k6,format=json

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:

./k6 --out xk6-kafka=brokers=someBroker,topic=someTopic,format=influxdb

You can even modify some of the format settings such as tagsAsFields:

./k6 --out xk6-kafka=brokers=someBroker,topic=someTopic,format=influxdb,influxdb.tagsAsFields={url,myCustomTag}

Testing Locally

This repo includes a docker-compose.yml file that starts local Kafka environment with several dependencies and utilities baked-in. See lensesio/fast-data-dev for more information.

⚠️ Be sure that you've already compiled your custom k6 binary as described in the Build section!

We'll use this environment to run some examples.

  1. Start the docker compose environment.

    docker compose up -d

    Once you see the following, you should be ready.

     [+] Running 2/2
     ⠿ Network xk6-output-kafka_default       Created
     ⠿ Container xk6-output-kafka-lensesio-1  Started

    Next, we'll use the k6 binary we compiled in the Build section above.

  2. Open http://localhost:3030/ to display the landing page for your local Kafka Development environment provided by the docker image. From there, you can select the Kafka Topics UI.

  3. Using our custom k6 binary, we can execute our example script outputting test metrics to kafka.

    ./k6 run --out xk6-kafka=brokers={localhost:9092},topic=k6-metrics examples/simple.js

    Refreshing your browser should now list the k6-metrics topic. Clicking into the topic will now show messages for real-time metrics published during the k6 test execution.

See also

xk6-output-kafka's People

Contributors

javaducky avatar mstoykov avatar olegbespalov avatar ppcano avatar victorlcm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

xk6-output-kafka's Issues

Document config options

The part of the Readme related to the configuration is linking to the old Kafka documentation that it is not providing a detailed documentation about the available options.

The suggestion is to add a table listing all the dedicated options that this extension is adding.

Remove dependency on k6's json and InfluxDB outputs

Both of the dependencies are so Kafka can format metrics in both of the formats.

While it's probably not great to copy-paste this code the alternative is that any changes to those might break this extension which especially as time goes by will not be an easy thing to avoid.

Even now the InfluxDB output will need to be refactored and moved from the old "collector" interface to the "Output" one, which will break this extension 😭.

Additionally, for InfluxDB we should probably copy 1-2 configurations such as tagsAsFields and precision.

We also intend on updating the influxdb library in k6 to support v2 which may or may not mean we will drop v1, but also means that the API will likely change and that

Given all of the above, I do think it's probably better to do this change now and drop any dependency on k6 that isn't the Output interface and its registration

Move to v2 of the influxdb api

it is only used to make the influxdb points so it should be 100% forward compatible given what I know of the problem, but maybe it will have slightly better performance and won't use a library that is deprecated at this point

SyncProducer performance

Hi 👋

I'm currently using this extension in the company I work and we're having some issues regarding the performance of sending the messages to our Kafka Broker. In order to speed up things, me and @knmsk are currently working on a full rewrite to match the new Output struct in k6 repository and also changing the SyncProducer to AsyncProducer.

The Idea is to improve throughput by using the AsyncProducer, batching messages and running in go routines. Also, we think that we should include an option to wait for acks from Kafka or not. This should be a choice for the users if they're willing to lose some messages to gain performance

Please let us know what you think 😄

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.