{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/eurobase-dev/json-schema/eurobase-dev-project-container-metrics-response-schema.json",
  "title": "ProjectContainerMetricsResponse",
  "x-generated": "2026-11-07",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/eurobase-dev-openapi.json#/components/schemas/ProjectContainerMetricsResponse",
  "type": "object",
  "required": [
    "ok",
    "project",
    "container",
    "timeRange",
    "windowStart",
    "windowEnd",
    "windowGranularity",
    "bucketStarts",
    "availability",
    "serviceLevel",
    "requestsByStatus",
    "slowRequestPaths",
    "runtimeUsage",
    "latestSignals",
    "updatedAt"
  ],
  "properties": {
    "ok": {
      "type": "boolean"
    },
    "project": {
      "type": "object",
      "required": [
        "id"
      ],
      "properties": {
        "id": {
          "type": "string"
        }
      }
    },
    "container": {
      "type": "object",
      "required": [
        "id",
        "name",
        "hostname"
      ],
      "properties": {
        "id": {
          "type": "string"
        },
        "name": {
          "type": "string"
        },
        "hostname": {
          "type": [
            "string",
            "null"
          ]
        }
      }
    },
    "timeRange": {
      "type": "string",
      "enum": [
        "30m",
        "6h",
        "24h",
        "7d"
      ]
    },
    "windowStart": {
      "type": "string",
      "format": "date-time"
    },
    "windowEnd": {
      "type": "string",
      "format": "date-time"
    },
    "windowGranularity": {
      "type": "string"
    },
    "bucketStarts": {
      "type": "array",
      "items": {
        "type": "string",
        "format": "date-time"
      }
    },
    "availability": {
      "type": "string",
      "enum": [
        "ready",
        "partial",
        "unavailable",
        "empty"
      ]
    },
    "serviceLevel": {
      "type": "object",
      "required": [
        "availability",
        "totalRequests",
        "successfulRequests",
        "successfulRequestRate",
        "fourXxRate",
        "fiveXxRate",
        "p95ResponseTimeMs",
        "timeline"
      ],
      "properties": {
        "availability": {
          "$ref": "#/$defs/ProjectContainerMetricsScalar"
        },
        "totalRequests": {
          "type": "integer",
          "minimum": 0
        },
        "successfulRequests": {
          "type": "integer",
          "minimum": 0
        },
        "successfulRequestRate": {
          "$ref": "#/$defs/ProjectContainerMetricsScalar"
        },
        "fourXxRate": {
          "$ref": "#/$defs/ProjectContainerMetricsScalar"
        },
        "fiveXxRate": {
          "$ref": "#/$defs/ProjectContainerMetricsScalar"
        },
        "p95ResponseTimeMs": {
          "$ref": "#/$defs/ProjectContainerMetricsScalar"
        },
        "timeline": {
          "type": "array",
          "items": {
            "type": "object",
            "required": [
              "bucketStart",
              "bucketEnd",
              "totalRequests",
              "successfulRequests",
              "statusClasses",
              "availability"
            ],
            "properties": {
              "bucketStart": {
                "type": "string",
                "format": "date-time"
              },
              "bucketEnd": {
                "type": "string",
                "format": "date-time"
              },
              "totalRequests": {
                "type": "integer",
                "minimum": 0
              },
              "successfulRequests": {
                "type": "integer",
                "minimum": 0
              },
              "statusClasses": {
                "type": "object",
                "required": [
                  "2xx",
                  "3xx",
                  "4xx",
                  "5xx"
                ],
                "properties": {
                  "2xx": {
                    "type": "integer",
                    "minimum": 0
                  },
                  "3xx": {
                    "type": "integer",
                    "minimum": 0
                  },
                  "4xx": {
                    "type": "integer",
                    "minimum": 0
                  },
                  "5xx": {
                    "type": "integer",
                    "minimum": 0
                  }
                }
              },
              "availability": {
                "type": "string",
                "enum": [
                  "empty",
                  "healthy",
                  "warning",
                  "error"
                ]
              }
            }
          }
        }
      }
    },
    "requestsByStatus": {
      "type": "object",
      "required": [
        "totals",
        "buckets"
      ],
      "properties": {
        "totals": {
          "type": "object",
          "required": [
            "2xx",
            "3xx",
            "4xx",
            "5xx"
          ],
          "properties": {
            "2xx": {
              "type": "integer",
              "minimum": 0
            },
            "3xx": {
              "type": "integer",
              "minimum": 0
            },
            "4xx": {
              "type": "integer",
              "minimum": 0
            },
            "5xx": {
              "type": "integer",
              "minimum": 0
            }
          }
        },
        "buckets": {
          "type": "array",
          "items": {
            "type": "object"
          }
        }
      }
    },
    "slowRequestPaths": {
      "type": "object",
      "required": [
        "items"
      ],
      "properties": {
        "items": {
          "type": "array",
          "maxItems": 5,
          "items": {
            "type": "object",
            "required": [
              "requestPath",
              "p95Ms",
              "count",
              "lastSeenAt"
            ],
            "properties": {
              "requestPath": {
                "type": "string",
                "maxLength": 8000
              },
              "p95Ms": {
                "type": [
                  "number",
                  "null"
                ]
              },
              "count": {
                "type": "integer",
                "minimum": 0
              },
              "lastSeenAt": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "date-time"
              }
            }
          }
        }
      }
    },
    "runtimeUsage": {
      "type": "object",
      "required": [
        "availability",
        "reason",
        "window",
        "activeSeconds",
        "cpuSeconds",
        "memoryGbSeconds"
      ],
      "properties": {
        "availability": {
          "type": "string",
          "enum": [
            "ready",
            "unavailable"
          ]
        },
        "reason": {
          "type": [
            "string",
            "null"
          ]
        },
        "workerEvent": {
          "type": "object",
          "description": "Present on a Workers project row the app host shipped (ADR 0076 contract §5a).",
          "properties": {
            "kind": {
              "type": "string",
              "enum": [
                "console",
                "runtime",
                "dropped",
                "stopped",
                "startup-failed",
                "reset"
              ]
            },
            "origin": {
              "type": "string",
              "enum": [
                "worker",
                "platform"
              ]
            },
            "level": {
              "type": [
                "string",
                "null"
              ]
            },
            "reason": {
              "type": [
                "string",
                "null"
              ]
            },
            "count": {
              "type": [
                "integer",
                "null"
              ]
            }
          }
        },
        "workerRequest": {
          "type": "object",
          "description": "Present on a Workers route Gateway access row: how the request was served. path never carries the query string.",
          "properties": {
            "outcome": {
              "type": "string",
              "enum": [
                "ok",
                "app-error",
                "refused",
                "suspended",
                "startup-failed",
                "instance-stopped",
                "platform-restart",
                "crashed",
                "timeout",
                "interrupted",
                "gateway"
              ]
            },
            "billed": {
              "type": [
                "boolean",
                "null"
              ]
            },
            "cold": {
              "type": [
                "boolean",
                "null"
              ]
            },
            "appClass": {
              "type": [
                "string",
                "null"
              ]
            },
            "cause": {
              "type": "string",
              "enum": [
                "oom",
                "watchdog",
                "recycle-drain",
                "crash"
              ]
            },
            "path": {
              "type": [
                "string",
                "null"
              ]
            }
          }
        },
        "window": {
          "type": "object",
          "required": [
            "code",
            "startAt",
            "endAt"
          ],
          "properties": {
            "code": {
              "type": "string",
              "enum": [
                "current_billing_month"
              ]
            },
            "startAt": {
              "type": "string",
              "format": "date-time"
            },
            "endAt": {
              "type": "string",
              "format": "date-time"
            }
          }
        },
        "activeSeconds": {
          "$ref": "#/$defs/ProjectContainerMetricsScalar"
        },
        "cpuSeconds": {
          "$ref": "#/$defs/ProjectContainerMetricsScalar"
        },
        "memoryGbSeconds": {
          "$ref": "#/$defs/ProjectContainerMetricsScalar"
        }
      }
    },
    "latestSignals": {
      "type": "object",
      "required": [
        "items"
      ],
      "properties": {
        "items": {
          "type": "array",
          "items": {
            "type": "object"
          }
        }
      }
    },
    "updatedAt": {
      "type": "string",
      "format": "date-time"
    }
  },
  "$defs": {
    "ProjectContainerMetricsScalar": {
      "type": "object",
      "required": [
        "value",
        "unit"
      ],
      "properties": {
        "value": {
          "type": [
            "number",
            "string",
            "null"
          ]
        },
        "unit": {
          "type": "string"
        }
      }
    }
  }
}