{
  "tags": [
    "四层监控"
  ],
  "description": "按时间窗口聚合流访问日志的带宽或流量。接口要求登录。普通用户未传 port 时只查询自身 uid；传 port 时每个值必须属于自己的监听配置，格式为 `端口/协议大写`（如 `443/TCP`）。管理员未传 port 时查询全部日志。查询跨度不得超过 50 小时，聚合桶随跨度自动为 1、2 或 5 分钟。",
  "operationId": "user_get_v1_monitor_stream_realtime",
  "security": [
    {
      "AccessToken": []
    },
    {
      "ApiKey": [],
      "ApiSecret": []
    }
  ],
  "responses": {
    "200": {
      "description": "成功、参数和端口权限错误均返回 HTTP 200；日志库没有聚合时 data 为空数组。",
      "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": "时间序列，元素为 [桶时间戳, 指标值]。stream-bandwidth 为每秒 bytes_sent，stream-traffic 为桶内 bytes_sent 总和。",
                    "items": {
                      "type": "array",
                      "minItems": 2,
                      "maxItems": 2,
                      "items": {
                        "type": "number",
                        "description": "第一个元素为 Elasticsearch 桶时间戳，第二个元素为指标值。"
                      }
                    }
                  }
                },
                "additionalProperties": false
              },
              {
                "type": "object",
                "required": [
                  "code",
                  "msg",
                  "data"
                ],
                "properties": {
                  "code": {
                    "type": "string",
                    "enum": [
                      "stream-realtime-1",
                      "stream-realtime-2",
                      "stream-realtime-3",
                      "stream-realtime-5",
                      "stream-realtime-6",
                      "stream-realtime-7",
                      "stream-realtime-8",
                      "stream-realtime-9",
                      "login_required"
                    ],
                    "description": "缺少/不支持指标、缺少时间、端口无权限、日期格式、跨度过长或认证失败的业务错误码。"
                  },
                  "msg": {
                    "type": "string",
                    "description": "实时指标参数、端口权限或时间范围校验失败的具体原因。"
                  },
                  "data": {
                    "type": "string",
                    "enum": [
                      ""
                    ],
                    "description": "发生业务错误时固定返回空字符串。"
                  }
                },
                "additionalProperties": false
              }
            ]
          },
          "examples": {
            "bandwidth": {
              "summary": "带宽序列",
              "value": {
                "code": 0,
                "msg": "",
                "data": [
                  [
                    1767225600000,
                    1048576
                  ],
                  [
                    1767225660000,
                    524288
                  ]
                ]
              }
            }
          },
          "example": {
            "code": 0,
            "msg": "",
            "data": [
              [
                1767225600000,
                1048576
              ],
              [
                1767225660000,
                524288
              ]
            ]
          }
        }
      }
    }
  },
  "x-python-handler": "monitor.StreamRealTimeAPI",
  "x-python-route-line": 816,
  "x-audience": "user",
  "x-auth": "user",
  "x-reviewed": true,
  "parameters": [
    {
      "name": "type",
      "in": "query",
      "required": true,
      "description": "监控指标。",
      "schema": {
        "type": "string",
        "enum": [
          "stream-bandwidth",
          "stream-traffic"
        ]
      }
    },
    {
      "name": "start",
      "in": "query",
      "required": true,
      "description": "开始时间（含），格式 YYYY-MM-DD HH:mm:ss，按 +08:00 解释。",
      "schema": {
        "type": "string",
        "example": "2026-01-01 00:00:00"
      }
    },
    {
      "name": "end",
      "in": "query",
      "required": true,
      "description": "结束时间（不含），格式 YYYY-MM-DD HH:mm:ss。",
      "schema": {
        "type": "string",
        "example": "2026-01-01 01:00:00"
      }
    },
    {
      "name": "port",
      "in": "query",
      "required": false,
      "description": "空格分隔的流监听标识，格式 `端口/协议大写`。普通用户只能传自己的监听项。",
      "schema": {
        "type": "string",
        "example": "443/TCP 8443/TCP"
      }
    }
  ],
  "x-itecdn-source-reviewed": true,
  "extensions": [
    {
      "key": "x-python-handler",
      "value": "monitor.StreamRealTimeAPI"
    },
    {
      "key": "x-python-route-line",
      "value": 816
    },
    {
      "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/realtime",
  "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": "按时间窗口聚合流访问日志的带宽或流量。接口要求登录。普通用户未传 port 时只查询自身 uid；传 port 时每个值必须属于自己的监听配置，格式为 `端口/协议大写`（如 `443/TCP`）。管理员未传 port 时查询全部日志。查询跨度不得超过 50 小时，聚合桶随跨度自动为 1、2 或 5 分钟。",
      "type": "text/plain"
    },
    "url": {
      "path": [
        "v1",
        "monitor",
        "stream",
        "realtime"
      ],
      "host": [
        "{{baseUrl}}"
      ],
      "query": [
        {
          "disabled": false,
          "description": {
            "content": "(Required) 监控指标。",
            "type": "text/plain"
          },
          "key": "type",
          "value": ""
        },
        {
          "disabled": false,
          "description": {
            "content": "(Required) 开始时间（含），格式 YYYY-MM-DD HH:mm:ss，按 +08:00 解释。",
            "type": "text/plain"
          },
          "key": "start",
          "value": ""
        },
        {
          "disabled": false,
          "description": {
            "content": "(Required) 结束时间（不含），格式 YYYY-MM-DD HH:mm:ss。",
            "type": "text/plain"
          },
          "key": "end",
          "value": ""
        },
        {
          "disabled": false,
          "description": {
            "content": "空格分隔的流监听标识，格式 `端口/协议大写`。普通用户只能传自己的监听项。",
            "type": "text/plain"
          },
          "key": "port",
          "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"
        }
      ]
    }
  }
}