<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Metrics on Grafana Labs</title><link>https://grafana.com/docs/k6/v2.3.x/using-k6/metrics/</link><description>Recent content in Metrics on Grafana Labs</description><generator>Hugo -- gohugo.io</generator><language>en</language><atom:link href="/docs/k6/v2.3.x/using-k6/metrics/index.xml" rel="self" type="application/rss+xml"/><item><title>Built-in metrics</title><link>https://grafana.com/docs/k6/v2.3.x/using-k6/metrics/reference/</link><pubDate>Mon, 21 Sep 2026 15:16:28 +0000</pubDate><guid>https://grafana.com/docs/k6/v2.3.x/using-k6/metrics/reference/</guid><content><![CDATA[&lt;h1 id=&#34;built-in-metrics&#34;&gt;Built-in metrics&lt;/h1&gt;
&lt;p&gt;Every k6 test emits built-in and 
    &lt;a href=&#34;/docs/k6/v2.3.x/using-k6/metrics/create-custom-metrics/&#34;&gt;custom metrics&lt;/a&gt;.
Each supported protocol also has its specific metrics.&lt;/p&gt;
&lt;h2 id=&#34;standard-built-in-metrics&#34;&gt;Standard built-in metrics&lt;/h2&gt;
&lt;p&gt;k6 always collects the following metrics, no matter what protocol the test uses:&lt;/p&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Metric Name&lt;/th&gt;
              &lt;th&gt;Type&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;checks&lt;/td&gt;
              &lt;td&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-metrics/rate/&#34;&gt;Rate&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;The rate of successful checks. In the end-of-test summary, this metric is displayed as three values: &lt;code&gt;checks_total&lt;/code&gt; (Counter), &lt;code&gt;checks_succeeded&lt;/code&gt; (Rate), and &lt;code&gt;checks_failed&lt;/code&gt; (Rate). These display values are not emitted to output backends and cannot be used in thresholds.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;data_received&lt;/td&gt;
              &lt;td&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-metrics/counter/&#34;&gt;Counter&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;The amount of received data. 
    &lt;a href=&#34;/docs/k6/v2.3.x/examples/track-transmitted-data-per-url/&#34;&gt;This example covers how to track data for an individual URL&lt;/a&gt;.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;data_sent&lt;/td&gt;
              &lt;td&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-metrics/counter/&#34;&gt;Counter&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;The amount of data sent. 
    &lt;a href=&#34;/docs/k6/v2.3.x/examples/track-transmitted-data-per-url/&#34;&gt;Track data for an individual URL&lt;/a&gt; to track data for an individual URL.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;dropped_iterations&lt;/td&gt;
              &lt;td&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-metrics/counter/&#34;&gt;Counter&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;The number of iterations that weren&amp;rsquo;t started due to lack of VUs (for the arrival-rate executors) or lack of time (expired maxDuration in the iteration-based executors). Refer to 
    &lt;a href=&#34;/docs/k6/v2.3.x/using-k6/scenarios/concepts/dropped-iterations/&#34;&gt;Dropped iterations&lt;/a&gt; for more details.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;iteration_duration&lt;/td&gt;
              &lt;td&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-metrics/trend/&#34;&gt;Trend&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;The time to complete one full iteration, including time spent in &lt;code&gt;setup&lt;/code&gt; and &lt;code&gt;teardown&lt;/code&gt;. To calculate the duration of the iteration&amp;rsquo;s function for the specific scenario, 
    &lt;a href=&#34;/docs/k6/v2.3.x/using-k6/workaround-iteration-duration/&#34;&gt;try this workaround&lt;/a&gt;.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;iterations&lt;/td&gt;
              &lt;td&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-metrics/counter/&#34;&gt;Counter&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;The aggregate number of times the VUs execute the JS script (the &lt;code&gt;default&lt;/code&gt; function).&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;vus&lt;/td&gt;
              &lt;td&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-metrics/gauge/&#34;&gt;Gauge&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;Current number of active virtual users&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;vus_max&lt;/td&gt;
              &lt;td&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-metrics/gauge/&#34;&gt;Gauge&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;Max possible number of virtual users (VU resources are 
    &lt;a href=&#34;/docs/k6/v2.3.x/using-k6/scenarios/concepts/arrival-rate-vu-allocation/&#34;&gt;pre-allocated&lt;/a&gt;, to avoid affecting performance when scaling up load).&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h2 id=&#34;http&#34;&gt;HTTP-specific built-in metrics&lt;/h2&gt;
