itecdn 5.x用户文档
itecdn 5.x / 用户 API

查询流服务实时监控时间序列

GET/v1/monitor/stream/realtime

按时间窗口聚合流访问日志的带宽或流量。接口要求登录。普通用户未传 port 时只查询自身 uid;传 port 时每个值必须属于自己的监听配置,格式为 端口/协议大写(如 443/TCP)。管理员未传 port 时查询全部日志。查询跨度不得超过 50 小时,聚合桶随跨度自动为 1、2 或 5 分钟。

身份认证

access-token

api-key + api-secret

认证定义
{
  "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 同时发送。"
  }
}

请求参数

参数位置类型必填说明与约束
typequerystring必填

监控指标。

完整参数定义
{
  "name": "type",
  "in": "query",
  "required": true,
  "description": "监控指标。",
  "schema": {
    "type": "string",
    "enum": [
      "stream-bandwidth",
      "stream-traffic"
    ]
  }
}
startquerystring必填

开始时间(含),格式 YYYY-MM-DD HH:mm:ss,按 +08:00 解释。

完整参数定义
{
  "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"
  }
}
endquerystring必填

结束时间(不含),格式 YYYY-MM-DD HH:mm:ss。

完整参数定义
{
  "name": "end",
  "in": "query",
  "required": true,
  "description": "结束时间(不含),格式 YYYY-MM-DD HH:mm:ss。",
  "schema": {
    "type": "string",
    "example": "2026-01-01 01:00:00"
  }
}
portquerystring可选

空格分隔的流监听标识,格式 端口/协议大写。普通用户只能传自己的监听项。

完整参数定义
{
  "name": "port",
  "in": "query",
  "required": false,
  "description": "空格分隔的流监听标识,格式 `端口/协议大写`。普通用户只能传自己的监听项。",
  "schema": {
    "type": "string",
    "example": "443/TCP 8443/TCP"
  }
}

响应

HTTP 200

成功、参数和端口权限错误均返回 HTTP 200;日志库没有聚合时 data 为空数组。

application/json

oneOf

oneOf · 1 · object
字段类型必填说明与约束
codeinteger必填

四层转发实时指标查询成功时固定为 0。

约束 / 默认值 / 示例
{
  "enum": [
    0
  ]
}
msgstring必填

四层转发实时指标查询成功时固定为空字符串。

约束 / 默认值 / 示例
{
  "enum": [
    ""
  ]
}
dataarray <array <number>>必填

时间序列,元素为 [桶时间戳, 指标值]。stream-bandwidth 为每秒 bytes_sent,stream-traffic 为桶内 bytes_sent 总和。

展开字段结构

时间序列,元素为 [桶时间戳, 指标值]。stream-bandwidth 为每秒 bytes_sent,stream-traffic 为桶内 bytes_sent 总和。

数组元素 · array <number>
数组元素 · number

第一个元素为 Elasticsearch 桶时间戳,第二个元素为指标值。

oneOf · 2 · object
字段类型必填说明与约束
codestring必填

缺少/不支持指标、缺少时间、端口无权限、日期格式、跨度过长或认证失败的业务错误码。

约束 / 默认值 / 示例
{
  "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"
  ]
}
msgstring必填

实时指标参数、端口权限或时间范围校验失败的具体原因。

datastring必填

发生业务错误时固定返回空字符串。

约束 / 默认值 / 示例
{
  "enum": [
    ""
  ]
}
完整 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
    }
  ]
}

示例

{
  "code": 0,
  "msg": "",
  "data": [
    [
      1767225600000,
      1048576
    ],
    [
      1767225660000,
      524288
    ]
  ]
}

带宽序列

{
  "code": 0,
  "msg": "",
  "data": [
    [
      1767225600000,
      1048576
    ],
    [
      1767225660000,
      524288
    ]
  ]
}

cURL 示例

根据文档生成;请替换主控地址、路径参数和凭证,并按上表补充查询参数。

curl --request GET \
  "https://master.example.invalid/v1/monitor/stream/realtime" \
  --header "access-token: YOUR_ACCESS_TOKEN"

查看完整接口 JSON