This directory contains the Prometheus configuration for monitoring the GitHub AI Search Backend.
prometheus.yml - Main Prometheus configuration filealerts.yml - Alerting rules for the backendREADME.md - This filePrometheus is configured to scrape metrics from the backend at:
http://backend:8080/api/metrics/prometheusgithub-ai-search-backendThe backend exposes Prometheus metrics at:
GET /api/metrics/prometheus
This endpoint returns metrics in Prometheus text format (text/plain).
The backend exposes the following Prometheus metrics:
github_ai_search_requests_total (counter) - Total number of requestsgithub_ai_search_requests_successful (counter) - Total successful requestsgithub_ai_search_requests_failed (counter) - Total failed requestsgithub_ai_search_success_rate (gauge) - Success rate percentagegithub_ai_search_avg_response_time_ms (gauge) - Average response time in millisecondsgithub_ai_search_total_tokens_used (counter) - Total tokens used by Gemini AIgithub_ai_search_health_score (gauge) - Health score (0-100)github_ai_search_performance_grade (gauge) - Performance grade (A-F)github_ai_search_cache_size (gauge) - Current cache sizegithub_ai_search_cache_maxsize (gauge) - Maximum cache sizegithub_ai_search_cache_usage_percent (gauge) - Cache usage percentagegithub_ai_search_requests_by_type_total{type="..."} (counter) - Requests by typegithub_ai_search_requests_by_type_avg_time_ms{type="..."} (gauge) - Average time by typeThe alerts.yml file defines several alerting rules:
# Check Prometheus configuration syntax
docker exec prometheus promtool check config /etc/prometheus/prometheus.yml
github-ai-search-backend target is UPIn Prometheus UI (http://localhost:9090/graph), try these queries:
# Total requests
github_ai_search_requests_total
# Success rate
github_ai_search_success_rate
# Average response time
github_ai_search_avg_response_time_ms
# Health score
github_ai_search_health_score
# Cache usage
github_ai_search_cache_usage_percent
# From host machine
curl http://localhost:8080/api/metrics/prometheus
# From within Docker network
docker exec prometheus wget -qO- http://backend:8080/api/metrics/prometheus
docker ps | grep backend
curl http://localhost:8080/api/health
curl http://localhost:8080/api/metrics/prometheus
docker network inspect <network_name>
docker logs prometheus
prometheus.yml has correct metrics_path and targetsmetrics_path is /api/metrics/prometheus (not /metrics)docker logs backend
curl http://localhost:8080/api/metrics/prometheus | head -20
Should return Prometheus text format with # HELP and # TYPE comments.
Edit prometheus.yml:
scrape_configs:
- job_name: "github-ai-search-backend"
scrape_interval: 30s # Change from 15s to 30s
Add additional scrape configs:
scrape_configs:
- job_name: "github-ai-search-backend"
# ... existing config ...
- job_name: "another-service"
metrics_path: /metrics
static_configs:
- targets: ["another-service:8080"]
Edit alerts.yml to add, modify, or remove alert rules. After changes:
docker restart prometheusPrometheus is automatically configured as a data source in Grafana. To use it:
http://prometheus:9090You can now create dashboards using Prometheus metrics.