&lt;p&gt;These metrics are generated only when the test makes HTTP requests.&lt;/p&gt;


&lt;div class=&#34;admonition admonition-note&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Note&lt;/p&gt;&lt;p&gt;For all &lt;code&gt;http_req_*&lt;/code&gt; metrics, &lt;strong&gt;the timestamp is emitted the end of the request.&lt;/strong&gt;
In other words, the timestamp happens when k6 receives the end of the response body, or the request times out.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Metric Name&lt;/th&gt;
              &lt;th&gt;Type&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;http_req_blocked&lt;/td&gt;
              &lt;td&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-metrics/trend/&#34;&gt;Trend&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;Time spent blocked (waiting for a free TCP connection slot) before initiating the request. &lt;code&gt;float&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;http_req_connecting&lt;/td&gt;
              &lt;td&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-metrics/trend/&#34;&gt;Trend&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;Time spent establishing TCP connection to the remote host. &lt;code&gt;float&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;http_req_duration&lt;/td&gt;
              &lt;td&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-metrics/trend/&#34;&gt;Trend&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;Total time for the request. It&amp;rsquo;s equal to &lt;code&gt;http_req_sending &#43; http_req_waiting &#43; http_req_receiving&lt;/code&gt; (i.e. how long did the remote server take to process the request and respond, without the initial DNS lookup/connection times). &lt;code&gt;float&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;http_req_failed&lt;/td&gt;
              &lt;td&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-metrics/rate/&#34;&gt;Rate&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;The rate of failed requests according to 
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-http/set-response-callback/&#34;&gt;setResponseCallback&lt;/a&gt;.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;http_req_receiving&lt;/td&gt;
              &lt;td&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-metrics/trend/&#34;&gt;Trend&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;Time spent receiving response data from the remote host. &lt;code&gt;float&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;http_req_sending&lt;/td&gt;
              &lt;td&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-metrics/trend/&#34;&gt;Trend&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;Time spent sending data to the remote host. &lt;code&gt;float&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;http_req_tls_handshaking&lt;/td&gt;
              &lt;td&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-metrics/trend/&#34;&gt;Trend&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;Time spent handshaking TLS session with remote host&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;http_req_waiting&lt;/td&gt;
              &lt;td&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-metrics/trend/&#34;&gt;Trend&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;Time spent waiting for response from remote host (a.k.a. “time to first byte”, or “TTFB”). &lt;code&gt;float&lt;/code&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;http_reqs&lt;/td&gt;
              &lt;td&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-metrics/counter/&#34;&gt;Counter&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;How many total HTTP requests k6 generated.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h2 id=&#34;browser&#34;&gt;Browser metrics&lt;/h2&gt;
&lt;p&gt;The 
    &lt;a href=&#34;/docs/k6/v2.3.x/using-k6-browser/&#34;&gt;k6 browser module&lt;/a&gt; emits its own metrics based on the &lt;a href=&#34;https://web.dev/vitals/#core-web-vitals&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Core Web Vitals&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;These core metrics will evolve over time when technology changes, but for now, k6 tracks the following core web vitals:&lt;/p&gt;


&lt;div data-shared=&#34;browser/web-vital-core-metrics.md&#34;&gt;
            &lt;!-- vale off --&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Metric name&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;browser_web_vital_cls&lt;/td&gt;
              &lt;td&gt;Measures the visual stability on a webpage by quantifying the amount of unexpected layout shift of visible page content. Refer to &lt;a href=&#34;https://web.dev/cls/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Cumulative Layout Shift&lt;/a&gt; for more information.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;browser_web_vital_inp&lt;/td&gt;
              &lt;td&gt;A metric that measures a page&amp;rsquo;s responsiveness. Refer to &lt;a href=&#34;https://web.dev/inp/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Interaction to Next Paint&lt;/a&gt; for more information.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;browser_web_vital_lcp&lt;/td&gt;
              &lt;td&gt;Measures the time it takes for the largest content element on a page to become visible. Refer to &lt;a href=&#34;https://web.dev/lcp/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Largest Contentful Paint&lt;/a&gt; for more information.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;!-- vale on --&gt;
&lt;/div&gt;

        
&lt;h3 id=&#34;other-web-vitals&#34;&gt;Other Web Vitals&lt;/h3&gt;
&lt;p&gt;Apart from the Core Web Vitals, the browser module also reports &lt;a href=&#34;https://web.dev/vitals/#other-web-vitals&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Other Web Vitals&lt;/a&gt;.&lt;/p&gt;


