This directory contains example configurations for Prometheus and Grafana to monitor the Actual Budget REST API.
The Actual Budget REST API exposes metrics in Prometheus format at the /metrics/prometheus endpoint. These configurations allow you to:
- Prometheus: Scrape and store metrics from the API
- Grafana: Visualize metrics with pre-configured dashboards
prometheus.yml- Prometheus configuration for scraping API metricsgrafana/- Grafana provisioning configurationsprovisioning/datasources/prometheus.yml- Prometheus datasource configurationprovisioning/dashboards/default.yml- Dashboard provisioning settingsdashboards/actual-budget-api-dashboard.json- Pre-built dashboard with API metrics
The development docker-compose.dev.yml already includes Prometheus and Grafana services. The configurations in this directory are automatically mounted:
-
Start all services:
docker compose -f docker-compose.dev.yml up --build
-
Access Grafana:
- URL: http://localhost:3001
- Username:
admin - Password:
admin(change on first login)
-
View the dashboard:
- Navigate to Dashboards → Actual Budget REST API Metrics
- The dashboard will automatically load with metrics from your API
-
Copy
prometheus.ymlto your Prometheus configuration directory:cp monitoring/prometheus.yml /path/to/prometheus/config/
-
Update the target URL in
prometheus.ymlif your API is running on a different host/port:static_configs: - targets: ['your-api-host:3000'] # Update this
-
Start Prometheus:
prometheus --config.file=/path/to/prometheus.yml
-
Verify metrics are being scraped:
- Open http://localhost:9090
- Go to Status → Targets and verify the API target is UP
- Query metrics:
http_requests_total
-
Install and start Grafana (see Grafana installation guide).
-
Copy the Grafana provisioning files:
# Copy datasource configuration cp -r monitoring/grafana/provisioning /etc/grafana/ # Copy dashboard cp monitoring/grafana/dashboards/actual-budget-api-dashboard.json /var/lib/grafana/dashboards/
-
Update the Prometheus URL in
provisioning/datasources/prometheus.ymlif needed:url: http://your-prometheus-host:9090
-
Restart Grafana to load the new configuration.
-
Access Grafana and view the dashboard:
- Open http://localhost:3000 (default Grafana port)
- Navigate to Dashboards → Actual Budget REST API Metrics
The pre-configured dashboard includes:
- Request Rate: Requests per second over time
- Total Requests: Cumulative request count (1 hour window)
- Error Rate: Percentage of requests that result in errors
- Total Errors: Cumulative error count (1 hour window)
- Request Duration: p50, p95, and p99 latency percentiles
- Average Response Time: Mean response time over time
- Requests by Method: Breakdown of HTTP methods (GET, POST, etc.)
- Requests by Route: Breakdown by API endpoint
- Status Code Distribution: Pie chart of HTTP status codes
- Error Status Codes: Time series of error status codes
Edit prometheus.yml to:
- Adjust scrape intervals
- Add alerting rules
- Configure additional targets
- Set retention policies
The dashboard JSON file can be imported into Grafana and customized:
- Open Grafana UI
- Go to Dashboards → Import
- Upload
grafana/dashboards/actual-budget-api-dashboard.json - Customize panels, add alerts, or create new visualizations
For production deployments:
-
Security:
- Protect Prometheus and Grafana with authentication
- Use HTTPS for all connections
- Restrict network access to monitoring services
-
Retention:
- Configure appropriate retention periods in Prometheus
- Set up data archival for long-term storage
-
High Availability:
- Run Prometheus in a clustered setup
- Use Grafana with external database for persistence
-
Alerting:
- Configure Alertmanager for Prometheus alerts
- Set up notification channels in Grafana
-
Verify Prometheus is scraping the API:
- Check Prometheus targets: http://localhost:9090/targets
- Verify the API is accessible from Prometheus
-
Check Grafana datasource:
- Go to Configuration → Data Sources
- Test the Prometheus connection
- Verify the URL is correct
-
Verify API metrics endpoint:
- Access http://your-api:3000/metrics/prometheus
- Ensure metrics are being exposed
-
Check dashboard provisioning:
- Verify dashboard JSON is in the correct path
- Check Grafana logs for provisioning errors
-
Verify datasource:
- Ensure Prometheus datasource is configured and working
- Check that metrics are available in Prometheus