{
  "openapi": "3.1.1",
  "info": {
    "title": "Kubernetes Event Explorer API",
    "version": "1.0.0",
    "summary": "Paste kubectl events and get a timeline, reason taxonomy and likely root causes per workload.",
    "description": "Every endpoint performs the same calculation as the human page and returns inputs, result, units, assumptions, sources, warnings and computedAt. MCP endpoint: /mcp."
  },
  "servers": [
    {
      "url": "https://kuberneteseventexplorer.usefulweb.site"
    }
  ],
  "paths": {
    "/api/v1/calculate": {
      "post": {
        "operationId": "calculate",
        "summary": "Paste kubectl events and get a timeline, reason taxonomy and likely root causes per workload.",
        "description": "Paste `kubectl get events -A -o json` or the default `kubectl get events` table. Events are grouped by involved object and inferred workload (Pod → ReplicaSet → Deployment), each reason is classified (rollout, crash loop, probes, image pulls, scheduling, volumes, OOM, node pressure…), and evidence-based root-cause hypotheses explain what probably happened and what to check next.\n\nMethodology:\n- JSON events: involvedObject/regarding, reason, message, type, count/series.count, firstTimestamp/lastTimestamp/eventTime are read as documented for core/v1 and events.k8s.io/v1 Events.\n- Table output: columns are located from the header line; relative ages (e.g. \"3m (x7 over 11m)\") are converted to absolute times counted back from capturedAt (default: the analysis time), and the \"xN\" repeat count is used as the occurrence count.\n- Reasons are mapped to categories using the reason strings emitted by kubelet, scheduler, controllers and node-problem-detector; ambiguous reasons are refined by message (BackOff restarting vs pulling image; Unhealthy liveness vs readiness; Failed ErrImagePull vs CreateContainerConfigError).\n- Pods are linked to Deployments via ScalingReplicaSet/SuccessfulCreate messages, then by the <deployment>-<rs-hash>-<pod-hash> naming convention.\n- Root-cause rules combine signals per workload (e.g. liveness failures + back-off → probe-induced restarts; back-off alone → app exits; FailedScheduling message → resources/taints/affinity/PVC).",
        "tags": [
          "devcloud"
        ],
        "x-mcp-tool": "kubernetes_event_explorer",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/KubernetesEventExplorerInput"
              },
              "examples": {
                "example1": {
                  "summary": "Crash-looping checkout, unschedulable worker, bad image tag (JSON)",
                  "value": {
                    "text": "{\"apiVersion\":\"v1\",\"kind\":\"List\",\"items\":[{\"metadata\":{\"name\":\"checkout.1\",\"namespace\":\"shop\"},\"involvedObject\":{\"kind\":\"Deployment\",\"namespace\":\"shop\",\"name\":\"checkout\"},\"reason\":\"ScalingReplicaSet\",\"message\":\"Scaled up replica set checkout-7d9f8b6c5d to 1\",\"type\":\"Normal\",\"count\":1,\"firstTimestamp\":\"2026-10-12T09:40:02Z\",\"lastTimestamp\":\"2026-10-12T09:40:02Z\",\"source\":{\"component\":\"deployment-controller\"}},{\"metadata\":{\"name\":\"checkout-rs.1\",\"namespace\":\"shop\"},\"involvedObject\":{\"kind\":\"ReplicaSet\",\"namespace\":\"shop\",\"name\":\"checkout-7d9f8b6c5d\"},\"reason\":\"SuccessfulCreate\",\"message\":\"Created pod: checkout-7d9f8b6c5d-x2k9p\",\"type\":\"Normal\",\"count\":1,\"firstTimestamp\":\"2026-10-12T09:40:02Z\",\"lastTimestamp\":\"2026-10-12T09:40:02Z\",\"source\":{\"component\":\"replicaset-controller\"}},{\"metadata\":{\"name\":\"p1.1\",\"namespace\":\"shop\"},\"involvedObject\":{\"kind\":\"Pod\",\"namespace\":\"shop\",\"name\":\"checkout-7d9f8b6c5d-x2k9p\"},\"reason\":\"Scheduled\",\"message\":\"Successfully assigned shop/checkout-7d9f8b6c5d-x2k9p to node-a\",\"type\":\"Normal\",\"count\":1,\"firstTimestamp\":\"2026-10-12T09:40:03Z\",\"lastTimestamp\":\"2026-10-12T09:40:03Z\",\"source\":{\"component\":\"default-scheduler\"}},{\"metadata\":{\"name\":\"p1.2\",\"namespace\":\"shop\"},\"involvedObject\":{\"kind\":\"Pod\",\"namespace\":\"shop\",\"name\":\"checkout-7d9f8b6c5d-x2k9p\"},\"reason\":\"Pulled\",\"message\":\"Container image \\\"registry.example.com/checkout:2.4.0\\\" already present on machine\",\"type\":\"Normal\",\"count\":6,\"firstTimestamp\":\"2026-10-12T09:40:04Z\",\"lastTimestamp\":\"2026-10-12T09:49:30Z\",\"source\":{\"component\":\"kubelet\"}},{\"metadata\":{\"name\":\"p1.3\",\"namespace\":\"shop\"},\"involvedObject\":{\"kind\":\"Pod\",\"namespace\":\"shop\",\"name\":\"checkout-7d9f8b6c5d-x2k9p\"},\"reason\":\"Unhealthy\",\"message\":\"Liveness probe failed: Get \\\"http://10.0.3.17:8080/healthz\\\": context deadline exceeded (Client.Timeout exceeded while awaiting headers)\",\"type\":\"Warning\",\"count\":15,\"firstTimestamp\":\"2026-10-12T09:40:40Z\",\"lastTimestamp\":\"2026-10-12T09:49:20Z\",\"source\":{\"component\":\"kubelet\"}},{\"metadata\":{\"name\":\"p1.4\",\"namespace\":\"shop\"},\"involvedObject\":{\"kind\":\"Pod\",\"namespace\":\"shop\",\"name\":\"checkout-7d9f8b6c5d-x2k9p\"},\"reason\":\"Killing\",\"message\":\"Container checkout failed liveness probe, will be restarted\",\"type\":\"Normal\",\"count\":5,\"firstTimestamp\":\"2026-10-12T09:41:00Z\",\"lastTimestamp\":\"2026-10-12T09:49:21Z\",\"source\":{\"component\":\"kubelet\"}},{\"metadata\":{\"name\":\"p1.5\",\"namespace\":\"shop\"},\"involvedObject\":{\"kind\":\"Pod\",\"namespace\":\"shop\",\"name\":\"checkout-7d9f8b6c5d-x2k9p\"},\"reason\":\"BackOff\",\"message\":\"Back-off restarting failed container checkout in pod checkout-7d9f8b6c5d-x2k9p_shop(5b1c)\",\"type\":\"Warning\",\"count\":22,\"firstTimestamp\":\"2026-10-12T09:43:10Z\",\"lastTimestamp\":\"2026-10-12T09:55:00Z\",\"source\":{\"component\":\"kubelet\"}},{\"metadata\":{\"name\":\"w1.1\",\"namespace\":\"shop\"},\"involvedObject\":{\"kind\":\"Pod\",\"namespace\":\"shop\",\"name\":\"worker-0\"},\"reason\":\"FailedScheduling\",\"message\":\"0/3 nodes are available: 1 node(s) had untolerated taint {dedicated: gpu}, 2 Insufficient memory. preemption: 0/3 nodes are available: 1 Preemption is not helpful for scheduling, 2 No preemption victims found for incoming pod.\",\"type\":\"Warning\",\"count\":8,\"firstTimestamp\":\"2026-10-12T09:45:00Z\",\"lastTimestamp\":\"2026-10-12T09:58:00Z\",\"source\":{\"component\":\"default-scheduler\"}},{\"metadata\":{\"name\":\"n1.1\",\"namespace\":\"default\"},\"involvedObject\":{\"kind\":\"Node\",\"name\":\"node-b\"},\"reason\":\"OOMKilling\",\"message\":\"Memory cgroup out of memory: Killed process 4121 (java) total-vm:4512340kB, anon-rss:1048576kB\",\"type\":\"Warning\",\"count\":2,\"firstTimestamp\":\"2026-10-12T09:50:11Z\",\"lastTimestamp\":\"2026-10-12T09:52:40Z\",\"source\":{\"component\":\"kernel-monitor\"}},{\"metadata\":{\"name\":\"img.1\",\"namespace\":\"shop\"},\"involvedObject\":{\"kind\":\"Pod\",\"namespace\":\"shop\",\"name\":\"search-6c77d9b8f4-q8rtz\"},\"reason\":\"Failed\",\"message\":\"Failed to pull image \\\"registry.example.com/search:2.5.1\\\": rpc error: code = NotFound desc = failed to pull and unpack image: manifest unknown\",\"type\":\"Warning\",\"count\":4,\"firstTimestamp\":\"2026-10-12T09:56:00Z\",\"lastTimestamp\":\"2026-10-12T09:59:10Z\",\"source\":{\"component\":\"kubelet\"}},{\"metadata\":{\"name\":\"img.2\",\"namespace\":\"shop\"},\"involvedObject\":{\"kind\":\"Pod\",\"namespace\":\"shop\",\"name\":\"search-6c77d9b8f4-q8rtz\"},\"reason\":\"BackOff\",\"message\":\"Back-off pulling image \\\"registry.example.com/search:2.5.1\\\"\",\"type\":\"Normal\",\"count\":9,\"firstTimestamp\":\"2026-10-12T09:56:20Z\",\"lastTimestamp\":\"2026-10-12T09:59:40Z\",\"source\":{\"component\":\"kubelet\"}}]}"
                  }
                },
                "example2": {
                  "summary": "Missing Secret during scale-up (kubectl table)",
                  "value": {
                    "text": "NAMESPACE   LAST SEEN           TYPE      REASON                    OBJECT                        MESSAGE\npayments    12m                 Normal    ScalingReplicaSet         deployment/api                Scaled up replica set api-5f6d8c9b7 from 2 to 4\npayments    12m                 Normal    SuccessfulCreate          replicaset/api-5f6d8c9b7      Created pod: api-5f6d8c9b7-abcde\npayments    11m                 Warning   FailedMount               pod/api-5f6d8c9b7-abcde       MountVolume.SetUp failed for volume \"db-creds\" : secret \"db-creds\" not found\npayments    3m (x7 over 11m)    Warning   Failed                    pod/api-5f6d8c9b7-abcde       Error: secret \"db-creds\" not found\npayments    2m (x30 over 10m)   Warning   Unhealthy                 pod/api-5f6d8c9b7-zzq1t       Readiness probe failed: HTTP probe failed with statuscode: 503\npayments    90s                 Warning   FailedGetResourceMetric   horizontalpodautoscaler/api   failed to get cpu utilization: missing request for cpu in container \"api\" of Pod \"api-5f6d8c9b7-abcde\"",
                    "capturedAt": "2026-10-12T10:00"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Calculation result envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/KubernetesEventExplorerResult"
                }
              }
            }
          },
          "400": {
            "description": "Malformed JSON body.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "422": {
            "description": "Invalid input (see errors[]).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded (see Retry-After).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tool": {
      "get": {
        "operationId": "getToolDefinition",
        "summary": "Inputs, output schema and examples for this tool",
        "responses": {
          "200": {
            "description": "Tool definition.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Problem": {
        "type": "object",
        "description": "RFC 9457 problem details. 422 responses include per-field `errors`.",
        "required": [
          "type",
          "title",
          "status",
          "detail"
        ],
        "properties": {
          "type": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "status": {
            "type": "integer"
          },
          "detail": {
            "type": "string"
          },
          "code": {
            "type": "string"
          },
          "errors": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "field",
                "message"
              ],
              "properties": {
                "field": {
                  "type": "string"
                },
                "message": {
                  "type": "string"
                }
              }
            }
          }
        }
      },
      "KubernetesEventExplorerInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "text": {
            "title": "kubectl events output",
            "description": "Output of `kubectl get events -A -o json` (best: exact timestamps) or the plain `kubectl get events -A` table including the header line. events.k8s.io/v1 JSON also works.",
            "type": "string",
            "maxLength": 3000000
          },
          "file": {
            "title": "Or upload the file",
            "description": "Read in memory as UTF-8 text and not stored. Max 5 MiB. Upload as {filename, contentType?, contentBase64}. Max 5120 KiB. Accepts .json,.txt,.log.",
            "type": "object",
            "additionalProperties": false,
            "required": [
              "filename",
              "contentBase64"
            ],
            "properties": {
              "filename": {
                "type": "string"
              },
              "contentType": {
                "type": "string"
              },
              "contentBase64": {
                "type": "string"
              }
            }
          },
          "namespace": {
            "title": "Only this namespace (optional)",
            "type": "string",
            "maxLength": 253
          },
          "warningsOnly": {
            "title": "Only show Warning events in the timeline",
            "type": "boolean",
            "default": false
          },
          "capturedAt": {
            "title": "Table output captured at (UTC, optional)",
            "description": "Only for the text table: relative ages like \"5m\" are counted back from this time. Default: now. Local date-time YYYY-MM-DDTHH:mm",
            "type": "string"
          }
        },
        "required": []
      },
      "KubernetesEventExplorerResult": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "schemaVersion",
          "tool",
          "computedAt",
          "inputs",
          "summary",
          "result",
          "units",
          "assumptions",
          "sources",
          "warnings",
          "presentation",
          "links"
        ],
        "properties": {
          "schemaVersion": {
            "type": "string",
            "const": "1.0"
          },
          "tool": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "id",
              "name",
              "version"
            ],
            "properties": {
              "id": {
                "type": "string"
              },
              "name": {
                "type": "string"
              },
              "version": {
                "type": "string"
              }
            }
          },
          "computedAt": {
            "type": "string",
            "format": "date-time"
          },
          "inputs": {
            "type": "object",
            "description": "Normalised inputs actually used, including applied defaults."
          },
          "summary": {
            "type": "string"
          },
          "result": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "format",
              "eventCount",
              "occurrences",
              "byType",
              "categories",
              "reasons",
              "objects",
              "diagnoses",
              "window"
            ],
            "properties": {
              "format": {
                "type": "string",
                "enum": [
                  "json",
                  "table"
                ]
              },
              "eventCount": {
                "type": "integer"
              },
              "occurrences": {
                "type": "integer"
              },
              "byType": {
                "type": "object",
                "additionalProperties": {
                  "type": "integer"
                }
              },
              "categories": {
                "type": "object",
                "additionalProperties": {
                  "type": "integer"
                }
              },
              "window": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "first",
                  "last"
                ],
                "properties": {
                  "first": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "last": {
                    "type": [
                      "string",
                      "null"
                    ]
                  }
                }
              },
              "reasons": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "reason",
                    "signal",
                    "category",
                    "type",
                    "events",
                    "occurrences",
                    "objects",
                    "first",
                    "last",
                    "meaning"
                  ],
                  "properties": {
                    "reason": {
                      "type": "string"
                    },
                    "signal": {
                      "type": "string"
                    },
                    "category": {
                      "type": "string"
                    },
                    "type": {
                      "type": "string"
                    },
                    "events": {
                      "type": "integer"
                    },
                    "occurrences": {
                      "type": "integer"
                    },
                    "objects": {
                      "type": "integer"
                    },
                    "first": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "last": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "meaning": {
                      "type": "string"
                    }
                  }
                }
              },
              "objects": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "object",
                    "workload",
                    "warnings",
                    "normal",
                    "topSignals",
                    "first",
                    "last"
                  ],
                  "properties": {
                    "object": {
                      "type": "string"
                    },
                    "workload": {
                      "type": "string"
                    },
                    "warnings": {
                      "type": "integer"
                    },
                    "normal": {
                      "type": "integer"
                    },
                    "topSignals": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "first": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "last": {
                      "type": [
                        "string",
                        "null"
                      ]
                    }
                  }
                }
              },
              "diagnoses": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "object",
                    "severity",
                    "finding",
                    "explanation",
                    "nextSteps",
                    "evidence"
                  ],
                  "properties": {
                    "object": {
                      "type": "string"
                    },
                    "severity": {
                      "type": "string",
                      "enum": [
                        "critical",
                        "warning",
                        "info"
                      ]
                    },
                    "finding": {
                      "type": "string"
                    },
                    "explanation": {
                      "type": "string"
                    },
                    "nextSteps": {
                      "type": "string"
                    },
                    "evidence": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  }
                }
              }
            }
          },
          "units": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          },
          "assumptions": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "sources": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "title"
              ],
              "properties": {
                "title": {
                  "type": "string"
                },
                "url": {
                  "type": "string"
                },
                "publisher": {
                  "type": "string"
                },
                "retrievedAt": {
                  "type": "string"
                },
                "note": {
                  "type": "string"
                }
              }
            }
          },
          "warnings": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "presentation": {
            "type": "array",
            "items": {
              "type": "object"
            },
            "description": "Display blocks used by the human page (same data)."
          },
          "links": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "human",
              "api",
              "openapi",
              "methodology"
            ],
            "properties": {
              "human": {
                "type": "string",
                "format": "uri"
              },
              "api": {
                "type": "string",
                "format": "uri"
              },
              "openapi": {
                "type": "string",
                "format": "uri"
              },
              "methodology": {
                "type": "string",
                "format": "uri"
              }
            }
          }
        }
      }
    }
  }
}