Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update docs for new prometheus dashboards #1344

Merged
merged 12 commits into from
Sep 28, 2023
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ You can also stream real-time metrics to the following services:
- [Prometheus remote write](/results-output/real-time/prometheus-remote-write)
- [TimescaleDB](/results-output/real-time/timescaledb)
- [StatsD](/results-output/real-time/statsd)
- [Other alternative with a custom output extension](/extensions/get-started/create/output-extensions/)

</Glossary>

> This list applies to local tests. To send k6 Cloud test results to an external service, refer to
[Cloud APM](/cloud/integrations/cloud-apm/).
> This list applies to local tests, not to [cloud tests](https://grafana.com/docs/grafana-cloud/k6/).


## Read more
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,21 +47,48 @@ Select the **Details** of your Prometheus service.
Now, pass the Username, API key, and Remote Write Endpoint of the Grafana Cloud Prometheus Configuration to the k6 binary:

```bash
K6_PROMETHEUS_RW_USERNAME=Your_Username \
K6_PROMETHEUS_RW_PASSWORD=Your_API_KEY \
K6_PROMETHEUS_RW_SERVER_URL=Your_REMOTE_WRITE_ENDPOINT \
K6_PROMETHEUS_RW_USERNAME=USERNAME \
K6_PROMETHEUS_RW_PASSWORD=API_KEY \
K6_PROMETHEUS_RW_SERVER_URL=REMOTE_WRITE_ENDPOINT \
k6 run -o experimental-prometheus-rw script.js
```

## Explore k6 metrics
## Visualize test results

To explore k6 metrics in Grafana Cloud:
1. Click on the Explore icon on the menu bar.
1. Choose the Prometheus data source from the dropdown in the top left.
1. In the query field, query k6 metrics to explore your testing results.
To visualize test results with Grafana, you can import the [k6 Prometheus dashboard by Grafana k6](https://grafana.com/grafana/dashboards/19665-k6-prometheus/).

On the Dashboards UI:

- Click `New` and select `Import`.
- Paste the Grafana URL or ID of the dashboard, and click `Load`.
- Select the Prometheus data source, and click `Import`.

![k6 Prometheus Dashboard](./images/Prometheus/k6-prometheus-dashboard-part1.png)

Optionally, when running the test, you can set the `testid` tag as a [wide test tag](https://k6.io/docs/using-k6/tags-and-groups/#test-wide-tags) to filter results of a particular test run on this dashboard (or in PromQL queries). `testid` can be any unique string that allows you to identify the test run.

<CodeGroup labels={["Tag metrics with testid"]}>

```bash
K6_PROMETHEUS_RW_USERNAME=USERNAME \
K6_PROMETHEUS_RW_PASSWORD=API_KEY \
K6_PROMETHEUS_RW_SERVER_URL=REMOTE_WRITE_ENDPOINT \
k6 run -o experimental-prometheus-rw --tag testid=TEST_ID script.js
```

</CodeGroup>

Additionally, you can also use the [Explore UI](https://grafana.com/docs/grafana/latest/explore/) to query k6 time series, design your visualization panels, and add them to any of your existing dashboards.

![Explore k6 metrics in Grafana Cloud](./images/GrafanaCloud/grafana_cloud_explore_k6_metrics_from_extension.png)

## Read more
All the k6 time series have a **k6_** prefix.
For more details, refer to the documentation on the [mapping of k6 metrics with Prometheus metrics](/results-output/real-time/prometheus-remote-write/#metrics-mapping).

It's also important to understand the default [Trend metric conversion](/results-output/real-time/prometheus-remote-write/#trend-metric-conversions) process and the format and querying limitations. The [`K6_PROMETHEUS_RW_TREND_STATS` option](/results-output/real-time/prometheus-remote-write/#options) allows you to convert trend metrics to multiple Prometheus time series. For instance, `K6_PROMETHEUS_RW_TREND_STATS=p(95),p(99),max,min` transforms each k6 trend metric into four Prometheus metrics as follows:

- `k6_*_p95`
- `k6_*_p99`
- `k6_*_max`
- `k6_*_min`

- [K6 makes performance testing easy with Prometheus and Grafana in Docker](https://medium.com/@rody.bothe/turning-data-into-understandable-insights-with-k6-load-testing-fa24e326e221)

Large diffs are not rendered by default.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,21 @@ Having test results in a dashboard brings various benefits:

## Options

With [Grafana](https://grafana.com/grafana/), you can create a custom dashboard to query and **visualize data from multiple sources and any type of backend**. With k6, you can stream your test results to any backend using a [custom output extension](/extensions/get-started/create/output-extensions/) or an existing [real-time output](/results-output/real-time/#service).
With [Grafana](https://grafana.com/grafana/), you can create a custom dashboard to query and **visualize data from multiple sources and any type of backend**.
Using k6, you can [stream your local test results to any backend](/results-output/real-time).

The flexibility and interoperability of Grafana and k6 let you visualize test and observability data in one dashboard, regardless of where the data is stored.
The following outputs include pre-built Grafana dashboards for their storage:

| Output | Grafana Dashboard |
|---|---|
| [AWSTimestream](https://github.com/leonyork/xk6-output-timestream) | [leonyork/xk6-output-timestream](https://github.com/leonyork/xk6-output-timestream/tree/main/grafana/dashboards/) |
| [InfluxDB](/results-output/real-time/influxdb) | [grafana/xk6-output-influxdb](https://github.com/grafana/xk6-output-influxdb/tree/main/grafana/dashboards) |
| [Prometheus remote write](/results-output/real-time/prometheus-remote-write) | [k6 Prometheus](https://grafana.com/grafana/dashboards/19665-k6-prometheus/) |
| [Prometheus remote write (Native Histograms)](/results-output/real-time/prometheus-remote-write) | [k6 Prometheus (Native Histograms)](https://grafana.com/grafana/dashboards/18030-k6-prometheus-native-histograms/) |
| [Grafana Cloud Prometheus](/results-output/real-time/grafana-cloud-prometheus/) | [k6 Prometheus](https://grafana.com/grafana/dashboards/19665-k6-prometheus/) |
| [TimescaleDB](/results-output/real-time/timescaledb/) | [grafana/xk6-output-timescaledb](https://github.com/grafana/xk6-output-timescaledb/tree/main/grafana/dashboards) |
| ---- | [More public dashboards from the community](https://grafana.com/grafana/dashboards/?search=k6) |

The flexibility and interoperability of Grafana and k6 let you join test and observability data in one dashboard, independently of where the data is stored.

For inspiration about how to build a custom dashboard that visualizes k6 results, browse the list of [community-built k6 dashboards](https://grafana.com/grafana/dashboards/?search=k6). The following outputs include pre-built Grafana dashboards for their storage:

- [AWSTimestream](https://github.com/leonyork/xk6-output-timestream)
- [InfluxDB](/results-output/real-time/influxdb)
- [Prometheus remote write](/results-output/real-time/prometheus-remote-write)
- [TimescaleDB](/results-output/real-time/timescaledb/)

For a fully managed solution, [Grafana Cloud k6](https://grafana.com/products/cloud/k6/) is our commercial product to store, view, scale, and manage your tests with ease. It provides custom views to access your testing and analyze test results, enhanced collaboration features, and many more additional capabilities.
Loading