{
  "tags": [
    "四层监控"
  ],
  "description": "聚合流访问日志，返回监听端口的请求数和发送流量排行。接口要求登录。普通用户仅查询自身 uid，管理员查询全部。榜单条数由系统 `res_rank_size` 配置决定；日志库无聚合或查询异常时返回空数组。",
  "operationId": "user_get_v1_monitor_stream_top",
  "security": [
    {
      "AccessToken": []
    },
    {
      "ApiKey": [],
      "ApiSecret": []
    }
  ],
  "responses": {
    "200": {
      "description": "成功和业务错误均返回 HTTP 200。",
      "content": {
        "application/json": {
          "schema": {
            "oneOf": [
              {
                "type": "object",
                "required": [
                  "code",
                  "msg",
                  "data"
                ],
                "properties": {
                  "code": {
                    "type": "integer",
                    "enum": [
                      0
                    ],
                    "description": "四层转发端口排行查询成功时固定为 0。"
                  },
                  "msg": {
                    "type": "string",
                    "enum": [
                      ""
                    ],
                    "description": "四层转发端口排行查询成功时固定为空字符串。"
                  },
                  "data": {
                    "type": "array",
                    "description": "端口排行数据。",
                    "items": {
                      "type": "object",
                      "required": [
                        "traffic",
                        "count",
                        "res"
                      ],
                      "properties": {
                        "traffic": {
                          "type": "number",
                          "description": "该端口 bytes_sent 总和。"
                        },
                        "count": {
                          "type": "integer",
                          "minimum": 0,
                          "description": "该端口请求文档数。"
                        },
                        "res": {
                          "type": "string",
                          "description": "流日志字段 port 的聚合值。"
                        }
                      },
                      "additionalProperties": false
                    }
                  }
                },
                "additionalProperties": false
              },
              {
                "type": "object",
                "required": [
                  "code",
                  "msg",
                  "data"
                ],
                "properties": {
                  "code": {
                    "type": "string",
                    "enum": [
                      "stream_monitor_top-2",
                      "stream_monitor_top-3",
                      "stream_monitor_top-4",
                      "stream_monitor_top-5",
                      "login_required"
                    ],
                    "description": "缺少/不支持类型、缺少/非法时间窗口或认证失败的业务错误码。"
                  },
                  "msg": {
                    "type": "string",
                    "description": "排行类型、时间窗口或认证失败的具体原因。"
                  },
                  "data": {
                    "type": "string",
                    "enum": [
                      ""
                    ],
                    "description": "发生业务错误时固定返回空字符串。"
                  }
                },
                "additionalProperties": false
              }
            ]
          },
          "examples": {
            "success": {
              "summary": "查询成功",
              "value": {
                "code": 0,
                "msg": "",
                "data": [
                  {
                    "traffic": 1048576,
                    "count": 42,
                    "res": "443/TCP"
                  }
                ]
              }
            }
          },
          "example": {
            "code": 0,
            "msg": "",
            "data": [
              {
                "traffic": 1048576,
                "count": 42,
                "res": "443/TCP"
              }
            ]
          }
        }
      }
    }
  },
  "x-python-handler": "monitor.StreamTopAPI",
  "x-python-route-line": 824,
  "x-audience": "user",
  "x-auth": "user",
  "x-reviewed": true,
  "parameters": [
    {
      "name": "type",
      "in": "query",
      "required": true,
      "description": "排行维度，当前仅支持监听端口。",
      "schema": {
        "type": "string",
        "enum": [
          "top-ports"
        ]
      }
    },
    {
      "name": "recent_time",
      "in": "query",
      "required": true,
      "description": "最近时间窗口，仅支持 10m、30m、60m。",
      "schema": {
        "type": "string",
        "enum": [
          "10m",
          "30m",
          "60m"
        ],
        "example": "10m"
      }
    }
  ],
  "x-itecdn-source-reviewed": true,
  "extensions": [
    {
      "key": "x-python-handler",
      "value": "monitor.StreamTopAPI"
    },
    {
      "key": "x-python-route-line",
      "value": 824
    },
    {
      "key": "x-audience",
      "value": "user"
    },
    {
      "key": "x-auth",
      "value": "user"
    },
    {
      "key": "x-reviewed",
      "value": true
    },
    {
      "key": "x-itecdn-source-reviewed",
      "value": true
    }
  ],
  "method": "get",
  "path": "/v1/monitor/stream/top",
  "servers": [
    {
      "url": "https://master.example.invalid",
      "description": "不可调用的示例地址；复制示例后替换为自己的主控域名。"
    }
  ],
  "securitySchemes": {
    "AccessToken": {
      "type": "apiKey",
      "in": "header",
      "name": "access-token",
      "description": "通过登录接口获得的短期访问令牌。"
    },
    "ApiKey": {
      "type": "apiKey",
      "in": "header",
      "name": "api-key",
      "description": "API Key；必须和 api-secret 同时发送。"
    },
    "ApiSecret": {
      "type": "apiKey",
      "in": "header",
      "name": "api-secret",
      "description": "API Secret；必须和 api-key 同时发送。"
    }
  },
  "info": {
    "title": "itecdn v5 用户 API",
    "version": "5.x",
    "description": "itecdn v5.x Python 主控用户 API。本文档不适用于 v6 或其它实现。"
  },
  "postman": {
    "name": "查询流服务端口流量排行",
    "description": {
      "content": "聚合流访问日志，返回监听端口的请求数和发送流量排行。接口要求登录。普通用户仅查询自身 uid，管理员查询全部。榜单条数由系统 `res_rank_size` 配置决定；日志库无聚合或查询异常时返回空数组。",
      "type": "text/plain"
    },
    "url": {
      "path": [
        "v1",
        "monitor",
        "stream",
        "top"
      ],
      "host": [
        "{{baseUrl}}"
      ],
      "query": [
        {
          "disabled": false,
          "description": {
            "content": "(Required) 排行维度，当前仅支持监听端口。",
            "type": "text/plain"
          },
          "key": "type",
          "value": ""
        },
        {
          "disabled": false,
          "description": {
            "content": "(Required) 最近时间窗口，仅支持 10m、30m、60m。",
            "type": "text/plain"
          },
          "key": "recent_time",
          "value": ""
        }
      ],
      "variable": []
    },
    "header": [
      {
        "key": "Accept",
        "value": "application/json"
      }
    ],
    "method": "GET",
    "auth": {
      "type": "apikey",
      "apikey": [
        {
          "type": "any",
          "value": "access-token",
          "key": "key"
        },
        {
          "type": "any",
          "value": "{{apiKey}}",
          "key": "value"
        },
        {
          "type": "any",
          "value": "header",
          "key": "in"
        }
      ]
    }
  }
}