Metrics & Observability
Monitor FaraCore with Prometheus metrics, Server-Sent Events, and health checks.
Prometheus Metrics
FaraCore exposes Prometheus-compatible metrics at /metrics endpoint.
Available Metrics
actions_total- Total number of actions by statuserrors_total- Total number of errorslatency- Action processing latency
Access Metrics
View metrics directly:
curl http://127.0.0.1:8000/metricsPrometheus Configuration
Add FaraCore to your Prometheus prometheus.yml:
scrape_configs:
- job_name: 'faramesh'
scrape_interval: 15s
static_configs:
- targets: ['localhost:8000']Server-Sent Events (SSE)
FaraCore streams real-time events via Server-Sent Events at /v1/events.
Event Types
action.created- New action submittedaction.approved- Action approvedaction.denied- Action deniedaction.completed- Action execution completed
Subscribe to Events
curl -N http://127.0.0.1:8000/v1/eventsFilter Events
Filter events by query parameters:
# Filter by status
curl -N "http://127.0.0.1:8000/v1/events?status=pending_approval"
# Filter by agent
curl -N "http://127.0.0.1:8000/v1/events?agent_id=my-agent"
# Filter by tool
curl -N "http://127.0.0.1:8000/v1/events?tool=shell"JavaScript Example
const eventSource = new EventSource('http://127.0.0.1:8000/v1/events?status=pending_approval');
eventSource.onmessage = (event) => {
const data = JSON.parse(event.data);
console.log('Event:', data.type, data.data);
};
eventSource.onerror = (error) => {
console.error('SSE error:', error);
};Health Checks
FaraCore provides health check endpoints for monitoring and load balancers.
Health Endpoint
GET /health - Always returns 200 OK
curl http://127.0.0.1:8000/healthReadiness Endpoint
GET /ready - Checks database connectivity
curl http://127.0.0.1:8000/readyMonitoring Setup
Recommended monitoring stack:
- Prometheus - Metrics collection
- Grafana - Metrics visualization
- AlertManager - Alerting on metrics
Example Grafana Dashboard
Create dashboards to visualize:
- Action submission rate
- Approval rate
- Error rate
- Average processing latency
- Actions by status
- Actions by tool