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 status
  • errors_total - Total number of errors
  • latency - Action processing latency

Access Metrics

View metrics directly:

curl http://127.0.0.1:8000/metrics

Prometheus 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 submitted
  • action.approved - Action approved
  • action.denied - Action denied
  • action.completed - Action execution completed

Subscribe to Events

curl -N http://127.0.0.1:8000/v1/events

Filter 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/health

Readiness Endpoint

GET /ready - Checks database connectivity

curl http://127.0.0.1:8000/ready

Monitoring 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