Overview

Qhaway includes a pre-built Grafana dashboard JSON that visualizes your agent telemetry. It uses Prometheus as the data source, consuming metrics served by Qhaway’s metrics endpoint.

Setup

1. Deploy the Metrics Server

import { serveMetrics, MemoryStorage } from '@carloscortezcloud/qhaway';

const { server } = serveMetrics({
  port: 9090,
  storage: new MemoryStorage(),
});

2. Configure Prometheus

# prometheus.yml
scrape_configs:
  - job_name: 'qhaway'
    static_configs:
      - targets: ['localhost:9090']

3. Import the Dashboard

The dashboard JSON is at @carloscortezcloud/qhaway/src/dashboard/qhaway-dashboard.json.

In Grafana:

  1. Click +Import
  2. Paste the JSON or upload the file
  3. Select your Prometheus data source
  4. Click Import

Dashboard Panels

Panel Metric Description
Cost by Model qhaway_cost_total Stacked bar chart of cost per model
Latency P99 qhaway_latency_seconds Histogram of response times
Token Usage qhaway_tokens_input_total + qhaway_tokens_output_total Token counts over time
Call Volume qhaway_calls_total Request rate by model and success
Cost by User qhaway_cost_total{user=~".*"} Per-user spend breakdown

Grafana Cloud / Local

# docker-compose.yml
services:
  prometheus:
    image: prom/prometheus
    volumes:
      - ./prometheus.yml:/etc/prometheus/prometheus.yml
    ports:
      - 9090:9090

  grafana:
    image: grafana/grafana
    ports:
      - 3000:3000
    environment:
      - GF_AUTH_ANONYMOUS_ENABLED=true

Available Metrics

Metric Type Labels
qhaway_cost_total Counter model, provider, user
qhaway_latency_seconds Histogram model (buckets: 0.1, 0.5, 1, 2, 5, 10)
qhaway_tokens_input_total Counter model
qhaway_tokens_output_total Counter model
qhaway_calls_total Counter model, success