This directory contains configuration files for monitoring and observability of the PredictIQ system.
Grafana dashboard configuration that provides visual monitoring of key system metrics:
- API Performance: Response times (p95, p99), error rates, throughput
- Cache Performance: Hit rates and efficiency
- Database Performance: Query times, connection pool utilization
- Contract Performance: Gas costs for different operations
- System Health: Overall service status
Grafana dashboard for SLO compliance and error budget tracking:
- Error Budget Status: Remaining budget per SLO
- Burn Rate: How fast error budget is being consumed
- SLO Compliance: Percentage of time meeting targets
- Trend Analysis: Historical performance trends
Grafana provisioning configuration for automatic dashboard loading from the repository.
Prometheus/Alertmanager alert rules for critical system thresholds:
- API Alerts: High response times, error rates, low throughput
- Cache Alerts: Low hit rates
- Database Alerts: Slow queries, high connection pool utilization
- Contract Alerts: High gas costs
- System Alerts: Service downtime, high resource usage
- Regression Alerts: Performance degradation detection
Performance threshold definitions used by testing and monitoring:
- Backend response time targets (p95, p99, avg)
- Error rate limits
- Throughput minimums
- Cache hit rate requirements
- Contract gas cost limits
- Database query time targets
- Regression detection thresholds
Dashboards are version-controlled and automatically loaded by Grafana on startup.
services:
grafana:
image: grafana/grafana:latest
volumes:
- ./performance/config/grafana-provisioning.yaml:/etc/grafana/provisioning/dashboards/dashboards.yaml
- ./performance/config/:/var/lib/grafana/dashboards/
environment:
- GF_SECURITY_ADMIN_PASSWORD=admin
ports:
- "3000:3000"apiVersion: v1
kind: ConfigMap
metadata:
name: grafana-provisioning
data:
dashboards.yaml: |
apiVersion: 1
providers:
- name: 'PredictIQ Dashboards'
orgId: 1
folder: 'Performance'
type: file
disableDeletion: false
updateIntervalSeconds: 10
allowUiUpdates: true
options:
path: /var/lib/grafana/dashboards
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: grafana
spec:
template:
spec:
containers:
- name: grafana
image: grafana/grafana:latest
volumeMounts:
- name: provisioning
mountPath: /etc/grafana/provisioning/dashboards
- name: dashboards
mountPath: /var/lib/grafana/dashboards
volumes:
- name: provisioning
configMap:
name: grafana-provisioning
- name: dashboards
configMap:
name: grafana-dashboardsWhen you make changes to dashboards in the Grafana UI, export them back to the repository:
# Set your Grafana API key
export GRAFANA_API_KEY=your-api-key-here
# Export dashboards
node ../scripts/export-grafana-dashboards.js
# Review changes
git diff grafana-*.json
# Commit and push
git add grafana-*.json
git commit -m "chore: update Grafana dashboards"
git push- Log in to Grafana as an admin
- Navigate to Configuration → API Keys
- Click "New API Key"
- Set Role to "Admin"
- Copy the generated key
-
Make changes in Grafana UI
- Add panels, modify queries, adjust colors, etc.
- Test the dashboard thoroughly
-
Export to repository
GRAFANA_API_KEY=your-key node ../scripts/export-grafana-dashboards.js
-
Review and commit
git diff grafana-*.json # Review changes git add grafana-*.json git commit -m "feat: add new performance panel to dashboard"
-
Deploy
- Push to main branch
- Grafana will automatically reload dashboards on next startup
- Or manually reload via Grafana UI
If provisioning is not available:
-
Import the dashboard into Grafana:
curl -X POST http://grafana:3000/api/dashboards/db \ -H "Content-Type: application/json" \ -H "Authorization: Bearer YOUR_API_KEY" \ -d @grafana-dashboard.json
-
Or manually import via Grafana UI:
- Navigate to Dashboards → Import
- Upload
grafana-dashboard.json
-
Add alerts to Prometheus configuration:
# prometheus.yml rule_files: - "alerts.yaml"
-
Configure Alertmanager for notifications:
# alertmanager.yml route: receiver: 'team-notifications' group_by: ['alertname', 'component'] group_wait: 30s group_interval: 5m repeat_interval: 4h receivers: - name: 'team-notifications' slack_configs: - api_url: 'YOUR_SLACK_WEBHOOK_URL' channel: '#predictiq-alerts'
Ensure your application exports the following metrics:
http_request_duration_seconds_bucket- Request duration histogramhttp_requests_total- Total request counter with status labels
cache_hits_total- Cache hit countercache_misses_total- Cache miss counter
db_query_duration_seconds_bucket- Query duration histogramdb_connections_active- Active connections gaugedb_connections_max- Maximum connections gauge
contract_gas_used- Gas usage gauge with operation labels
up- Service availability (1 = up, 0 = down)node_memory_*- Memory metricsnode_cpu_seconds_total- CPU metrics
- Critical: Immediate action required, system functionality impaired
- Warning: Attention needed, potential issues developing
- Info: Informational, no immediate action required
Edit thresholds.json to modify performance targets:
{
"backend": {
"response_time": {
"p95": 200, // Adjust as needed
"p99": 500,
"avg": 150
}
}
}To add new panels to the Grafana dashboard:
- Edit
grafana-dashboard.json - Add a new panel object to the
panelsarray - Configure queries, visualization, and alerts
- Re-import the dashboard
To add new alert rules:
- Edit
alerts.yaml - Add a new rule under the appropriate group
- Define the PromQL expression, duration, and annotations
- Reload Prometheus configuration
- Set realistic thresholds based on actual system performance
- Use percentiles (p95, p99) instead of averages for latency
- Configure alert fatigue prevention with appropriate
fordurations - Group related alerts to avoid notification spam
- Document alert runbooks for incident response
- Review and adjust thresholds regularly based on system evolution
The thresholds defined here are used by:
- Performance tests in
performance/backend/k6/ - Regression detection in
performance/scripts/compare-results.js - Automated performance gates in CI pipelines
For questions or issues with observability configuration:
- Check Grafana documentation: https://grafana.com/docs/
- Check Prometheus documentation: https://prometheus.io/docs/
- Review performance test results in
performance/directory