> ## 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.

# Analytics MTTR

> Retorna métricas detalhadas de MTTR (Mean Time To Resolve) com breakdown por fase

<ParamField query="period" type="string" default="30d">
  Período de análise: `7d`, `30d`, `90d`, `180d`
</ParamField>

<ParamField query="severity" type="string">
  Filtrar por severidade: `critical`, `high`, `medium`, `low`
</ParamField>

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

<ParamField query="granularity" type="string" default="daily">
  Granularidade do histórico: `hourly`, `daily`, `weekly`
</ParamField>

<ResponseExample>
  ```json Response 200 theme={"system"}
  {
    "apiVersion": "v1",
    "kind": "AnalyticsMTTR",
    "metadata": {
      "period": "30d",
      "from": "2026-02-17T00:00:00Z",
      "to": "2026-03-19T15:00:00Z",
      "generatedAt": "2026-03-19T15:05:00Z"
    },
    "mttr": {
      "overall": {
        "mean": "8m30s",
        "median": "6m15s",
        "p95": "25m",
        "p99": "1h10m"
      },
      "bySeverity": {
        "critical": {
          "mean": "12m45s",
          "median": "10m",
          "count": 8
        },
        "high": {
          "mean": "8m20s",
          "median": "6m",
          "count": 35
        },
        "medium": {
          "mean": "6m",
          "median": "4m30s",
          "count": 52
        },
        "low": {
          "mean": "3m15s",
          "median": "2m",
          "count": 28
        }
      },
      "byPhase": {
        "detection": {
          "mean": "45s",
          "description": "Tempo entre o evento e a detecção pelo watcher"
        },
        "analysis": {
          "mean": "1m30s",
          "description": "Tempo de análise de root cause pela IA"
        },
        "approval": {
          "mean": "3m20s",
          "description": "Tempo de espera por aprovação humana"
        },
        "remediation": {
          "mean": "2m55s",
          "description": "Tempo de execução do runbook de remediação"
        }
      },
      "history": [
        {
          "date": "2026-03-19",
          "mttr": "7m",
          "incidentCount": 5
        },
        {
          "date": "2026-03-18",
          "mttr": "9m30s",
          "incidentCount": 8
        },
        {
          "date": "2026-03-17",
          "mttr": "6m15s",
          "incidentCount": 3
        },
        {
          "date": "2026-03-16",
          "mttr": "11m",
          "incidentCount": 7
        }
      ],
      "improvement": {
        "vsPrevPeriod": "-22%",
        "vsBaseline": "-45%",
        "baselinePeriod": "2026-01-01 to 2026-01-31"
      }
    }
  }
  ```
</ResponseExample>


## OpenAPI

````yaml GET /analytics/mttr
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:
  /analytics/mttr:
    get:
      tags:
        - Analytics
      summary: Analytics MTTR
      description: Returns detailed MTTR metrics with phase breakdown.
      operationId: analyticsMTTR
      parameters:
        - name: period
          in: query
          required: false
          description: Analysis period.
          schema:
            type: string
            enum:
              - 7d
              - 30d
              - 90d
              - 180d
            default: 30d
        - name: severity
          in: query
          required: false
          description: Filter by severity.
          schema:
            type: string
            enum:
              - critical
              - high
              - medium
              - low
        - name: namespace
          in: query
          required: false
          description: Filter by namespace.
          schema:
            type: string
        - name: granularity
          in: query
          required: false
          description: History granularity.
          schema:
            type: string
            enum:
              - hourly
              - daily
              - weekly
            default: daily
      responses:
        '200':
          description: MTTR metrics
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AnalyticsMTTR'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '429':
          $ref: '#/components/responses/RateLimited'
components:
  schemas:
    AnalyticsMTTR:
      type: object
      properties:
        apiVersion:
          type: string
          example: v1
        kind:
          type: string
          example: AnalyticsMTTR
        metadata:
          type: object
          properties:
            period:
              type: string
            from:
              type: string
              format: date-time
            to:
              type: string
              format: date-time
            generatedAt:
              type: string
              format: date-time
        mttr:
          type: object
          properties:
            overall:
              type: object
              additionalProperties: true
            bySeverity:
              type: object
              additionalProperties: true
            byPhase:
              type: object
              additionalProperties: true
            history:
              type: array
              items:
                type: object
                additionalProperties: true
            improvement:
              type: object
              additionalProperties: true
    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
  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>`.

````