&lt;div data-shared=&#34;browser/web-vital-other-metrics.md&#34;&gt;
            &lt;!-- vale off --&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Metric name&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;browser_web_vital_fcp&lt;/td&gt;
              &lt;td&gt;Measures the time it takes for the browser to render the first DOM element on the page, whether that&amp;rsquo;s a text, image or header. Refer to &lt;a href=&#34;https://web.dev/fcp/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;First Contentful Paint&lt;/a&gt; for more information.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;browser_web_vital_ttfb&lt;/td&gt;
              &lt;td&gt;Measures the time it takes between the browser request and the start of the response from a server. Refer to &lt;a href=&#34;https://web.dev/ttfb/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;Time to First Byte&lt;/a&gt; for more information.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;!-- vale on --&gt;
&lt;/div&gt;

        
&lt;h2 id=&#34;websockets&#34;&gt;Built-in WebSocket metrics&lt;/h2&gt;
&lt;p&gt;&lt;code&gt;k6&lt;/code&gt; emits the following metrics when interacting with a WebSocket service through the 
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-websockets/&#34;&gt;&lt;code&gt;k6/websockets&lt;/code&gt;&lt;/a&gt; or legacy &lt;code&gt;k6/ws&lt;/code&gt; API.&lt;/p&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Metric name&lt;/th&gt;
              &lt;th&gt;Type&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;ws_connecting&lt;/td&gt;
              &lt;td&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-metrics/trend/&#34;&gt;Trend&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;Total duration for the WebSocket connection request.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;ws_msgs_received&lt;/td&gt;
              &lt;td&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-metrics/counter/&#34;&gt;Counter&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;Total number of messages received&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;ws_msgs_sent&lt;/td&gt;
              &lt;td&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-metrics/counter/&#34;&gt;Counter&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;Total number of messages sent&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;ws_ping&lt;/td&gt;
              &lt;td&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-metrics/trend/&#34;&gt;Trend&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;Duration between a ping request and its pong reception&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;ws_session_duration&lt;/td&gt;
              &lt;td&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-metrics/trend/&#34;&gt;Trend&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;Duration of the WebSocket session. Time between the start of the connection and the end of the VU execution.&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;ws_sessions&lt;/td&gt;
              &lt;td&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-metrics/counter/&#34;&gt;Counter&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;Total number of started WebSocket sessions.&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;&lt;h2 id=&#34;grpc&#34;&gt;Built-in gRPC metrics&lt;/h2&gt;
&lt;p&gt;k6 emits the following metrics when it interacts with a service through the 
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-net-grpc/&#34;&gt;&lt;code&gt;gRPC&lt;/code&gt;&lt;/a&gt; API.&lt;/p&gt;
&lt;section class=&#34;expand-table-wrapper&#34;&gt;&lt;div class=&#34;button-div&#34;&gt;
      &lt;button class=&#34;expand-table-btn&#34;&gt;Expand table&lt;/button&gt;
    &lt;/div&gt;&lt;div class=&#34;responsive-table-wrapper&#34;&gt;
    &lt;table&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;Metric Name&lt;/th&gt;
              &lt;th&gt;Type&lt;/th&gt;
              &lt;th&gt;Description&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;grpc_req_duration&lt;/td&gt;
              &lt;td&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-metrics/trend/&#34;&gt;Trend&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;Time to receive response from remote host&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;grpc_streams&lt;/td&gt;
              &lt;td&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-metrics/counter/&#34;&gt;Counter&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;Total number of started streams&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;grpc_streams_msgs_received&lt;/td&gt;
              &lt;td&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-metrics/counter/&#34;&gt;Counter&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;Total number of messages received&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;grpc_streams_msgs_sent&lt;/td&gt;
              &lt;td&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-metrics/counter/&#34;&gt;Counter&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;Total number of messages sent&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
  &lt;/div&gt;
&lt;/section&gt;

