# ServerBandwidthStatService
> 服务带宽统计服务

---

## findDailyServerBandwidthStats
> 获取最近N天峰值带宽

- 角色：`admin`
- HTTP：`POST https://backend.dooki.cloud/ServerBandwidthStatService/findDailyServerBandwidthStats`
- RPC：`rpc findDailyServerBandwidthStats(FindDailyServerBandwidthStatsRequest) returns (FindDailyServerBandwidthStatsResponse);`

**请求对象 (`FindDailyServerBandwidthStatsRequest`)**

```json
{
  "serverId": "int64 // 服务ID（网站ID）",
  "days": "int32",
  "algo": "string // 带宽算法，目前支持secondly和avg"
}
```

**响应对象 (`FindDailyServerBandwidthStatsResponse`)**

```json
{
  "stats": "[]Stat",
  "percentile": "int32 // 百分位",
  "nthStat": "Stat // 百分位统计数据",
  "day": "string",
  "bytes": "int64 // 峰值字节/秒",
  "bits": "int64 // 峰值比特/秒"
}
```

**调用示例**

```bash
curl -X POST "https://backend.dooki.cloud/ServerBandwidthStatService/findDailyServerBandwidthStats" \
  -H "Content-Type: application/json" \
  -H "X-Edge-Access-Token: <YOUR_TOKEN>" \
  -d '{
    ...
  }'
```

---

## findDailyServerBandwidthStatsBetweenDays
> 读取日期段内的带宽数据

- 角色：`admin`, `user`
- HTTP：`POST https://backend.dooki.cloud/ServerBandwidthStatService/findDailyServerBandwidthStatsBetweenDays`
- RPC：`rpc findDailyServerBandwidthStatsBetweenDays (FindDailyServerBandwidthStatsBetweenDaysRequest) returns (FindDailyServerBandwidthStatsBetweenDaysResponse);`

**请求对象 (`FindDailyServerBandwidthStatsBetweenDaysRequest`)**

```json
{
  "userId": "int64 // 用户ID，和服务ID二选一",
  "serverId": "int64 // 服务ID，和用户ID二选一",
  "dayFrom": "string // 开始日期 YYYYMMDD",
  "dayTo": "string // 结束日期 YYYYMMDD",
  "percentile": "int32 // 可选项，百分位（nth）带宽位置，0-100之间",
  "nodeRegionId": "int64 // 区域ID，可选项（目前只有用户整体统计支持区域ID）",
  "algo": "string // 带宽算法，目前支持secondly和avg"
}
```

**响应对象 (`FindDailyServerBandwidthStatsBetweenDaysResponse`)**

```json
{
  "stats": "[]Stat",
  "nthStat": "Stat",
  "day": "string",
  "timeAt": "string",
  "bytes": "int64 // 峰值字节/秒",
  "bits": "int64 // 峰值比特/秒"
}
```

**调用示例**

```bash
curl -X POST "https://backend.dooki.cloud/ServerBandwidthStatService/findDailyServerBandwidthStatsBetweenDays" \
  -H "Content-Type: application/json" \
  -H "X-Edge-Access-Token: <YOUR_TOKEN>" \
  -d '{
    ...
  }'
```

---

## findHourlyServerBandwidthStats
> 获取最近N小时峰值带宽

- 角色：`admin`
- HTTP：`POST https://backend.dooki.cloud/ServerBandwidthStatService/findHourlyServerBandwidthStats`
- RPC：`rpc findHourlyServerBandwidthStats(FindHourlyServerBandwidthStatsRequest) returns (FindHourlyServerBandwidthStatsResponse);`

**请求对象 (`FindHourlyServerBandwidthStatsRequest`)**

```json
{
  "serverId": "int64 // 服务ID（网站ID）",
  "hours": "int32",
  "algo": "string // 带宽算法，目前支持secondly和avg"
}
```

**响应对象 (`FindHourlyServerBandwidthStatsResponse`)**

```json
{
  "stats": "[]Stat",
  "percentile": "int32 // 百分位",
  "nthStat": "Stat // 百分位统计数据",
  "day": "string",
  "hour": "int32",
  "bytes": "int64 // 峰值字节/秒",
  "bits": "int64 // 峰值比特/秒"
}
```

**调用示例**

```bash
curl -X POST "https://backend.dooki.cloud/ServerBandwidthStatService/findHourlyServerBandwidthStats" \
  -H "Content-Type: application/json" \
  -H "X-Edge-Access-Token: <YOUR_TOKEN>" \
  -d '{
    ...
  }'
```

---

## findServerBandwidthStats
> 获取服务的峰值带宽

- 角色：`admin`
- HTTP：`POST https://backend.dooki.cloud/ServerBandwidthStatService/findServerBandwidthStats`
- RPC：`rpc findServerBandwidthStats(FindServerBandwidthStatsRequest) returns (FindServerBandwidthStatsResponse);`

**请求对象 (`FindServerBandwidthStatsRequest`)**

```json
{
  "serverId": "int64 // 服务ID",
  "month": "string // YYYYMM，month和day二选一",
  "day": "string // YYYYMMDD",
  "algo": "string // 带宽算法，目前支持secondly和avg"
}
```

**响应对象 (`FindServerBandwidthStatsResponse`)**

```json
{
  "serverBandwidthStats": "[]ServerBandwidthStat"
}
```

**调用示例**

```bash
curl -X POST "https://backend.dooki.cloud/ServerBandwidthStatService/findServerBandwidthStats" \
  -H "Content-Type: application/json" \
  -H "X-Edge-Access-Token: <YOUR_TOKEN>" \
  -d '{
    ...
  }'
```

---
