- Updated: March 20, 2026
- 4 min read
Integrating OpenClaw Rating API Edge with Moltbook and Visualizing Token‑Bucket Metrics in Grafana
# End‑to‑End Tutorial: OpenClaw Rating API Edge + Moltbook + Grafana Token‑Bucket Dashboard
*Published in the wave of self‑hosted AI agents, this guide shows you how to combine three powerful UBOS components into a single, observable workflow.*
—
## 1️⃣ Overview
– **OpenClaw Rating API Edge** – a lightweight HTTP endpoint that returns a rating score for any piece of content.
– **Moltbook** – a self‑hosted notebook platform that can call external APIs and store results as structured data.
– **Grafana** – visualises time‑series metrics; we will use its token‑bucket plugin to monitor API usage.
The tutorial will:
1. Pull the Rating API Edge guide (see the existing **Rating API Edge** guide).
2. Call the Rating API from Moltbook and store the rating together with a timestamp.
3. Emit a token‑bucket metric for each call.
4. Build a Grafana dashboard that shows request rates, success/failure ratios, and rating trends.
5. Include an internal link to the **OpenClaw hosting** page for context.
—
## 2️⃣ Prerequisites
– UBOS node with **OpenClaw**, **Moltbook**, and **Grafana** installed.
– Access to the **Rating API Edge** guide (URL from the Rating API Edge guide).
– Access to the **Token‑Bucket Grafana** guide (URL from the token‑bucket Grafana guide).
– An API token for Grafana (see the Grafana guide for creation).
—
## 3️⃣ Step‑by‑Step Integration
### Step 1 – Get the Rating API Edge URL
1. Open the Rating API Edge guide (linked in the guide section).
2. Copy the endpoint URL, e.g. `https://api.openclaw.tech/v1/rating`.
3. Note the required request payload:
{ “text”: “Your content to rate” }
### Step 2 – Create a Moltbook Notebook
1. Log into Moltbook (`https://.ubos.tech/moltbook`).
2. Create a new notebook called **”OpenClaw Rating & Metrics”**.
3. Add a **Python** cell (Moltbook supports Python out‑of‑the‑box).
4. Install the `requests` library if not present:
python
!pip install requests
5. Paste the following code (replace “ with the URL from Step 1):
python
import requests, time, json
API_URL = “”
GRAFANA_ENDPOINT = “https:///api/metrics”
GRAFANA_TOKEN = “”
def rate_content(text):
resp = requests.post(API_URL, json={“text”: text})
resp.raise_for_status()
rating = resp.json().get(“rating”)
ts = int(time.time())
# Store in Moltbook’s built‑in DB (simple JSON file for demo)
entry = {“timestamp”: ts, “text”: text, “rating”: rating}
with open(“ratings.json”, “a”) as f:
f.write(json.dumps(entry) + “\n”)
# Emit token‑bucket metric
metric = {
“name”: “openclaw_rating_requests”,
“type”: “counter”,
“value”: 1,
“tags”: {“status”: “success”},
“timestamp”: ts
}
headers = {“Authorization”: f”Bearer {GRAFANA_TOKEN}”, “Content-Type”: “application/json”}
requests.post(GRAFANA_ENDPOINT, headers=headers, json=metric)
return rating
# Example usage
sample = “The quick brown fox jumps over the lazy dog.”
print(“Rating:”, rate_content(sample))
6. Run the cell – a rating will be stored and a metric sent to Grafana.
### Step 3 – Verify Data Persistence
– Open the `ratings.json` file from Moltbook’s file manager.
– You should see lines like:
{“timestamp”:1700000000,”text”:”The quick brown fox…”,”rating”:4.2}
### Step 4 – Configure Grafana Token‑Bucket Plugin
1. Follow the **Token‑Bucket Grafana guide** to install the plugin (if not already).
2. In Grafana, create a new **Data Source** → **Prometheus** (or the built‑in metrics backend used by the plugin).
3. Add the metric name `openclaw_rating_requests` to the dashboard.
4. Create a **Rate** panel:
– Query: `rate(openclaw_rating_requests[1m])`
– Visualization: **Time series**.
5. Add a second panel to show rating trends:
– Use the `ratings.json` as a CSV/JSON datasource (Grafana can read files via the SimpleJSON plugin) or push rating values as a separate metric `openclaw_rating_value`.
6. Apply tags (`status=”success”` vs. `status=”error”`) to see error rates.
### Step 5 – Assemble the Dashboard
– Title: **”OpenClaw Rating API – Token Bucket & Rating Overview”**.
– Panels:
1. **Request Rate** – shows requests per second/minute.
2. **Success / Error Ratio** – stacked bar.
3. **Rating Over Time** – line chart of the rating values.
– Save the dashboard and share the link.
—
## 4️⃣ Linking Back to UBOS Resources
– The **Rating API Edge guide** (referenced throughout) lives here: *[Rating API Edge Guide]*.
– The **Token‑Bucket Grafana guide** is available at: *[Token‑Bucket Grafana Guide]*.
– For a deeper dive into hosting OpenClaw on UBOS, see our internal page: .
—
## 5️⃣ Wrap‑up
You now have a fully automated pipeline:
1. Moltbook calls OpenClaw’s Rating API Edge.
2. Each call records a rating and pushes a token‑bucket metric.
3. Grafana visualises both usage patterns and the actual rating data.
This end‑to‑end example demonstrates how UBOS lets you **combine AI‑driven services, notebook‑style orchestration, and observability**—a perfect recipe for the booming self‑hosted AI‑agent ecosystem.
—
*Happy building, and stay tuned for more UBOS tutorials!*