Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/martymarron/xk6-output-prometheus-pushgateway
This is a k6 extension for publishing test-run metrics to Prometheus via Pushgateway.
https://github.com/martymarron/xk6-output-prometheus-pushgateway
grafana k6 k6-extension load-testing performance-testing prometheus pushgateway xk6
Last synced: about 2 months ago
JSON representation
This is a k6 extension for publishing test-run metrics to Prometheus via Pushgateway.
- Host: GitHub
- URL: https://github.com/martymarron/xk6-output-prometheus-pushgateway
- Owner: martymarron
- License: apache-2.0
- Created: 2022-12-05T05:25:18.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-07-29T05:31:13.000Z (5 months ago)
- Last Synced: 2024-07-30T05:16:25.883Z (5 months ago)
- Topics: grafana, k6, k6-extension, load-testing, performance-testing, prometheus, pushgateway, xk6
- Language: Go
- Homepage:
- Size: 60.5 KB
- Stars: 10
- Watchers: 3
- Forks: 5
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-k6 - xk6-output-prometheus-pushgateway - Export results to Prometheus pushgateway. (Extensions / Community)
- awesome-k6 - xk6-output-prometheus-pushgateway - Export results to Prometheus pushgateway. (Extensions / Community)
README
xk6-output-prometheus-pushgateway
===
This is a k6 extension for publishing test-run metrics to Prometheus via [Pushgateway](https://prometheus.io/docs/instrumenting/pushing/).\
This extension is fully inspired by [xk6-output-prometheus-remote](https://github.com/grafana/xk6-output-prometheus-remote).\
There might be a circumstance not to enable the "[Remote Write](https://prometheus.io/docs/practices/remote_write/)" feature on your Prometheus instance. In that case, the [Pushgateway](https://prometheus.io/docs/instrumenting/pushing/) and this extension are possibly be an alternative solution.## Usage
```sh
% xk6 build --with github.com/martymarron/xk6-output-prometheus-pushgateway@latest
% K6_PUSHGATEWAY_URL=http://localhost:9091 \
K6_JOB_NAME=k6_load_testing \
./k6 run \
./script.js \
-o output-prometheus-pushgateway
```# Prometheus Labels
It is possible to add Prometheus labels with external JSON dictionary in `js` script
```
export const options = {
ext: {
"pushgateway": {
app: "myapp",
env: "myenv",
}
}
};
```or with environment variables
```
K6_LABEL_APP=myapp K6_LABEL_ENV=myenv k6 run ...
```It is possible to check Prometheus labels with debug output. It looks like
```
DEBU[0000] Pushgateway labels from JSON options.ext.pushgateway dictionary map[app:MYAPP env:MYENV url:MYURL]
DEBU[0000] Pushgateway labels map[app:MYAPP env:MYENV url:MYURL]
```The 1st line is Prometheus labels from `options.ext.pushgateway` dictionary.
The 2nd line is the final set of labels after merging `options.ext.pushgateway` dictionary and environment variables.
# Metrics prefix
It is possible to configure this output to expose the time series with a prefix.
Configure it with the following environment variable:
```
K6_PUSHGATEWAY_NAMESPACE=k6 k6 run ...
```