# Statistics

> View a CDN domain's traffic, origin fetch traffic, request count, and origin fetch request count, and get statistics and logs through the API.

Statistics help you understand a CDN domain's usage, cache effectiveness, and abnormal spikes.

## View a single CDN domain

Entry point: **CDN › Static acceleration management (静态加速管理) ›** the domain's **Manage (管理) › Statistics (统计)**.

| Chart                      | Lines                                                                                                                           | Unit  |
| -------------------------- | ------------------------------------------------------------------------------------------------------------------------------- | ----- |
| **Traffic usage (流量使用统计)** | `<domain> traffic`: traffic the edge returns to visitors`<domain> origin fetch traffic`: traffic the edge pulls from the origin | MB    |
| **Request count (请求数统计)**  | `<domain> requests`: requests the edge receives`<domain> origin fetch requests`: requests the edge sends to the origin          | Count |

Both charts are aggregated by day (Beijing time) and show roughly the last month by default. Hover over a line to see that day's values.

### Select a time range

In the upper-right corner of each chart you can select a date range. Click **Search (搜索)** to apply it and **Reset (重置)** to restore the default. The time ranges of the two charts are independent.

- A single query covers at most 31 days. Going over shows "查询时间跨度不可超过31天" (the query time span can't exceed 31 days)
- You can query only the last 90 days. Going over shows "仅支持查询90天内的数据" (only data within 90 days can be queried)

## View all CDN domains under a bucket

Entry point: **Object storage › Bucket list › a specific bucket › Statistics (对象存储 › 桶列表 › 具体的桶 › 统计)**. Besides S4 traffic and request counts, the chart also lists a line for each CDN domain that uses this bucket as the origin. See [Usage statistics](https://docs.bitiful.com/en/bitiful-s4/handbook/statistics.md).

## How to read them

- **Cache hits**: `1 - origin fetch traffic ÷ traffic` gives a rough estimate of the hit rate by traffic. When the hit rate is low, check whether URLs change often and whether you recently did a directory purge.
- **Traffic spikes**: Check IPs, Referers, and User-Agents in [Access logs](https://docs.bitiful.com/en/console/access-logs.md), then configure [hotlink protection](https://docs.bitiful.com/en/cdn/handbook/access-control.md) or a [per-connection speed limit](https://docs.bitiful.com/en/cdn/handbook/performance.md).
- **Relation to your bill**: Charts are for watching trends. Charges follow your [Charges](https://docs.bitiful.com/en/prices/handbook/bills.md). Origin fetch traffic and requests incur separate S4 charges. See [Data transfer](https://docs.bitiful.com/en/prices/detail/transfer-prices.md) and [Requests](https://docs.bitiful.com/en/prices/detail/requests-prices.md).

## Get them with the API

The [Static CDN API](https://docs.bitiful.com/en/developer/api/cdn.md) provides edge traffic, origin fetch traffic, edge request counts, and origin fetch request counts aggregated by hour, day, and month, plus access logs for the last 3 days.

```bash
curl -G "https://api.bitiful.com/cdn/data/cdn.example.com/traffic" \
  -H "Authorization: <API Token>" \
  --data-urlencode "start_time=1735660800" \
  --data-urlencode "end_time=1735747200" \
  --data-urlencode "period=hourly"
```

```json
{
  "data": [
    { "timestamp": 1735660800, "value": 128.5 },
    { "timestamp": 1735664400, "value": 96.2 }
  ]
}
```

For traffic, `value` is in MB. For request counts, `value` is a count.