&lt;div class=&#34;admonition admonition-note&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Note&lt;/p&gt;&lt;p&gt;Steams-related metrics (&lt;code&gt;grpc_streams*&lt;/code&gt;) are available only on &lt;code&gt;k6&lt;/code&gt; version &lt;code&gt;0.49.0&lt;/code&gt; or higher or when using the &lt;code&gt;k6/experimental/grpc&lt;/code&gt; module, which is available on &lt;code&gt;k6&lt;/code&gt; version &lt;code&gt;0.45.0&lt;/code&gt;.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

]]></content><description>&lt;h1 id="built-in-metrics">Built-in metrics&lt;/h1>
&lt;p>Every k6 test emits built-in and
&lt;a href="/docs/k6/v2.3.x/using-k6/metrics/create-custom-metrics/">custom metrics&lt;/a>.
Each supported protocol also has its specific metrics.&lt;/p>
&lt;h2 id="standard-built-in-metrics">Standard built-in metrics&lt;/h2>
&lt;p>k6 always collects the following metrics, no matter what protocol the test uses:&lt;/p></description></item><item><title>Create custom metrics</title><link>https://grafana.com/docs/k6/v2.3.x/using-k6/metrics/create-custom-metrics/</link><pubDate>Mon, 21 Sep 2026 15:16:28 +0000</pubDate><guid>https://grafana.com/docs/k6/v2.3.x/using-k6/metrics/create-custom-metrics/</guid><content><![CDATA[&lt;h1 id=&#34;create-custom-metrics&#34;&gt;Create custom metrics&lt;/h1&gt;
&lt;p&gt;Besides the 
    &lt;a href=&#34;/docs/k6/v2.3.x/using-k6/metrics/reference/&#34;&gt;built-in metrics&lt;/a&gt;, you can create custom metrics.
For example, you can compute a metric for your business logic, or use the 
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-http/response/&#34;&gt;Response.timings&lt;/a&gt; object to create a metric for a specific set of endpoints.&lt;/p&gt;
&lt;p&gt;Each metric type has a &lt;a href=&#34;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes/constructor&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;constructor&lt;/a&gt; to create a custom metric.
The constructor creates a metric object of the declared type. Each type has an &lt;code&gt;add&lt;/code&gt; method to take metric measurements.&lt;/p&gt;
&lt;p&gt;If you need help constructing a custom metric, read the following sections of this document.
They document the procedure and provide examples.
If you&amp;rsquo;re comfortable with these already, you might prefer to read the 
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-metrics/&#34;&gt;reference documentation for each metric constructor&lt;/a&gt;.
Each topic has examples to make a custom metric and create 
    &lt;a href=&#34;/docs/k6/v2.3.x/using-k6/thresholds/&#34;&gt;thresholds&lt;/a&gt; from it.&lt;/p&gt;
&lt;h2 id=&#34;create-a-custom-metric&#34;&gt;Create a custom metric&lt;/h2&gt;


&lt;div class=&#34;admonition admonition-note&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Note&lt;/p&gt;&lt;p&gt;Custom metrics must be created in 
    &lt;a href=&#34;/docs/k6/v2.3.x/using-k6/test-lifecycle/&#34;&gt;init context&lt;/a&gt;.
This limits memory and ensures that k6 can validate that all thresholds are evaluating defined metrics.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;p&gt;The generic procedure to create a custom metric is as follows:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Import the 
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-metrics/&#34;&gt;&lt;code&gt;k6/metrics&lt;/code&gt;&lt;/a&gt; module. Optionally, specify the type of metrics you want to create with a named import:&lt;/p&gt;
&lt;!-- md-k6:skip --&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;JavaScript&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-javascript&#34;&gt;import { Trend } from &amp;#39;k6/metrics&amp;#39;;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;In init context, construct a new custom-metric object.&lt;/p&gt;
&lt;p&gt;For example, the following creates a custom trend. The object in the script is called &lt;code&gt;myTrend&lt;/code&gt;, and its metric appears in the results output as &lt;code&gt;waiting_time&lt;/code&gt;.&lt;/p&gt;
&lt;!-- md-k6:skip --&gt;
&lt;!-- eslint-skip --&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;JavaScript&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-javascript&#34;&gt;const myTrend = new Trend(&amp;#39;waiting_time&amp;#39;);&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;In the VU iteration code, use the &lt;code&gt;add&lt;/code&gt; method to take a measurement.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&#34;example-create-a-trend-metric-for-waiting-time&#34;&gt;Example: create a trend metric for waiting time&lt;/h2&gt;
&lt;p&gt;This VU code makes a request then adds the timing value of the request to the &lt;code&gt;myTrend&lt;/code&gt; object.&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;JavaScript&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-javascript&#34;&gt;import http from &amp;#39;k6/http&amp;#39;;
import { Trend } from &amp;#39;k6/metrics&amp;#39;;

