Skip to content

Add Prometheus metrics endpoint #4944

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

gouthamve
Copy link

I have a friend who is using k6 for some massive database load-tests that run for hours. However, k6 is OOMing sometimes and they'd like to understand if they need to modify GOGC values.

The easiest way for them to do it is to leverage the Prometheus Golang runtime metrics. This was brought up before in #3535 however, it was rejected for two reasons:

  1. client_golang dependency might go away in favor of OTel
  2. The future of metrics exposition is OTel

However I'd like to reopen this for two reasons. client_golang is a dependency of opentelemetry-go as well. So that dependency is not going away.

But the more important reason is that there are already many high performance Golang systems exposing /metrics and the metrics and tooling around them is pretty mature and extensive.

The OTel Golang runtime metrics are new and not yet stable: https://opentelemetry.io/docs/specs/semconv/runtime/go-metrics/ Reimplementing everything for these metrics is not a trivial effort.

  • I have performed a self-review of my code.
  • I have commented on my code, particularly in hard-to-understand areas.
  • I have added tests for my changes.
  • I have run linter and tests locally (make check) and all pass.

cc @joanlopez @oleiade @mstoykov @dgzlopes

Checklist: Documentation (only for k6 maintainers and if relevant)

Please do not merge this PR until the following items are filled out.

  • I have added the correct milestone and labels to the PR.
  • I have updated the release notes: link
  • I have updated or added an issue to the k6-documentation: grafana/k6-docs#NUMBER if applicable
  • I have updated or added an issue to the TypeScript definitions: grafana/k6-DefinitelyTyped#NUMBER if applicable

Related PR(s)/Issue(s)

I have a friend who is using k6 for some massive database load-tests
that run for hours. However, k6 is OOMing sometimes and they'd like to
understand if they need to modify GOGC values.

The easiest way for them to do it is to leverage the Prometheus Golang
runtime metrics. This was brought up before in grafana#3535 however, it was
rejected for two reasons:

1. `client_golang` dependency might go away in favor of OTel
2. The future of metrics exposition is OTel

However I'd like to reopen this for two reasons. `client_golang` is a
dependency of `opentelemetry-go` as well. So that dependency is not going
away.

But the more important reason is that there are already many high
performance Golang systems exposing `/metrics` and the metrics and tooling
around them is pretty mature and extensive.

The OTel Golang runtime metrics are new and not yet stable: https://opentelemetry.io/docs/specs/semconv/runtime/go-metrics/
Reimplementing everything for these metrics is not a trivial effort.

Signed-off-by: gouthamve <gouthamve@gmail.com>
@gouthamve gouthamve requested a review from a team as a code owner July 18, 2025 10:14
@gouthamve gouthamve requested review from ankur22 and codebien and removed request for a team July 18, 2025 10:14
@CLAassistant
Copy link

CLAassistant commented Jul 18, 2025

CLA assistant check
All committers have signed the CLA.

Copy link
Contributor

@ankur22 ankur22 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm probably not the best person to review this, but I'd like to get some clarification still. With this change, we would be exposing the standard Go runtime and process metrics that the client_golang library auto‐registers, correct? I don't think k6 registers any other data using prometheus.

@gouthamve
Copy link
Author

we would be exposing the standard Go runtime and process metrics that the client_golang library auto‐registers, correct?

Yes

@szkiba
Copy link
Contributor

szkiba commented Jul 18, 2025

FYI https://github.com/szkiba/xk6-prometheus
(an extension does similar or same thing)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants