Giter Club home page Giter Club logo

xk6-output-prometheus-remote's Introduction

xk6-output-prometheus-remote

k6 extension for publishing test-run metrics to Prometheus via Remote Write endpoint.

โš ๏ธ Not to be confused with Prometheus Remote Write client extension which is for load testing Prometheus itself.

๐Ÿ”– As of k6 v0.42.0, this extension is available within k6 as an experimental module. This means that the extension has entered the process of being fully merged into the core of k6 and does not require a special build with xk6 to utilize this feature.

See the Prometheus remote write guide to utilize this feature.

There are many options for remote-write compatible agents, the official list can be found here. The exact details of how metrics will be processed or stored depends on the underlying agent used.

Key points to know:

  • remote write format does not contain explicit definition of any metric types while metadata definition is still in flux and can have different implementation depending on the remote-write compatible agent
  • remote read is a separate interface and it is much less defined. For example, remote read may not work without precise queries; see here and here for details
  • some remote-write compatible agents may support additional formats for remote write, like JSON, but it is not part of official Prometheus remote write specification and therefore absent here

Usage

To build k6 binary with the Prometheus remote write output extension use:

xk6 build --with github.com/grafana/xk6-output-prometheus-remote@latest 

Then run new k6 binary with the following command for using the default configuration (e.g. remote write server url set to http://localhost:9090/api/v1/write):

./k6 run -o xk6-prometheus-rw script.js 

Check the documentation for advanced configurations.

Docker Compose

This repo includes a docker-compose.yml file that starts Prometheus, Grafana, and a custom build of k6 having the xk6-output-prometheus-remote extension.

Note: the docker-compose.yml file has the Native Histogram mapping set as enabled.

This is just a quick setup to show the usage. For a real use case, you will want to deploy outside of docker.

Clone the repo to get started and follow these steps:

  1. Start the docker compose environment.

    docker-compose up -d

    Some users have encountered failures for the k6 build portion. A workaround may be to disable the "Use Docker Compose V2" checkbox in the General section of Docker Desktop settings.

    # Output
    Creating xk6-output-prometheus-remote_grafana_1     ... done
    Creating xk6-output-prometheus-remote_prometheus_1  ... done
    Creating xk6-output-prometheus-remote_k6_1          ... done
  2. Use the k6 Docker image to run the k6 script and send metrics to the Prometheus container started on the previous step. You must set the testid tag with a unique identifier to segment the metrics into discrete test runs for the Grafana dashboards.

    docker-compose run --rm -T k6 run -<samples/test.js --tag testid=<SOME-ID>

    For convenience, the docker-run.sh can be used to simply:

    ./docker-run.sh samples/test.js
  3. Visit http://localhost:3000/ to view results in Grafana.

Dashboards

The docker-compose setup comes with some pre-built Grafana dashboards. Check the dashboard guide for details.

Note: The dashboards work with the Native Histogram mapping so it is required to enable it.

xk6-output-prometheus-remote's People

Contributors

codebien avatar jwcastillo avatar yorugac avatar javaducky avatar chr15murray avatar pablochacin avatar arukiidou avatar ppcano avatar robholland avatar oleiade avatar johncming avatar

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.