const myTrend = new Trend(&amp;#39;waiting_time&amp;#39;);

export default function () {
  const r = http.get(&amp;#39;https://quickpizza.grafana.com/&amp;#39;);
  myTrend.add(r.timings.waiting);
  console.log(myTrend.name); // waiting_time
}&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&#34;view-custom-metric-results&#34;&gt;View custom metric results&lt;/h2&gt;
&lt;p&gt;Custom metrics appear in 
    &lt;a href=&#34;/docs/k6/v2.3.x/results-output/&#34;&gt;Results output&lt;/a&gt; in both the end-of-test summary and in the granular data points.
Each metric type has specific aggregation methods.
You can also optionally 
    &lt;a href=&#34;/docs/k6/v2.3.x/using-k6/tags-and-groups/&#34;&gt;tag&lt;/a&gt; any value for a custom metric.
You can use these tags to filter test results.&lt;/p&gt;
&lt;p&gt;Here&amp;rsquo;s how the output of the preceding script might look in the end-of-test summary.
Since the metric is a trend, k6 calculates various trends based on the number of values and their summation.&lt;/p&gt;

&lt;div class=&#34;code-snippet &#34;&gt;&lt;div class=&#34;lang-toolbar&#34;&gt;
    &lt;span class=&#34;lang-toolbar__item lang-toolbar__item-active&#34;&gt;Bash&lt;/span&gt;
    &lt;span class=&#34;code-clipboard&#34;&gt;
      &lt;button x-data=&#34;app_code_snippet()&#34; x-init=&#34;init()&#34; @click=&#34;copy()&#34;&gt;
        &lt;img class=&#34;code-clipboard__icon&#34; src=&#34;/media/images/icons/icon-copy-small-2.svg&#34; alt=&#34;Copy code to clipboard&#34; width=&#34;14&#34; height=&#34;13&#34;&gt;
        &lt;span&gt;Copy&lt;/span&gt;
      &lt;/button&gt;
    &lt;/span&gt;
    &lt;div class=&#34;lang-toolbar__border&#34;&gt;&lt;/div&gt;
  &lt;/div&gt;&lt;div class=&#34;code-snippet &#34;&gt;
    &lt;pre data-expanded=&#34;false&#34;&gt;&lt;code class=&#34;language-bash&#34;&gt;$ k6 run script.js

  ...
  INFO[0001] waiting_time                                  source=console

  ...
  iteration_duration.............: avg=1.15s    min=1.15s    med=1.15s    max=1.15s    p(90)=1.15s    p(95)=1.15s
  iterations.....................: 1     0.864973/s
  waiting_time...................: avg=265.245396 min=265.245396 med=265.245396 max=265.245396 p(90)=265.245396 p(95)=265.245396&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;


&lt;div class=&#34;admonition admonition-note&#34;&gt;&lt;blockquote&gt;&lt;p class=&#34;title text-uppercase&#34;&gt;Note&lt;/p&gt;&lt;p&gt;Custom metrics are collected from VU threads only at the end of a VU iteration.
For long-running scripts, custom metrics might appear only after the test runs a while.&lt;/p&gt;&lt;/blockquote&gt;&lt;/div&gt;

&lt;h2 id=&#34;read-more&#34;&gt;Read more&lt;/h2&gt;
&lt;p&gt;The 
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-metrics/&#34;&gt;&lt;code&gt;k6/metrics&lt;/code&gt;&lt;/a&gt; has examples for defining each type of custom metric, and for defining a threshold on the metric.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-metrics/counter/&#34;&gt;Counter&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-metrics/gauge/&#34;&gt;Gauge&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-metrics/rate/&#34;&gt;Rate&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
    &lt;a href=&#34;/docs/k6/v2.3.x/javascript-api/k6-metrics/trend/&#34;&gt;Trend&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
]]></content><description>&lt;h1 id="create-custom-metrics">Create custom metrics&lt;/h1>
&lt;p>Besides the
&lt;a href="/docs/k6/v2.3.x/using-k6/metrics/reference/">built-in metrics&lt;/a>, you can create custom metrics.
For example, you can compute a metric for your business logic, or use the
&lt;a href="/docs/k6/v2.3.x/javascript-api/k6-http/response/">Response.timings&lt;/a> object to create a metric for a specific set of endpoints.&lt;/p></description></item></channel></rss>