{
  "tags": [
    "网站监控"
  ],
  "description": "按时间窗口聚合网站 HTTP 访问日志的带宽、流量、请求量、QPS、缓存命中率、4xx/5xx 状态码或源站指标。接口要求登录。普通用户固定查询自身 uid，且所传域名必须属于自己；管理员不加 uid 限制。服务端按查询跨度自动使用 1 分钟（少于 6 小时）、2 分钟（6 至 12 小时）或 5 分钟（12 小时及以上）桶，跨度超过 50 小时会拒绝。",
  "operationId": "user_get_v1_monitor_site_realtime",
  "security": [
    {
      "AccessToken": []
    },
    {
      "ApiKey": [],
      "ApiSecret": []
    }
  ],
  "responses": {
    "200": {
      "description": "成功及参数、域名权限错误均返回 HTTP 200。日志库未返回聚合时 data 为空数组。时间戳为 Elasticsearch date_histogram 桶键（通常为 Unix 毫秒时间戳）。",
      "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": "除 status-4xx/status-5xx 外，元素为 [时间戳, 指标值]。bandwidth 和 backend-bandwidth 为每秒字节数；traffic/backend-traffic 为字节总量；req 为请求数；qps 为每秒请求数；backend-resp-time 为平均源站响应时间；两个缓存类型为 0 至 100 的命中百分比。状态码类型时元素改为分组对象。",
                    "items": {
                      "oneOf": [
                        {
                          "type": "array",
                          "minItems": 2,
                          "maxItems": 2,
                          "items": {
                            "oneOf": [
                              {
                                "type": "integer",
                                "description": "桶时间戳。"
                              },
                              {
                                "type": "number",
                                "description": "指标值。"
                              }
                            ]
                          }
                        },
                        {
                          "type": "object",
                          "required": [
                            "name",
                            "value"
                          ],
                          "properties": {
                            "name": {
                              "type": "string",
                              "description": "4xx 或 5xx HTTP 状态码。"
                            },
                            "value": {
                              "type": "array",
                              "description": "该状态码完整时间序列。",
                              "items": {
                                "type": "array",
                                "minItems": 2,
                                "maxItems": 2,
                                "items": {
                                  "oneOf": [
                                    {
                                      "type": "integer",
                                      "description": "桶时间戳。"
                                    },
                                    {
                                      "type": "integer",
                                      "minimum": 0,
                                      "description": "该状态码在对应时间桶内的请求数。"
                                    }
                                  ]
                                }
                              }
                            }
                          },
                          "additionalProperties": false
                        }
                      ]
                    }
                  }
                },
                "additionalProperties": false
              },
              {
                "type": "object",
                "required": [
                  "code",
                  "msg",
                  "data"
                ],
                "properties": {
                  "code": {
                    "type": "string",
                    "enum": [
                      "realtime-1",
                      "realtime-2",
                      "realtime-3",
                      "realtime-5",
                      "realtime-6",
                      "realtime-7",
                      "realtime-8",
                      "realtime-9",
                      "realtime-11",
                      "login_required"
                    ],
                    "description": "缺少/不支持指标、缺少时间、域名无权限、日期格式、跨度超过限制、端口错误或认证失败的业务错误码。"
                  },
                  "msg": {
                    "type": "string",
                    "description": "实时指标参数、权限或时间范围校验失败的具体原因。"
                  },
                  "data": {
                    "type": "string",
                    "enum": [
                      ""
                    ],
                    "description": "发生业务错误时固定返回空字符串。"
                  }
                },
                "additionalProperties": false
              }
            ]
          },
          "examples": {
            "traffic": {
              "summary": "流量序列",
              "value": {
                "code": 0,
                "msg": "",
                "data": [
                  [
                    1767225600000,
                    1048576
                  ],
                  [
                    1767225660000,
                    524288
                  ]
                ]
              }
            },
            "status4xx": {
              "summary": "4xx 状态码序列",
              "value": {
                "code": 0,
                "msg": "",
                "data": [
                  {
                    "name": "404",
                    "value": [
                      [
                        1767225600000,
                        3
                      ],
                      [
                        1767225660000,
                        0
                      ]
                    ]
                  },
                  {
                    "name": "403",
                    "value": [
                      [
                        1767225600000,
                        1
                      ],
                      [
                        1767225660000,
                        2
                      ]
                    ]
                  }
                ]
              }
            }
          },
          "example": {
            "code": 0,
            "msg": "",
            "data": [
              [
                1767225600000,
                1048576
              ],
              [
                1767225660000,
                524288
              ]
            ]
          }
        }
      }
    }
  },
  "x-python-handler": "monitor.RealTimeAPI",
  "x-python-route-line": 736,
  "x-audience": "user",
  "x-auth": "user",
  "x-reviewed": true,
  "parameters": [
    {
      "name": "type",
      "in": "query",
      "required": true,
      "description": "监控指标类型。",
      "schema": {
        "type": "string",
        "enum": [
          "bandwidth",
          "traffic",
          "req",
          "qps",
          "req-cache-status",
          "byte-cache-status",
          "status-4xx",
          "status-5xx",
          "backend-bandwidth",
          "backend-traffic",
          "backend-resp-time"
        ]
      }
    },
    {
      "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": "domain",
      "in": "query",
      "required": false,
      "description": "空格分隔的网站域名精确筛选。普通用户每个域名都必须属于自己。",
      "schema": {
        "type": "string",
        "example": "www.example.invalid api.example.invalid"
      }
    },
    {
      "name": "server_port",
      "in": "query",
      "required": false,
      "description": "源站端口精确筛选，必须为合法端口。",
      "schema": {
        "type": "string",
        "example": "443"
      }
    }
  ],
  "x-itecdn-source-reviewed": true,
  "extensions": [
    {
      "key": "x-python-handler",
      "value": "monitor.RealTimeAPI"
    },
    {
      "key": "x-python-route-line",
      "value": 736
    },
    {
      "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/site/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": "按时间窗口聚合网站 HTTP 访问日志的带宽、流量、请求量、QPS、缓存命中率、4xx/5xx 状态码或源站指标。接口要求登录。普通用户固定查询自身 uid，且所传域名必须属于自己；管理员不加 uid 限制。服务端按查询跨度自动使用 1 分钟（少于 6 小时）、2 分钟（6 至 12 小时）或 5 分钟（12 小时及以上）桶，跨度超过 50 小时会拒绝。",
      "type": "text/plain"
    },
    "url": {
      "path": [
        "v1",
        "monitor",
        "site",
        "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": "domain",
          "value": ""
        },
        {
          "disabled": false,
          "description": {
            "content": "源站端口精确筛选，必须为合法端口。",
            "type": "text/plain"
          },
          "key": "server_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"
        }
      ]
    }
  }
}