Skip to Content

Network Metrics

Network metrics help investigate HTTP traffic, status codes, most accessed routes, latency, user agents, and source IPs. These endpoints are available for HTTP projects on plans that include metrics access.

Required permissions

EndpointsMinimum scope
summary, status-codes, routes, and user-agentsproject.metrics.read on project:<project-id>
request-events and source-ipsproject.network.visitors.read on project:<project-id>
visitorsproject.network.visitors.read on project:<project-id>

request-events and source-ips return each visitor's source IP and user agent, so they require their own permission. project.metrics.read does not grant access to them: the query responds 403, with no masked version. owner has full access; assistant, member, and organization API Keys need the matching scope, and project.network.visitors.read is not part of the assistant initial template. AI assistant connections through MCP only query the aggregated endpoints.

In Preview environments, the permission is checked on the Preview's main project.

Headers

HeaderRequiredDescription
x-api-key or AuthorizationYesOrganization API Key or user token
x-organization-idWith a user tokenActive project organization. Not needed with an organization API key

Endpoints

EndpointMain use
GET /v1/project/:id/metrics/network/summaryAggregated view of requests, bytes, latency, and status classes
GET /v1/project/:id/metrics/network/status-codesGrouping by HTTP status code
GET /v1/project/:id/metrics/network/routesMost accessed routes and status codes by route
GET /v1/project/:id/metrics/network/user-agentsMost frequent user agents
GET /v1/project/:id/metrics/network/request-eventsIndividual request events
GET /v1/project/:id/metrics/network/source-ipsSource IPs with the highest volume
GET /v1/project/:id/metrics/network/visitorsVisitors, page views, top pages, referrers and countries for the period (query range_seconds and tz); the period is limited by your plan's history

Path Parameters

ParameterTypeDescription
idstringProject ID

Query Filters

ParameterTypeDescription
range_secondsnumberRelative window. Accepted values: 300, 3600, 21600, 86400, 604800
fromstringStart date in ISO 8601 format. Must be earlier than or equal to to
tostringEnd date in ISO 8601 format
status_codestringSpecific HTTP status code, such as 500
status_classstringHTTP class: 2xx, 3xx, 4xx, or 5xx
source_ipstringSource IP used to filter events
pathstringHTTP path used to filter events
pagenumberPagination page. Default: 1, maximum: 10000
limitnumberItems per page. Default: 5, maximum: 50

Use range_seconds for simple dashboards. Use from and to when you need to compare a specific incident window.

Without range_seconds, from, or to, the query uses the last 24 hours. The maximum window is 7 days counted back from to: an older from is adjusted to that limit.

Summary

GET /v1/project/:id/metrics/network/summary
{
  "status": "success",
  "message": "get network analytics summary with success",
  "data": {
    "project_id": "507f1f77bcf86cd799439011",
    "window": {
      "from": "2026-05-23T13:00:00.000Z",
      "to": "2026-05-23T14:00:00.000Z",
      "seconds": 3600
    },
    "summary": {
      "requests": 1200,
      "bytes_received": 420000,
      "bytes_sent": 1800000,
      "avg_latency_ms": 42,
      "p95_latency_ms": 120
    },
    "status_classes": {
      "2xx": 1160,
      "3xx": 20,
      "4xx": 15,
      "5xx": 5
    }
  }
}

Paginated Lists

The status-codes, routes, user-agents, request-events, and source-ips endpoints return data and pagination.

{
  "status": "success",
  "message": "get network analytics status codes with success",
  "data": {
    "data": [
      {
        "status_code": "200",
        "requests": 1160,
        "user_agents": {
          "Mozilla/5.0": 900,
          "curl/8.0": 260
        },
        "routes": {
          "GET /": 800,
          "GET /health": 360
        },
        "bytes_received": 390000,
        "bytes_sent": 1600000,
        "avg_latency_ms": 39,
        "p95_latency_ms": 110
      }
    ],
    "pagination": {
      "page": 1,
      "limit": 5,
      "total": 1,
      "total_pages": 1
    }
  }
}

Request events

Each request-events item represents a request received by the application:

{
  "status": "success",
  "message": "get network analytics request events with success",
  "data": {
    "data": [
      {
        "timestamp": "2026-05-23T13:58:12.000Z",
        "source_ip": "203.0.113.10",
        "method": "GET",
        "path": "/",
        "status_code": "200",
        "bytes_received": 320,
        "bytes_sent": 1540,
        "user_agent": "Mozilla/5.0",
        "latency_ms": 38
      }
    ],
    "pagination": {
      "page": 1,
      "limit": 5,
      "total": 1,
      "total_pages": 1
    }
  }
}

source-ips returns items with source_ip and requests, sorted by request volume.

Examples

Last-hour summary

curl -X GET "https://api.zenifra.com/v1/project/507f1f77bcf86cd799439011/metrics/network/summary?range_seconds=3600" \
  -H "x-api-key: your-api-key" \
  -H "x-organization-id: your-organization-id"

Routes with 5xx errors

curl -X GET "https://api.zenifra.com/v1/project/507f1f77bcf86cd799439011/metrics/network/routes?status_class=5xx&limit=10" \
  -H "x-api-key: your-api-key" \
  -H "x-organization-id: your-organization-id"

Events for a specific IP

Requires project.network.visitors.read.

curl -X GET "https://api.zenifra.com/v1/project/507f1f77bcf86cd799439011/metrics/network/request-events?source_ip=203.0.113.10" \
  -H "x-api-key: your-api-key" \
  -H "x-organization-id: your-organization-id"

Python

import requests

API_KEY = "your-api-key"
ORGANIZATION_ID = "your-organization-id"
PROJECT_ID = "507f1f77bcf86cd799439011"

headers = {"x-api-key": API_KEY, "x-organization-id": ORGANIZATION_ID}

summary = requests.get(
    f"https://api.zenifra.com/v1/project/{PROJECT_ID}/metrics/network/summary",
    params={"range_seconds": 3600},
    headers=headers
).json()

print(summary)

Common Errors

CodeLikely reasonHow to fix
400Invalid parameter, such as range_seconds outside the list, a date not in ISO 8601 format, or from later than toReview the query filters
402Plan does not allow metrics accessUpgrade to a plan with metrics enabled
403Invalid organization or permission (insufficient organization permission)Confirm x-organization-id and the scope required by the endpoint; request-events and source-ips require project.network.visitors.read
422Project is not HTTP (code: "PROJECT_OPERATION_NOT_SUPPORTED")Use database metrics in Metrics and Logs
404Project not foundCheck Project ID, API Key, and organization

Next Steps

Last updated on

On this page