Skip to main content

Request and execution metrics

Written by Aron Day

From 3B v11.0.0, 3B can push its own metrics to your monitoring stack: request rate, errors, and duration for the API, Edge, the orchestrator, Blobstore, git-service, and Pony, and the outcome and duration of workflow executions. They’re off by default.

Turn them on

Point 3B at an OTLP/HTTP metrics endpoint. If you followed Install a monitoring stack with Helm or Install monitoring on K3s, that’s the Collector:

metrics:
  enabled: true
  otlpEndpoint: http://otel-collector.monitoring.svc:4318/v1/metrics

Add this to your release values and run your usual helm upgrade. If you use an HTTP proxy, add the endpoint’s host to httpProxy.noProxy.

To push straight to Prometheus 3 or later instead, enable its OTLP receiver, keep the default metric name translation, and use the Prometheus URL plus /api/v1/otlp/v1/metrics. For push credentials, set metrics.otlpHeaders. It takes the same list as autoscaling.otlpMetricsHeaders in How and when to scale.

If you already have autoscaling.enabled: true, these metrics are on. They go to autoscaling.otlpMetricsEndpoint, with its headers, unless you set metrics.otlpEndpoint. If you do, 3B sends metrics.otlpHeaders instead of the autoscaling headers, and the scaling gauges go to the new endpoint too, so autoscaling.prometheusUrl must query the same store.

Each service exports every 10 seconds, apart from the API, which exports every 60 seconds. 3B sends cumulative values. If your backend only accepts delta values, convert them in a Collector with the cumulativetodelta processor.

Once the pods have restarted, count the pods reporting for each service:

count by (job) (count by (job, instance) (http_server_request_duration_seconds_count{stack="<stackName>"}))

Replace <stackName> with your chart’s stackName. A pod only appears after it has served a request, so a quiet service can be missing for a while.

What 3B sends

3B metric name

Name in Prometheus

Sent by

What it measures

http.server.request.duration

http_server_request_duration_seconds

API, Edge, orchestrator, Blobstore, git-service, Pony

A histogram of how long each request took, up to its response headers. Its count gives request rate and its labels give errors.

worker.execution.duration

worker_execution_duration_seconds

Orchestrator

A histogram of worker time for each build or step run a worker finishes. Only the final attempt counts.

edge.admission.utilization

edge_admission_utilization

Edge

Percentage of Edge’s concurrency permits in use (0–100). Autoscaling targets 50%.

orchestrator.worker.slots.wanted

orchestrator_worker_slots_wanted

Orchestrator

Occupied execution slots plus runnable work, capped per tenant and summed across the stack. Autoscaling sizes workers from it. It reports even with no traffic.

Prometheus stores each histogram as _bucket, _count, and _sum series. Request durations top out at a 10-second bucket and execution durations at one hour, so percentiles never read above those.

Labels

Every series carries stack, set to your chart’s stackName, so several installs can share one Prometheus. Prometheus also sets job to the service and instance to the pod name. The job values are 3b/api, 3b/edge, 3b/orchestrator, 3b/blobstore, 3b/git-service, and 3b/pony.

Pony is the egress proxy that runs beside the API, workers, and git-service. Every copy reports as 3b/pony, so tell them apart by instance, such as instance=~"worker-.*".

Label in Prometheus

On

Values

http_request_method

Requests

GET, POST, and the other standard methods. Anything else is _OTHER.

http_route

Requests

The matched route template, with placeholders in place of IDs. Missing when no route matched, including Edge’s workflow traffic and Blobstore’s 503s while it starts or stops.

http_response_status_code

Requests

The status code returned.

error_type

Requests with a 5xx status

The status code.

url_scheme

Requests

Always http, since TLS ends before traffic reaches the service.

exec_kind

Executions

build or run.

exec_status

Executions

success or error.

exec_failure_boundary

Failed executions

user_space when the failure is the workflow’s, such as its code exiting non-zero, timing out, or running out of memory. control_plane when 3B couldn’t run the step. data_plane when 3B couldn’t load or save its data.

admission

Edge’s gauge

execution or response, one series per permit pool.

Series grow with routes, status codes, and pods. Pony on workers adds series for each worker replica.

What isn’t measured

  • Health probes, the worker’s long poll for work, and Blobstore’s lock watches. The orchestrator’s /tunnel-networks route is also a long poll, from the tunnel gateway, so leave it out of latency queries.

  • Edge’s workflow traffic, such as webhooks, has no http_route. Its status codes mix the workflow’s own responses with Edge’s, such as 503 when busy and 504 on timeout, and its durations include the workflow’s run time.

  • Attempts that 3B retries, and executions that fail before a worker finishes them.

  • Pony’s proxied traffic. Only its control API is measured.

  • The worker’s sandbox runtime, Zero sync, the tunnel gateway, nginx, the bundled Postgres, and inbound email.

  • Time spent streaming a response body. Duration stops at the response headers.

Example queries

Request rate per service:

sum by (job) (rate(http_server_request_duration_seconds_count{stack="<stackName>"}[5m]))

Share of requests that return a server error, for services handling at least one request every five seconds. Edge is left out because its 5xx responses can be the workflow’s own:

(
  sum by (job) (rate(http_server_request_duration_seconds_count{stack="<stackName>", job!="3b/edge", error_type!=""}[5m]))
  /
  sum by (job) (rate(http_server_request_duration_seconds_count{stack="<stackName>", job!="3b/edge"}[5m]))
)
and
sum by (job) (rate(http_server_request_duration_seconds_count{stack="<stackName>", job!="3b/edge"}[5m])) > 0.2

95th percentile request duration per service:

histogram_quantile(0.95,
  sum by (job, le) (rate(http_server_request_duration_seconds_bucket{stack="<stackName>", job!="3b/edge", http_route!="/tunnel-networks"}[5m]))
)

Share of executions that 3B failed to run, as opposed to workflow errors:

sum(rate(worker_execution_duration_seconds_count{stack="<stackName>", exec_failure_boundary=~"control_plane|data_plane"}[10m]))
/
sum(rate(worker_execution_duration_seconds_count{stack="<stackName>"}[10m]))

Work is waiting but no executions have finished for 30 minutes:

max(orchestrator_worker_slots_wanted{stack="<stackName>"}) > 0
unless
sum(rate(worker_execution_duration_seconds_count{stack="<stackName>"}[30m])) > 0

3B has stopped sending metrics:

absent_over_time(orchestrator_worker_slots_wanted{stack="<stackName>"}[10m])

Because the API exports once a minute, keep rate windows at five minutes or longer. During a rollout, a replaced pod’s last sample can linger for five minutes, so use max rather than sum on the gauges. For suggested thresholds, see What to monitor.

Did this answer your question?