Skip to content

Commit

Permalink
add a no label benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
sontek committed Jan 2, 2023
1 parent 585ecbf commit a994323
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
2 changes: 1 addition & 1 deletion benchmarking/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ We are using [k6](https://k6.io/) for our benchmarking. To run one of the perfor
tests you can do:

```
k6 run -e PAG_HOST=http://localhost --vus 10 --duration 30s benchmarking/perf1.js
k6 run -e PAG_HOST=http://localhost --vus 10 --duration 30s benchmarking/labels.js
```
File renamed without changes.
36 changes: 36 additions & 0 deletions benchmarking/no_labels.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import http from 'k6/http';
import { check } from 'k6';

function getRandInteger(min, max) {
return Math.floor(Math.random() * (max - min) ) + min;
}

/*
Original prom-agg-gateway doesn't support labels so this perf test
is here mostly to compare against them.
*/
export default function () {
const url = `${__ENV.PAG_HOST}/metrics/`;

const randomMetric1 = getRandInteger(1, 50)
const randomMetric2 = getRandInteger(1000, 3000)
const randomMetric3 = getRandInteger(3000, 4000)

const payload = `
# TYPE some_metric counter
some_metric{label="val1"} ${randomMetric1}
# TYPE another_metric gauge
# HELP another_metric Just an example.
another_metric ${randomMetric2}
k6_http_requests_total{method="post",code="200"} ${randomMetric3}
`

const params = {
headers: {
'Content-Type': 'application/json',
},
};

const res = http.post(url, payload, params);
check(res, { 'status was 200ish': (r) => r.status < 300 });
}

0 comments on commit a994323

Please sign in to comment.