This guide explains how to configure Prometheus to scrape metrics from the GitHub AI Search Backend.
The backend exposes Prometheus metrics at:
GET /api/metrics/prometheus
Prometheus is configured to scrape this endpoint every 15 seconds.
# Test the metrics endpoint
curl http://localhost:8080/api/metrics/prometheus
# Expected output: Prometheus text format with metrics
# Example:
# # HELP github_ai_search_requests_total Total number of requests
# # TYPE github_ai_search_requests_total counter
# github_ai_search_requests_total 42
# Start all services (Prometheus, Grafana, Alertmanager, Loki)
docker compose -f docker-compose.observability.yml up -d
# Verify services are running
docker compose -f docker-compose.observability.yml ps
# Check configuration syntax
docker exec prometheus promtool check config /etc/prometheus/prometheus.yml
# Expected output:
# Checking /etc/prometheus/prometheus.yml
# SUCCESS: 1 rule files found
github-ai-search-backend target shows:
monitoring/prometheus/prometheus.yml)scrape_configs:
- job_name: "github-ai-search-backend"
metrics_path: /api/metrics/prometheus
static_configs:
- targets: ["backend:8080"]
Key Points:
metrics_path: /api/metrics/prometheus (not /metrics)targets: backend:8080 (Docker service name and port)scrape_interval: 15 secondsThe backend and Prometheus must be on the same Docker network:
# docker-compose.observability.yml
services:
backend:
# ... backend config ...
prometheus:
depends_on:
- backend
# ... prometheus config ...
Once Prometheus is scraping, you can query these metrics:
# Total requests
github_ai_search_requests_total
# Success rate (percentage)
github_ai_search_success_rate
# Average response time (milliseconds)
github_ai_search_avg_response_time_ms
# Health score (0-100)
github_ai_search_health_score
# Performance grade
github_ai_search_performance_grade
# Cache usage percentage
github_ai_search_cache_usage_percent
# Cache size
github_ai_search_cache_size
The configuration includes several alerting rules (see monitoring/prometheus/alerts.yml):
Symptoms:
Solutions:
docker ps | grep backend
curl http://localhost:8080/api/health
curl http://localhost:8080/api/metrics/prometheus
# Find network name
docker inspect backend | grep NetworkMode
# Check if Prometheus is on same network
docker inspect prometheus | grep NetworkMode
docker logs prometheus | tail -50
docker exec prometheus wget -qO- http://backend:8080/api/metrics/prometheus
Symptoms:
Solution:
metrics_path in prometheus.yml is /api/metrics/prometheus/metrics or /api/metricsSymptoms:
Solution:
prometheus.yml matches actual port (8080)docker-compose.observability.yml port mappingSymptoms:
Solution:
curl http://localhost:8080/api/metrics/prometheus | head -10
# HELP and # TYPE commentsrate(github_ai_search_requests_total[5m])github_ai_search_success_rategithub_ai_search_avg_response_time_msmonitoring/alertmanager/README.md)Set up dashboards for:
curl http://localhost:8080/api/metrics/prometheuspromtool check configIf you encounter issues:
docker logs prometheus and docker logs backend