# 使用统计

ISP 的统计维度是**按 IP**，而不是按请求流。每个 IP 是你拥有的可计费资源，仪表盘与 API 帮你判断哪些 IP 真正在产生价值。

## 控制台

**控制台 → ISP → 统计** 提供：

* **每 IP 用量** — 字节、请求数、错误率
* **每批次健康评分** — 错误 + 替换 + 饱和度的综合分
* **Top 目标** — ISP 流量最多去往的站点
* **IP 利用率** — 批次中闲置的 IP（释放候选）
* **替换历史** — 历次替换记录
* **续费日历** — 即将到期的日期

粒度：最近 24 小时按分钟，7 天内按 5 分钟，更久按小时。

## REST API

按时间维度的单 IP 流量：

```bash
curl -H "Authorization: Bearer API_KEY" \
     "https://api.helodata.com/v1/isp/traffic?batch_id=bat_01HX&from=2026-05-01&to=2026-05-28&group_by=ip"
```

响应：

```json
{
  "rows": [
    { "ip": "198.51.100.42", "bytes_in": 1234567, "bytes_out": 9876543, "requests": 4210, "error_rate": 0.012 },
    { "ip": "198.51.100.43", "bytes_in": 222345,  "bytes_out": 134567,  "requests": 88,   "error_rate": 0.0 }
  ]
}
```

`group_by` 可取 `ip`、`batch`、`target_domain`、`day`。

单 IP 详情（最近 N 条请求）：

```bash
curl -H "Authorization: Bearer API_KEY" \
     "https://api.helodata.com/v1/isp/ips/{ip_id}/requests?limit=100"
```

返回最近 1,000 条采样请求的状态、目标、字节、时间戳。

## 响应头

每个 ISP IP 在每个响应中返回：

```
X-Helodata-Bytes-In: 1248
X-Helodata-Bytes-Out: 38745
X-Helodata-IP-Health: 96
X-Helodata-Request-Id: req_01HX2K3PQ4M5
```

`X-Helodata-IP-Health` 是该 IP 实时 0–100 评分——低于 80 时（若配置了告警）会触发。

## 给请求打标签

机制同住宅——`X-Helodata-Tag` 请求头。标签出现在控制台筛选与流量 API 的 `group_by` 中。

```bash
curl -x http://helo_s1a2b3c4d5e:PASSWORD@198.51.100.42:8000 \
     -H "X-Helodata-Tag: campaign-acme-q2" \
     https://example.com
```

## 发现闲置 IP

控制台会标记最近 7 天未使用的 IP，两种处理：

* **重新分配** — 让流量经过它们
* **释放** — 在下一个续费日丢弃以省钱

## 健康告警

**控制台 → 告警** 中可设置 ISP 专属告警：

* 单 IP 健康分跌破 X
* 批次健康分跌破 X
* 每周期替换次数超过 Y
* 批次进入宽限期（续费提醒）
* 单 IP 错误率在 Z 分钟内超过 Z%

告警通过邮件与可选的 Slack webhook 发送。

## 账单对账

ISP 按 IP 按月计费——**定额**，与用量无关。**账单 → 发票** 上的条目就是 `数量 × 月单价`，不需要核对带宽。

期内替换 IP 不会改变发票数量——替换在 10% 免费额度内被月费覆盖。


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.helodata.com/helodata-zh/chan-pin/overview-2/statistics.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
