Skip to main content
New to Testkube? Unleash the power of cloud native testing in Kubernetes with Testkube. Get Started >

Resource Metrics

Testkube automatically collects resource metrics for your workflow executions to help you understand their resource usage and optimize accordingly. This functionality allows you to identify Workflows that

  • Are over-provisioned for their needs, resulting in unnecessary resource allocation and costs.
  • Are under-provisioned for their needs, resulting in unnecessarily long Workflow executions.
  • Display unexpected resource-usage patterns over time (spikes, gradual increases, etc.)

Metrics Collected

Testkube samples the following metrics and calculates aggregates for each Workflow Step that runs a container command:

MetricValue TypesAggregatesDescription
CPUmillicoresmin, max, avg, totalCPU usage in milicores over time
Memorybytesmin, max, avg, totalMemory usage in bytes over time
Network Trafficbytessent/received min, max, avg, totalNetwork traffic (read/write) in bytes per second
Disk IObytesread/write min, max, avg, totalDisk operations (read/write) in bytes per second
note

The default sampling frequency is 1 second, please note that for short running tests (less than 3 seconds), this can lead to misleading/insufficient data for performing accurate metrics analysis and visualisation.

Metrics Visualisation

Collected metrics and related metadata is visualized in the "Resource Usage" tab for a Workflow execution:

Basic Resource Usage

There are four charts:

  • CPU - shows CPU usage over time for each pod/node, with CPU requests and limits as dashed and dotted lines respectively.
  • Memory - shows memory usage over time for each pod/node, with Memory requests and limits as dashed and dotted lines respectively.
  • Network Traffic - shows ingoing/outgoing network traffic over time.
  • Disk Usage - shows data read/written over time.

The y-axis is logarithmic for the CPU and Memory charts, linear for Network and Disk Usage.

Moving the pointer over the chart will automatically highlight and show details for the corresponding data-point, as shown for the selected 10:21:08 timestamp above.

The corresponding Workflow for the execution above had the following Resource Request defined:

...
container:
workingDir: /data/repo/test/pytest/pytest-project
image: python:3.12.6-alpine3.20
resources:
requests:
cpu: 256m
memory: 256Mi
...

As you can see in the chart:

  • the CPU usage was well above the requested 256m for the initial seconds, but dropped below for the rest of the execution
  • the memory usage was far below the requested 256Mi during the entire execution
  • there were early spikes for both network traffic and disk usage, which were expected for the underlying test itself.

Since the Workflow had no Resource Limits defined, the default limits for CPU and Memory are shown in the charts.

The below example runs a Cypress test that has both requests and limits defined as follows:

...
resources:
limits:
cpu: 2
memory: 2Gi
requests:
cpu: 2
memory: 2Gi
...

which shows the following charts:

Advanced Resource Usage

Visualisation of multiple-step Workflows

For Workflows with multiple steps, these are separated by purple lines, for example:

Multi-Step Resource Usage

This Workflow has 5 steps, each indicated with a vertical dotted line in the charts. Hovering over a specific line shows the name of the step on the top of the chart.

Visualisation of parallel Nodes

When looking at resource metrics for a Workflow Execution that ran across multiple nodes, each node will be visualised separately, for example the following k6 test that ran across 5 nodes:

Parallel Nodes Workflow

shows the following resource usage, where each node has their own line in each chart:

Parallel Nodes Resource Usage

Clicking on the individual labels for each line shows/hides them from the graph; in the below graph all Worker Writes have been deselected to show only Worker Reads in the graph:

Parallel Node Line Selection

Aggregate Visualisation

Hovering the Resource-Metric indicator in the Execution details and Execution list displays that executions average and peak value for each metric.

Execution Details:

Metric Aggregates in Execution Details

Execution List:

Metric Aggregates in Exection List

Resource Aggregates in Insights

The Test Insights module exposes aggregate metrics for analysis:

Resource Metrics in Insights

Selecting a metric allows you to select which value to use in the diagram:

Resource Metric Values in Insights

Available aggregates in Insights

Selecting a Metric value further allows you to select which aggregate to use in the diagram:

Resource Metric Aggregates in Insights

The following aggregates are available for each metric across selected Executions:

MetricMetric AggregateInsights AggregateDescription
CPU UsageMillicores minminThe min CPU Usage for all selected Executions
maxThe highest min CPU Usage for all selected Executions
Millicores maxminThe smallest max CPU Usage for all selected Executions
maxThe max CPU Usage for all selected Executions
Millicores avgaverageThe average avg CPU Usage for all selected Executions
Millicores totalsumThe total CPU Usage for all selected Executions
Memory UsageUsed minminThe min Memory Usage for all selected Executions
maxThe highest min Memory Usage for all selected Executions
Used maxminThe smallest max Memory Usage for all selected Executions
maxThe max Memory Usage for all selected Executions
Used avgaverageThe average avg Memory Usage for all selected Executions
Used totalsumThe total Memory Usage for all selected Executions
Network UsageSent minminThe min bytes sent for all selected Executions
maxThe highest min bytes sent for all selected Executions
Sent maxminThe smallest max bytes sent for all selected Executions
maxThe max bytes sent for all selected Executions
Sent avgaverageThe average avg bytes sent for all selected Executions
Sent totalsumThe total bytes sent for all selected Executions
Received minminThe min bytes received for all selected Executions
maxThe highest min bytes received for all selected Executions
Received maxminThe smallest max bytes received for all selected Executions
maxThe max bytes received for all selected Executions
Received avgaverageThe average avg bytes received for all selected Executions
Received totalsumThe total bytes received for all selected Executions
Disk UsageRead minminThe min bytes read for all selected Executions
maxThe highest min bytes read sent for all selected Executions
Read maxminThe smallest max bytes read for all selected Executions
maxThe max bytes read for all selected Executions
Read avgaverageThe average avg bytes read for all selected Executions
Read totalsumThe total bytes read for all selected Executions
Write minminThe min bytes written for all selected Executions
maxThe highest min bytes written for all selected Executions
Write maxminThe smallest max bytes written for all selected Executions
maxThe max bytes written for all selected Executions
Write avgaverageThe average avg bytes written for all selected Executions
Write totalsumThe total bytes written for all selected Executions