> ## Documentation Index
> Fetch the complete documentation index at: https://chatcli.edilsonfreitas.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Listar AI Insights

> Retorna todos os insights gerados pela IA com análise de causa raiz, scores de confiança e ações de remediação sugeridas para cada incidente

<ParamField query="namespace" type="string">
  Filtrar por namespace Kubernetes
</ParamField>

<ParamField query="issue" type="string">
  Filtrar por nome do incidente (ex.: `INC-20260319-001`)
</ParamField>

<ParamField query="page" type="integer" default="1">
  Número da página para paginação
</ParamField>

<ParamField query="pageSize" type="integer" default="20">
  Itens por página (máximo 100)
</ParamField>

## O Que São AI Insights?

Toda vez que a plataforma AIOps detecta um incidente, um recurso **AIInsight** é criado contendo a análise completa da IA. Isso inclui:

* **Análise de causa raiz** com score de confiança (0-100%)
* **Recomendações** em formato legível por humanos
* **Ações sugeridas** com parâmetros concretos (ex.: "ScaleDeployment para 5 réplicas")
* **Dados de enriquecimento**: análise de logs, métricas Prometheus, contexto GitOps, análise de cascata e previsão de raio de explosão

Este endpoint é essencial para entender **como a IA raciocinou** sobre cada incidente, especialmente quando incidentes são escalados para operadores humanos.

<ResponseExample>
  ```json Response 200 theme={"system"}
  {
    "apiVersion": "v1",
    "kind": "AIInsightList",
    "metadata": {
      "totalCount": 2,
      "page": 1,
      "pageSize": 20
    },
    "items": [
      {
        "name": "insight-inc-20260319-001",
        "namespace": "production",
        "issueRef": "INC-20260319-001",
        "provider": "anthropic",
        "model": "claude-sonnet-4-20250514",
        "analysis": "The payment-service deployment is experiencing OOMKill events. Root cause: memory leak in the webhook handler that fails to close HTTP response bodies on validation errors, causing heap accumulation. The leak correlates with a recent deployment (revision 42) that introduced the payment notification webhook handler.",
        "confidence": 0.91,
        "recommendations": [
          "Increase memory limit from 512Mi to 1Gi as immediate mitigation",
          "Restart pods to reclaim leaked memory",
          "Review webhook handler code for unclosed response bodies"
        ],
        "suggestedActions": [
          {
            "name": "Increase memory limit",
            "action": "AdjustResources",
            "description": "Increase memory limit to prevent further OOMKills while the code fix is deployed",
            "params": {
              "memoryLimit": "1Gi",
              "deployment": "payment-service",
              "namespace": "production"
            }
          },
          {
            "name": "Restart deployment",
            "action": "RestartDeployment",
            "description": "Restart pods to reclaim leaked memory immediately",
            "params": {
              "deployment": "payment-service",
              "namespace": "production"
            }
          }
        ],
        "logAnalysis": "1 Go panic stack trace detected; 12 critical error patterns (OOMKilled, memory allocation failure); Primary exception: runtime: out of memory",
        "gitOpsContext": "Helm release 'payment' chart=payment-service version=2.3.1 status=deployed revision=42",
        "cascadeAnalysis": "Cascade chain: production/payment-service(root_cause) -> production/api-gateway(victim). The api-gateway is receiving 503 responses from payment-service.",
        "blastRadiusPrediction": "AdjustResources: Low risk. Affects 3 pods, 1 service (payment-svc). No PDB violations.",
        "generatedAt": "2026-03-19T14:32:00Z",
        "creationTimestamp": "2026-03-19T14:31:00Z"
      }
    ]
  }
  ```
</ResponseExample>


## OpenAPI

````yaml GET /aiinsights
openapi: 3.1.0
info:
  title: ChatCLI AIOps Platform API
  description: >-
    REST API for the ChatCLI AIOps Platform — incidents, SLOs, runbooks,
    approvals, postmortems, analytics, audit, federation and health.


    The playground below uses **editable server variables** so you can point
    requests at your own self-hosted instance. Adjust `host`, `port` and
    `basePath` to match your deployment, then click **Try it**.
  version: 1.0.0
  contact:
    name: ChatCLI
    url: https://github.com/diillson/chatcli
  license:
    name: Apache-2.0
    identifier: Apache-2.0
