Skip to content

[benchmark]: collect resource metrics during benchmark runs#21759

Open
AR21SM wants to merge 1 commit into
etcd-io:mainfrom
AR21SM:feat/benchmark-prometheus-metrics
Open

[benchmark]: collect resource metrics during benchmark runs#21759
AR21SM wants to merge 1 commit into
etcd-io:mainfrom
AR21SM:feat/benchmark-prometheus-metrics

Conversation

@AR21SM
Copy link
Copy Markdown

@AR21SM AR21SM commented May 17, 2026

related issues #21634 , #16467

This PR adds prometheus resource metric sampling to the benchmark report path.

When --metrics-url is provided, the benchmark samples the following etcd resource metrics during the run:

  • process_resident_memory_bytes
  • go_memstats_heap_alloc_bytes
  • go_memstats_heap_inuse_bytes

The max value for each sampled metric is appended to the existing perfdash JSON report when --report-perfdash is enabled.

Raw sampled resource metric time-series are written to a separate JSON artifact:

  • EtcdResourceMetrics_benchmark_<operation>_<timestamp>.json

sample artifact snippets from local run:

{
 "version": "v1",
 "dataItems": [
   {
     "data": {
       "Perc50": 0.5683,
       "Perc90": 0.809,
       "Perc99": 1.7786
     },
     "labels": {
       "Operation": "PUT"
     },
     "unit": "ms"
   },
   {
     "data": {
       "Max": 39854080
     },
     "labels": {
       "Metric": "process_resident_memory_bytes",
       "Operation": "PUT"
     },
     "unit": "bytes"
   },
   {
     "data": {
       "Max": 5165704
     },
     "labels": {
       "Metric": "go_memstats_heap_alloc_bytes",
       "Operation": "PUT"
     },
     "unit": "bytes"
   },
   {
     "data": {
       "Max": 7127040
     },
     "labels": {
       "Metric": "go_memstats_heap_inuse_bytes",
       "Operation": "PUT"
     },
     "unit": "bytes"
   }
 ]
}

{
  "version": "v1",
  "operation": "PUT",
  "samples": [
    {
      "timestamp": "2026-05-17T03:54:28.369478719Z",
      "values": {
        "go_memstats_heap_alloc_bytes": 4903944,
        "go_memstats_heap_inuse_bytes": 7086080,
        "process_resident_memory_bytes": 39854080
      }
    },
    {
      "timestamp": "2026-05-17T03:54:29.039713056Z",
      "values": {
        "go_memstats_heap_alloc_bytes": 5165704,
        "go_memstats_heap_inuse_bytes": 7127040,
        "process_resident_memory_bytes": 39854080
      }
    }
  ]
}

Signed-off-by: AR21SM <mahajanashishar21sm@gmail.com>
@k8s-ci-robot
Copy link
Copy Markdown

Hi @AR21SM. Thanks for your PR.

I'm waiting for a etcd-io member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work.

Tip

We noticed you've done this a few times! Consider joining the org to skip this step and gain /lgtm and other bot rights. We recommend asking approvers on your previous PRs to sponsor you.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-ci-robot
Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: AR21SM
Once this PR has been reviewed and has the lgtm label, please assign ahrtr for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@AR21SM
Copy link
Copy Markdown
Author

AR21SM commented May 17, 2026

cc @serathius @siyuanfoundation :)

@siyuanfoundation
Copy link
Copy Markdown
Contributor

I have verified it works as described.

@kishen-v Can you verify the change is compatible with the expected data format of perf-dash?


generatePerfReport bool

metricsURL string
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

the metrics collector should just use the same endpoint as the benchmark with /metrics path.
instead of using the url as an argument, it's better to pass in a list of metric names.

Comment thread pkg/report/report.go
var summaries []MetricSummary
var samples []MetricSample
if sampler != nil {
summaries, samples = sampler.stop()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

if something fails before this line, sampler.stop() will never be called.

Comment thread pkg/report/perfdash.go
Samples []MetricSample `json:"samples"`
}

func writeMetricTimeSeriesReport(benchmarkOp string, samples []MetricSample) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could be generalized to cover writePerfDashReport. The metric for that would be latency

Comment thread pkg/report/metrics.go
client *http.Client

mu sync.Mutex
samples map[string][]float64
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

what is the difference between samples and series?
more documentation in general will be appreciated

@kishen-v
Copy link
Copy Markdown
Contributor

kishen-v commented May 21, 2026

@kishen-v Can you verify the change is compatible with the expected data format of perf-dash?

Hey @siyuanfoundation, Sure! I'll take a look at the changes and also confirm if it is in-line with what perf-dash expects. Will update the findings here in a day or two.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

4 participants