- Updated: March 19, 2026
- 6 min read
Visualizing UBOS Per-Agent Token‑Bucket Metrics in Grafana
Answer: To visualize per‑agent token‑bucket custom metrics exposed by the UBOS Prometheus exporter, you must (1) configure Prometheus to scrape the exporter endpoint, (2) add Prometheus as a data source in Grafana, and (3) build a Grafana dashboard that queries the ubos_token_bucket_* series. The following guide walks senior engineers through every step, provides a ready‑to‑import JSON dashboard, and includes troubleshooting tips.
1. Introduction
Observability is the backbone of modern DevOps. UBOS ships a built‑in OpenAI ChatGPT integration that also publishes a Prometheus exporter exposing per‑agent token‑bucket metrics. These metrics let you see how many tokens each AI agent has consumed, the remaining quota, and refill rates—critical data for capacity planning and cost control.
This senior‑engineer guide assumes you already run UBOS in production and want a Grafana view that updates in real time. We’ll cover prerequisites, exporter internals, Prometheus scraping, Grafana data‑source setup, dashboard creation, and publishing the article on UBOS homepage.
2. Prerequisites
- UBOS instance (v2.5+ recommended) with the Prometheus exporter enabled.
- Running Prometheus server (v2.30+).
- Grafana instance (v9.0+).
- Network connectivity between Prometheus and the UBOS exporter endpoint (default
http://<ubos-host>:9090/metrics). - Basic knowledge of YAML, JSON, and PromQL.
3. Overview of the Prometheus exporter and token‑bucket metrics
The UBOS exporter follows the standard Prometheus exposition format. For each AI agent, it emits three series:
| Metric Name | Description | Type |
|---|---|---|
ubos_token_bucket_capacity | Configured maximum tokens for the agent. | gauge |
ubos_token_bucket_available | Current tokens left. | gauge |
ubos_token_bucket_refill_rate | Tokens added per second. | gauge |
Each metric includes a agent_id label, enabling per‑agent slicing in Grafana.
4. Setting up Prometheus to scrape the exporter
Update your prometheus.yml with a new scrape_config. Below is a minimal example:
scrape_configs:
- job_name: 'ubos-token-bucket'
static_configs:
- targets: ['ubos.example.com:9090']
metrics_path: /metrics
scheme: http
relabel_configs:
- source_labels: [__address__]
regex: (.*):9090
target_label: __address__
replacement: $1:9090
After editing, reload Prometheus:
curl -X POST http://localhost:9090/-/reloadVerify that the metrics appear:
curl http://ubos.example.com:9090/metrics | grep ubos_token_bucketFor a deeper dive into Prometheus configuration, see the official Prometheus documentation.
5. Configuring Grafana data source for Prometheus
- Log into Grafana and navigate to Configuration > Data Sources.
- Click Add data source and select Prometheus.
- Set the URL to your Prometheus server, e.g.,
http://prometheus.example.com:9090. - Leave the default
Accessmode as Server. - Click Save & Test. You should see a green confirmation.
Once the data source is verified, Grafana can query the ubos_token_bucket_* series.
6. Creating the token‑bucket dashboard
Panel design
We recommend a three‑panel layout:
- Capacity Gauge – Shows the maximum tokens per agent.
- Available Tokens Time‑Series – Real‑time line chart of remaining tokens.
- Refill Rate Bar – Visualizes refill speed for each agent.
Example JSON payload
Copy the JSON below into Grafana (Dashboard > Manage > Import) to get a ready‑made view.
{
"dashboard": {
"id": null,
"uid": "ubos-token-bucket",
"title": "UBOS Token Bucket per Agent",
"timezone": "browser",
"schemaVersion": 38,
"version": 1,
"refresh": "5s",
"panels": [
{
"type": "gauge",
"title": "Token Bucket Capacity",
"gridPos": {"x":0,"y":0,"w":12,"h":8},
"datasource": "Prometheus",
"targets": [
{
"expr": "max(ubos_token_bucket_capacity) by (agent_id)",
"legendFormat": "{{agent_id}}",
"refId": "A"
}
],
"fieldConfig": {
"defaults": {
"unit": "none",
"min": 0
}
}
},
{
"type": "timeseries",
"title": "Available Tokens (Live)",
"gridPos": {"x":12,"y":0,"w":12,"h":8},
"datasource": "Prometheus",
"targets": [
{
"expr": "ubos_token_bucket_available",
"legendFormat": "{{agent_id}}",
"refId": "B"
}
],
"fieldConfig": {
"defaults": {
"unit": "none",
"min": 0
}
}
},
{
"type": "barchart",
"title": "Refill Rate (tokens/s)",
"gridPos": {"x":0,"y":8,"w":24,"h":8},
"datasource": "Prometheus",
"targets": [
{
"expr": "avg(ubos_token_bucket_refill_rate) by (agent_id)",
"legendFormat": "{{agent_id}}",
"refId": "C"
}
],
"fieldConfig": {
"defaults": {
"unit": "ops",
"min": 0
}
}
}
]
},
"overwrite": true
}
After importing, you can edit each panel to add thresholds, alerts, or custom legends.
7. Step‑by‑step walkthrough
-
Enable the exporter in UBOS. In the UBOS admin UI, navigate to Integrations → Prometheus Exporter and toggle it on. The default endpoint is
/metrics. -
Confirm metric exposure. Run
curl http://<ubos-host>:9090/metrics | grep ubos_token_bucketand verify the three series appear with theagent_idlabel. -
Update Prometheus config. Add the
scrape_configshown in Section 4, reload Prometheus, and check the Status → Targets page for a green “UP” status. -
Add Prometheus as a Grafana data source. Follow the steps in Section 5. Test the connection by querying
ubos_token_bucket_availablein the Grafana Explore view. - Import the dashboard JSON. Go to Dashboards → Manage → Import, paste the JSON from Section 6, and click Import. Assign the Prometheus data source if prompted.
-
Customize panels. Use the Panel > Edit** menu to add thresholds (e.g., red when
available < 10) and enable alerting rules that push to Slack or the Workflow automation studio. - Validate real‑time updates. Trigger token consumption on a test agent (e.g., via the UBOS ChatGPT and Telegram integration) and watch the Grafana panels reflect the change within seconds.
- Save and share. Click Save dashboard, give it a meaningful name, and use the share icon to generate a snapshot link for stakeholders.
8. Troubleshooting common issues
- No metrics appear in Prometheus. Verify that the UBOS exporter port is reachable from the Prometheus host (use
telnet <ubos-host> 9090). Check firewall rules and ensure themetrics_pathis correct. - Grafana shows “Data source is missing”. Re‑assign the Prometheus data source in the dashboard JSON or via the dashboard settings. Ensure the data source name matches exactly.
- Panel shows “NaN” or empty series. Confirm that the
agent_idlabel exists on the metric. Use Grafana Explore to runubos_token_bucket_availablewithout aggregation. - High latency between token consumption and dashboard update. Check Prometheus scrape interval (default 15s). Reduce it to
5sinprometheus.ymland reload. - Alert rules fire continuously. Ensure alert expressions include a
forclause (e.g.,for: 2m) to avoid flapping.
9. Publishing the article on ubos.tech
UBOS provides a built‑in CMS for technical documentation. Follow these steps to make the guide live:
- Log into the About UBOS admin portal.
- Navigate to Content → Articles → New Article.
- Set the slug to
token-bucket-grafana-guideand paste the HTML content from this page into the editor (ensure “HTML” mode is selected). - Choose the Enterprise AI platform by UBOS tag for discoverability.
- Review the SEO fields: meta title “Visualize UBOS Token‑Bucket Metrics in Grafana – Senior Engineer Guide”, meta description “Step‑by‑step setup of Prometheus scraping, Grafana data source, and a ready‑to‑import dashboard for per‑agent token‑bucket metrics.”
- Click Save Draft, preview, then Publish.
- After publishing, share the URL on internal Slack channels and add it to the UBOS partner program newsletter.
10. Conclusion and next steps
By completing this guide you now have a live Grafana dashboard that surfaces per‑agent token‑bucket usage, enabling proactive capacity planning and cost optimization for AI workloads on UBOS. The same pattern can be extended to other custom metrics—simply expose them via the UBOS exporter and reuse the dashboard JSON structure.
Next, consider integrating alerts with the AI YouTube Comment Analysis tool or automating remediation through the AI Email Marketing module. For a broader view of UBOS capabilities, explore the UBOS solutions for SMBs and the UBOS templates for quick start.
Happy monitoring!