servers:
  - url: http://{host}:{port}/{basePath}
    description: >-
      Self-hosted ChatCLI AIOps Platform — adjust host, port and basePath to
      match your deployment.
    variables:
      host:
        default: localhost
        description: >-
          Hostname or IP of your ChatCLI operator. For Kubernetes, use the
          Service DNS (e.g. chatcli-api.chatcli-system.svc) or your Ingress
          host.
      port:
        default: '8090'
        description: >-
          Port the API listens on. Default is 8090; configurable via Helm value
          `apiPort` or env var CHATCLI_API_PORT.
      basePath:
        default: api/v1
        description: >-
          API base path. Always `api/v1` unless you have a custom proxy rewrite
          in front of the operator.
security:
  - ApiKeyAuth: []
tags:
  - name: Incidents
    description: >-
      Incident lifecycle: list, fetch, acknowledge, resolve, snooze, timeline
      and remediation views.
  - name: Runbooks
    description: Remediation runbooks (list, create, update, delete).
  - name: SLOs
    description: Service Level Objectives and error budgets.
  - name: Approvals
    description: Approval workflow for risky remediations.
  - name: Postmortems
    description: Auto-generated postmortems with review, feedback and close.
  - name: Remediations
    description: Remediation plans and agentic execution history.
  - name: AI Insights
    description: AI root-cause analysis and recommendations per incident.
  - name: Analytics
    description: 'Operational analytics: MTTD, MTTR, trends, capacity, compliance.'
  - name: Audit
    description: Immutable audit log and exports.
  - name: Federation
    description: 'Multi-cluster federation: clusters, status and cross-cluster correlations.'
  - name: Health
    description: Liveness and readiness probes.
paths:
  /aiinsights:
    get:
      tags:
        - AI Insights
      summary: List AI Insights
      description: >-
        Returns all AI-generated insights with root-cause analysis, confidence
        scores and suggested remediation actions per incident.
      operationId: listAIInsights
      parameters:
        - name: namespace
          in: query
          required: false
          description: Filter by Kubernetes namespace.
          schema:
            type: string
        - name: issue
          in: query
          required: false
          description: Filter by incident name.
          schema:
            type: string
        - name: page
          in: query
          required: false
          description: Page number.
          schema:
            type: integer
            default: 1
        - name: pageSize
          in: query
          required: false
          description: Items per page (max 100).
          schema:
            type: integer
            default: 20
            maximum: 100
      responses:
        '200':
          description: Paginated list of AI insights
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AIInsightList'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '429':
          $ref: '#/components/responses/RateLimited'
components:
  schemas:
    AIInsightList:
      type: object
      properties:
        apiVersion:
          type: string
          example: v1
        kind:
          type: string
          example: AIInsightList
        metadata:
          $ref: '#/components/schemas/ListMetadata'
        items:
          type: array
          items:
            $ref: '#/components/schemas/AIInsightListItem'
    ListMetadata:
      type: object
      properties:
        totalCount:
          type: integer
          example: 42
        page:
          type: integer
          example: 1
        pageSize:
          type: integer
          example: 20
    AIInsightListItem:
      type: object
      properties:
        name:
          type: string
        namespace:
          type: string
        issueRef:
          type: string
        provider:
          type: string
        model:
          type: string
        analysis:
          type: string
        confidence:
          type: number
        recommendations:
          type: array
          items:
            type: string
        suggestedActions:
          type: array
          items:
            $ref: '#/components/schemas/AIInsightAction'
        logAnalysis:
          type: string
        gitOpsContext:
          type: string
        cascadeAnalysis:
          type: string
        blastRadiusPrediction:
          type: string
        generatedAt:
          type: string
          format: date-time
        creationTimestamp:
          type: string
          format: date-time
    Error:
      type: object
      required:
        - apiVersion
        - kind
        - error
      properties:
        apiVersion:
          type: string
          example: v1
        kind:
          type: string
          example: Error
        error:
          oneOf:
            - type: object
              required:
                - code
                - message
              properties:
                code:
                  type: integer
                  example: 404
                message:
                  type: string
                  example: Resource not found
                details:
                  type: string
            - type: string
        code:
          type: integer
          description: Top-level code (only used by some endpoints).
          example: 400
    AIInsightAction:
      type: object
      properties:
        name:
          type: string
        action:
          type: string
        description:
          type: string
        params:
          type: object
          additionalProperties: true
  responses:
    Unauthorized:
      description: Missing or invalid API token
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    RateLimited:
      description: Rate limit exceeded for this token's role
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: Authorization
      description: >-
        Bearer token issued by the operator. Format: `Authorization: Bearer
        <token>`.

````