{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://raw.githubusercontent.com/api-evangelist/harness/main/json-schema/harness-dashboard-metrics-schema.json",
  "title": "DashboardMetrics",
  "description": "Policy, policy set and evaluation metrics",
  "x-generated": "2026-10-04",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/harness-dashboard-api-openapi.yml#/components/schemas/DashboardMetrics",
  "type": "object",
  "properties": {
    "aggregates": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/AggregateStatus"
      },
      "description": "Aggregate evaluation counts by day"
    },
    "policy_health": {
      "$ref": "#/$defs/PolicyHealth"
    }
  },
  "required": [
    "policy_health",
    "aggregates"
  ],
  "$defs": {
    "AggregateStatus": {
      "type": "object",
      "properties": {
        "error": {
          "type": "integer",
          "description": "Count of evaluations that have a status of 'error'",
          "format": "int64"
        },
        "pass": {
          "type": "integer",
          "description": "Count of evaluations that have a status of 'pass'",
          "format": "int64"
        },
        "time": {
          "type": "integer",
          "description": "The Unix time of this particular aggregation",
          "format": "int64"
        },
        "warning": {
          "type": "integer",
          "description": "Count of evaluations that have a status of 'warning'",
          "format": "int64"
        }
      },
      "description": "Aggregate metrics for evaluations on a single day",
      "required": [
        "time",
        "error",
        "warning",
        "pass"
      ]
    },
    "EvaluationCounts": {
      "type": "object",
      "properties": {
        "error": {
          "type": "integer",
          "description": "Count of evaluations that have a status of 'error'",
          "format": "int64"
        },
        "pass": {
          "type": "integer",
          "description": "Count of evaluations that have a status of 'pass'",
          "format": "int64"
        },
        "warning": {
          "type": "integer",
          "description": "Count of evaluations that have a status of 'warning'",
          "format": "int64"
        }
      },
      "description": "Evaluation counts by status",
      "required": [
        "error",
        "warning",
        "pass"
      ]
    },
    "PolicyHealth": {
      "type": "object",
      "properties": {
        "total_evaluation_count": {
          "type": "integer",
          "description": "Total number of evaluations that have occurred",
          "format": "int64"
        },
        "total_evaluation_entity_count": {
          "$ref": "#/$defs/EvaluationCounts"
        },
        "total_policy_count": {
          "type": "integer",
          "description": "Total number of policies stored",
          "format": "int64"
        },
        "total_policy_set_count": {
          "type": "integer",
          "description": "Total number of policy sets stored",
          "format": "int64"
        },
        "total_policy_set_entity_count": {
          "type": "object",
          "description": "Total number of policy sets by type",
          "additionalProperties": {
            "type": "integer",
            "format": "int64"
          }
        }
      },
      "description": "Policy health metrics",
      "required": [
        "total_policy_count",
        "total_policy_set_count",
        "total_policy_set_entity_count",
        "total_evaluation_count",
        "total_evaluation_entity_count"
      ]
    }
  }
}