Temporal Cloud Metrics to CtrlB
This guide explains how to collect Temporal Cloud metrics in CtrlB. An OpenTelemetry Collector scrapes the Temporal Cloud OpenMetrics endpoint and forwards the metrics to CtrlB over OTLP.
Temporal Cloud OpenMetrics endpoint → OpenTelemetry Collector → CtrlB
Overview
Temporal Cloud publishes metrics for Workflows, Activities, Task Queues, Nexus operations and the Temporal Cloud frontend service at https://metrics.temporal.io/v1/metrics. Metrics carry the labels temporal_namespace, temporal_account and region, plus labels that depend on the metric, such as temporal_workflow_type, temporal_task_queue, task_type or operation.
How the endpoint behaves:
- One-minute windows. Each scrape returns only the most recently completed one-minute window. The endpoint keeps no history, so a window the collector misses is lost.
- Three-minute delay. Data points are timestamped about 3 minutes in the past. The collector keeps those timestamps.
- All gauges, three kinds. Every metric is a gauge, and Temporal's reference marks each one as one of three kinds:
- Rate: a per-second rate averaged over the minute, for example
temporal_cloud_v1_workflow_success_count - Value: the latest value in the window, for example
temporal_cloud_v1_approximate_backlog_count. Despite the_countsuffix, this is not a rate - Latency: a percentile in seconds, for example
temporal_cloud_v1_service_latency_p95
- Rate: a per-second rate averaged over the minute, for example
- Activity only. A metric appears only when there was matching activity in the window.
For the full list of metrics and labels, see the Temporal metrics reference.
Versions Used
| Component | Version |
|---|---|
| OpenTelemetry Collector Contrib | 0.166.0 |
Prerequisites
Before beginning the setup, ensure you have:
- The Account Owner or Global Admin role in Temporal Cloud. Only these roles can grant the Metrics Read-Only role. A Namespace Admin cannot complete section 1
- Your CtrlB instance host and API token. If you don't have them, contact your CtrlB representative or check your onboarding documentation
- A Linux host with Docker, or a Kubernetes cluster, that can reach
metrics.temporal.ioand your CtrlB instance over HTTPS
1. Create a Temporal Cloud API Key
Step 1: Create a Service Account
In the Temporal Cloud UI, go to Settings → Service Accounts → Create Service Account and assign the Metrics Read-Only account-level role. This role can read the OpenMetrics endpoint and nothing else.
Step 2: Generate an API Key
Open the Service Account and create an API key. Copy it and store it securely. Temporal shows it only once.
Step 3: Check the Endpoint
Enter the key when prompted. Reading it this way keeps it out of your shell history and the process list:
printf 'Temporal API key: '; read -rs TEMPORAL_API_KEY; echo
printf 'Authorization: Bearer %s\n' "$TEMPORAL_API_KEY" | \
curl -s -H @- https://metrics.temporal.io/v1/metrics | head
The output starts with lines such as # TYPE temporal_cloud_v1_.... If a Namespace had no activity in the last window, some metrics are missing; that is expected.
2. Create the Collector Configuration
Create a working directory with two files.
Step 1: Store the Credentials
Create a file named .env:
TEMPORAL_API_KEY=<TEMPORAL_API_KEY>
CTRLB_API_TOKEN=<API_TOKEN>
Write each value as is, with no quotes and no trailing spaces. Docker passes the values exactly as written.
Restrict the file to your user:
chmod 600 .env
Step 2: Create collector.yaml
Replace <INSTANCE_HOST> with your CtrlB instance host:
receivers:
prometheus:
config:
scrape_configs:
- job_name: temporal-cloud
scrape_interval: 30s
scrape_timeout: 30s
honor_timestamps: true
scheme: https
metrics_path: /v1/metrics
authorization:
type: Bearer
credentials: ${env:TEMPORAL_API_KEY}
static_configs:
- targets: ['metrics.temporal.io']
processors:
batch: {}
exporters:
otlp_http:
endpoint: https://<INSTANCE_HOST>/engine/api/default
headers:
Authorization: Basic ${env:CTRLB_API_TOKEN}
service:
pipelines:
metrics:
receivers: [prometheus]
processors: [batch]
exporters: [otlp_http]
What the settings do:
scrape_interval: 30sis what Temporal recommends. Intervals longer than 60 seconds can skip data points, because the endpoint updates once a minute.honor_timestamps: truekeeps Temporal's timestamps, so data points land at the minute they describe instead of the minute they were scraped.- The collector sets the OpenTelemetry resource attribute
service.nameto thejob_name, so the Temporal Cloud metrics arrive under the servicetemporal-cloud. - The
otlp_httpexporter appends/v1/metricstoendpoint. Do not add it yourself. Collectors older than 0.144.0 call this exporterotlphttp. - The collector also sends its own scrape metrics, such as
upandscrape_duration_seconds.upis 1 when the last scrape of Temporal succeeded.
The OpenMetrics endpoint allows 180 requests per hour per Temporal Cloud account (see Temporal's rate limits). One collector scraping every 30 seconds uses 120 of them. Run a single collector per account, and count any other scraper on the same account (for example a Datadog or Grafana Cloud integration, or curl checks) against the same limit.
Optional: Scrape Only Some Namespaces or Metrics
To reduce volume, add params to the scrape job. Both accept several values, and Namespace names support wildcards:
- job_name: temporal-cloud
# ...settings from collector.yaml above...
params:
namespaces: ['production-*']
metrics:
- temporal_cloud_v1_workflow_success_count
- temporal_cloud_v1_workflow_failed_count
- temporal_cloud_v1_approximate_backlog_count
Filtering is also the fix when a response is cut short. Temporal returns at most 50,000 data points per scrape, and marks a cut response with the header X-Completeness: limited (see Temporal's response completeness). To check, from the working directory:
set -a; . ./.env; set +a
printf 'Authorization: Bearer %s\n' "$TEMPORAL_API_KEY" | \
curl -s -D - -o /dev/null -H @- https://metrics.temporal.io/v1/metrics | grep -i x-completeness
3. Run the Collector
The collector runs as a non-root user inside the container, so make the config readable by all users:
chmod 644 collector.yaml
From the working directory:
docker run -d --name temporal-cloud-metrics --restart unless-stopped \
--env-file .env \
-v "$PWD/collector.yaml:/etc/otelcol-contrib/config.yaml:ro" \
otel/opentelemetry-collector-contrib:0.166.0
Check that it started without errors:
docker logs temporal-cloud-metrics
On Kubernetes, run the same configuration as a Deployment with one replica, and supply TEMPORAL_API_KEY and CTRLB_API_TOKEN from a Secret as environment variables. More replicas would each scrape the endpoint and use up the rate limit.
4. Verify the Data in CtrlB
Because of the 3-minute delay, allow about 5 minutes after the collector starts.
- Open the Metrics page in CtrlB
- Search for
temporal_cloud_v1 - Click a metric, such as
temporal_cloud_v1_workflow_success_count, and open the Attributes tab to see the Temporal labels
If nothing appears, see Troubleshooting.
5. Build a Dashboard
Create a dashboard as described in Dashboards. In the panel's Query tab, switch to Code and select PromQL in the editor. There is no dataset to pick: PromQL finds each metric by its name.
All Temporal Cloud metrics are gauges that Temporal has already aggregated per minute, so do not wrap them in rate() or increase(). Do wrap them in last_over_time(...[1m]), as the queries below do. Temporal sends a series only for minutes with activity, and without the wrapper a query keeps showing a series' last value for up to 5 minutes after it stops.
Example queries:
| Panel | PromQL |
|---|---|
| Successful Workflows per second, by Namespace | sum by (temporal_namespace) (last_over_time(temporal_cloud_v1_workflow_success_count[1m])) |
| Failed Workflows per second, by Workflow type | sum by (temporal_namespace, temporal_workflow_type) (last_over_time(temporal_cloud_v1_workflow_failed_count[1m])) |
| Timed-out Workflows per second | sum by (temporal_namespace) (last_over_time(temporal_cloud_v1_workflow_timeout_count[1m])) |
| Task Queue backlog, by task type | sum by (temporal_namespace, temporal_task_queue, task_type) (last_over_time(temporal_cloud_v1_approximate_backlog_count[1m])) |
| Age of the oldest backlog task | max by (temporal_namespace, temporal_task_queue) (last_over_time(temporal_cloud_v1_approximate_backlog_age[1m])) |
| Throttled requests per second | sum by (temporal_namespace) (last_over_time(temporal_cloud_v1_service_request_throttled_count[1m])) |
| p95 latency of Start and Signal requests | max by (temporal_namespace, operation) (last_over_time(temporal_cloud_v1_service_latency_p95{operation=~"StartWorkflowExecution|SignalWorkflowExecution|SignalWithStartWorkflowExecution"}[1m])) |
Keep operation in the latency query: Temporal advises against combining percentiles across operations, because the result is no longer a true percentile.
Each Temporal metric is stored as its own dataset, named after the metric, for example temporal_cloud_v1_workflow_success_count. With a 30-second scrape interval, the collector reads each one-minute window twice, so CtrlB stores two identical rows per series and minute. PromQL is not affected. In SQL, deduplicate before you add up values, for example by taking MAX(value) per _timestamp and series before a SUM.
Backlog age and throttled requests are good candidates for Alerts. When you set an alert's evaluation window, allow for the 3-minute delay.
6. Optional: Worker Metrics
Temporal Cloud metrics describe the service side. Worker-side metrics, such as slot usage, Schedule-To-Start latency and sticky cache hits, come from the Temporal SDK in your Workers. Collect both to see bottlenecks on either side.
Configure each SDK to expose a Prometheus metrics endpoint, as described in Temporal's SDK metrics setup. Then add a second job to the same collector:
- job_name: temporal-workers
scrape_interval: 30s
static_configs:
- targets: ['<WORKER_HOST>:<METRICS_PORT>']
The collector must be able to reach each Worker's metrics port. Bind the SDK's metrics endpoint to an address other hosts can reach, such as 0.0.0.0, not 127.0.0.1. Inside the Docker container, localhost is the container itself, so use the Worker's host name or IP address.
Worker metrics arrive under the service temporal-workers. SDKs that export OpenTelemetry metrics can send them over OTLP instead; see OpenTelemetry for Metrics.
To trace Workflows and the LLM calls your agents make, see Temporal Agents.
Troubleshooting
Errors from Temporal Cloud
HTTP 401 or Jwt is missing
- Check that
TEMPORAL_API_KEYin.env(or the Kubernetes Secret) holds the full key, with no quotes or trailing spaces - Confirm the key belongs to a Service Account with the Metrics Read-Only role and has not expired
HTTP 429 Too Many Requests
- Something else is using the account's request limit: a second collector or replica, another integration on the same account, or repeated
curlchecks. Stop the extra scraper, or lengthenscrape_interval(up to 60s) on each
Gaps or missing metrics
- Metrics appear only for windows with matching activity
- Keep
scrape_intervalat 60 seconds or less - If responses are cut short (header
X-Completeness: limited), filter by Namespace or metric
Errors from CtrlB
HTTP 401 Unauthorized
- Verify the header format:
Authorization: Basic <API_TOKEN>
HTTP 404
- Set the exporter
endpointtohttps://<INSTANCE_HOST>/engine/api/default, without a trailing slash or/v1/metrics
Data Looks Late
Data points carry timestamps about 3 minutes in the past. This is expected. Use a time range of at least the last 15 minutes when checking recent data.