Usage Analytics

Monitor your API usage, track performance metrics, and analyze governance events with TORK's comprehensive analytics dashboard.

Overview

The TORK analytics dashboard provides real-time insights into your AI governance platform. Track API calls, monitor response times, analyze governance events, and export detailed reports for compliance and optimization.

API Metrics

Total calls, success rates, and error tracking

Performance

Response times, P95/P99 latencies

Governance

PII detections, violations, jailbreaks

Trends

Historical data and comparisons

Key Metrics

API Usage Metrics

MetricDescription
total_callsTotal number of API calls made
successful_callsAPI calls that completed successfully (2xx)
failed_callsAPI calls that failed (4xx, 5xx)
avg_response_time_msAverage response time in milliseconds
p95_response_time_ms95th percentile response time
p99_response_time_ms99th percentile response time

Governance Metrics

MetricDescription
pii_detectionsPII instances detected and redacted
policy_violationsPolicy rule violations blocked
jailbreak_attemptsJailbreak/prompt injection attempts blocked
rate_limit_hitsRequests rejected due to rate limits
circuit_breaker_triggersCircuit breaker activations

Time Ranges

Analytics data can be viewed across different time periods:

Last 7 days
Last 30 days
Last 90 days
Data Retention
Hourly data is retained for 7 days. Daily aggregated data is retained for 365 days. Export your data regularly for long-term storage needs.

API Reference

Access analytics data programmatically using the Analytics API.

Get Analytics Summary

bash
curl -X GET "https://api.tork.network/v1/analytics?range=7d" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json"

Response

json
{
  "success": true,
  "data": {
    "summary": {
      "totalCalls": 15420,
      "successfulCalls": 14980,
      "failedCalls": 440,
      "avgResponseTime": 145.2,
      "piiDetections": 234,
      "policyViolations": 56,
      "jailbreakAttempts": 12,
      "rateLimitHits": 89
    },
    "comparison": {
      "callsChange": 12.5,
      "successRateChange": -0.3,
      "responseTimeChange": -5.2,
      "piiChange": 8.1
    },
    "timeRange": {
      "label": "7d",
      "start": "2024-01-14T00:00:00Z",
      "end": "2024-01-21T00:00:00Z"
    }
  }
}

Available Endpoints

EndpointDescription
GET /v1/analyticsSummary metrics with period comparison
GET /v1/analytics/trendsDaily trend data for charts
GET /v1/analytics/heatmapHourly usage patterns by day of week
GET /v1/analytics/endpointsBreakdown by API endpoint
GET /v1/analytics/agentsTop agents by usage
GET /v1/analytics/exportExport data as CSV

Exporting Data

Export analytics data as CSV for external analysis, reporting, or compliance documentation.

Export Types

Summary Report

Overview metrics and totals for the period

Daily Breakdown

Day-by-day analytics with all metrics

Hourly Details

Hour-by-hour granular data (last 7 days)

Governance Events

PII, violations, and jailbreak data

API Export

bash
# Export daily breakdown as CSV
curl -X GET "https://api.tork.network/v1/analytics/export?range=30d&type=daily" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -o analytics-daily-30d.csv

Analytics Alerts

Configure alerts to get notified when metrics exceed thresholds.

Available Alert Metrics

  • error_rate - Percentage of failed API calls
  • pii_detections - Number of PII instances detected
  • policy_violations - Policy violations per time window
  • response_time - Average response time in ms
  • rate_limit_hits - Rate limit rejections
  • jailbreak_attempts - Jailbreak detection count

Create Alert via API

bash
curl -X POST "https://api.tork.network/v1/analytics/alerts" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "High Error Rate Alert",
    "metric": "error_rate",
    "condition": "above",
    "threshold": 5,
    "time_window_minutes": 60,
    "notify_email": true,
    "notify_slack": true
  }'

Best Practices

Monitor Key Metrics

Set up alerts for error rate, response time, and governance events. Aim for less than 1% error rate and sub-200ms average response times.

Review Usage Patterns

Use the heatmap to identify peak usage hours. Consider scaling resources or adjusting rate limits based on patterns.

Regular Exports

Export analytics data monthly for compliance documentation. Keep governance event exports for audit trails.

Track Agent Performance

Monitor individual agent success rates. Investigate agents with lower than 95% success rate for potential issues.