{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/kognitos/json-schema/kognitos-v1-query-metrics-response-schema.json",
  "title": "v1QueryMetricsResponse",
  "description": "Response message for the QueryMetrics RPC.\n\nContains results for each requested metric, with time series data\nand metadata about the query execution.",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/kognitos-analytics-api-openapi.yml#/components/schemas/v1QueryMetricsResponse",
  "type": "object",
  "properties": {
    "results": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/v1MetricResult"
      },
      "description": "Results for each requested metric.\n\nOrdered in the same sequence as the metrics field in the request.\nEach result contains the time series data for one metric.",
      "readOnly": true
    },
    "next_page_token": {
      "type": "string",
      "description": "Token for retrieving the next page of results.\n\nIf non-empty, there are more results available. Pass this value as\npage_token in the next request to retrieve the next page.\n\nIf empty, there are no more results (this is the last page).\n\nWhen paginating, all metrics will include their next page of series.\n\nSee https://google.aip.dev/158 for pagination specification.",
      "readOnly": true
    }
  },
  "required": [
    "results"
  ],
  "$defs": {
    "v1AggregationFunction": {
      "type": "string",
      "enum": [
        "AGGREGATION_FUNCTION_UNSPECIFIED",
        "AGGREGATION_FUNCTION_COUNT",
        "AGGREGATION_FUNCTION_SUM",
        "AGGREGATION_FUNCTION_AVG",
        "AGGREGATION_FUNCTION_MIN",
        "AGGREGATION_FUNCTION_MAX"
      ],
      "default": "AGGREGATION_FUNCTION_UNSPECIFIED",
      "description": "Aggregation function for metric values.\n\nSpecifies how metric values should be aggregated within each interval.\n\n - AGGREGATION_FUNCTION_UNSPECIFIED: Unspecified aggregation. Defaults to COUNT.\n - AGGREGATION_FUNCTION_COUNT: Count of occurrences.\n - AGGREGATION_FUNCTION_SUM: Sum of values.\n - AGGREGATION_FUNCTION_AVG: Average of values.\n - AGGREGATION_FUNCTION_MIN: Minimum value.\n - AGGREGATION_FUNCTION_MAX: Maximum value."
    },
    "v1MetricDataPoint": {
      "type": "object",
      "properties": {
        "start_time": {
          "type": "string",
          "format": "date-time",
          "description": "The start time for this data point's interval.\n\nRepresents the start of the interval for which the value is aggregated.",
          "readOnly": true
        },
        "value": {
          "type": "number",
          "format": "double",
          "description": "The aggregated metric value for this interval.\n\nResult of applying the aggregation function to all matching records\nwithin this interval for this series' tag combination.",
          "readOnly": true
        },
        "window_label": {
          "type": "string",
          "description": "Human-readable label for the time window.\n\nProvides a formatted display name for the interval, formatted according\nto the interval granularity and the user's locale preferences.\n\nExamples:\n- HOUR: \"Jan 15, 2025 10:00 AM\", \"2025-01-15 10:00\"\n- DAY: \"January 15, 2025\", \"2025-01-15\"\n- WEEK: \"Week of Jan 15, 2025\", \"2025-W03\"\n- MONTH: \"January 2025\", \"2025-01\"",
          "readOnly": true
        }
      },
      "description": "A single data point in a metric time series.\n\nRepresents an aggregated metric value at a specific point in time.",
      "required": [
        "start_time",
        "value",
        "window_label"
      ]
    },
    "v1MetricInterval": {
      "type": "string",
      "enum": [
        "METRIC_INTERVAL_UNSPECIFIED",
        "METRIC_INTERVAL_HOUR",
        "METRIC_INTERVAL_DAY",
        "METRIC_INTERVAL_WEEK",
        "METRIC_INTERVAL_MONTH"
      ],
      "default": "METRIC_INTERVAL_UNSPECIFIED",
      "description": "Time interval for metric aggregation.\n\nSpecifies the granularity at which metric data points are aggregated.\nThe server may adjust the requested interval based on the time range\nor data availability.\n\n - METRIC_INTERVAL_UNSPECIFIED: Unspecified interval. Server will determine appropriate interval.\n - METRIC_INTERVAL_HOUR: Hourly aggregation.\n - METRIC_INTERVAL_DAY: Daily aggregation.\n - METRIC_INTERVAL_WEEK: Weekly aggregation.\n - METRIC_INTERVAL_MONTH: Monthly aggregation."
    },
    "v1MetricResult": {
      "type": "object",
      "properties": {
        "metric": {
          "type": "string",
          "description": "The name of this metric.\n\nEchoes back the metric name from the request.",
          "readOnly": true
        },
        "interval": {
          "$ref": "#/$defs/v1MetricInterval"
        },
        "aggregation": {
          "$ref": "#/$defs/v1AggregationFunction"
        },
        "series": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/v1MetricSeries"
          },
          "description": "Multiple time series, one per unique group_by combination.\n\nIf group_by is empty, there will be exactly one series with empty tags.\nIf group_by has values, there will be one series per unique combination\nfound in the data.\n\nSeries are ordered according to the order_by parameter in the request.\nIf page_size was specified, results are paginated across all metrics.\n\nThe list may be empty if no data exists for the requested time range.",
          "readOnly": true
        }
      },
      "description": "Result for a single metric query.\n\nContains the time series data and metadata for one metric.",
      "required": [
        "metric",
        "interval",
        "aggregation",
        "series"
      ]
    },
    "v1MetricSeries": {
      "type": "object",
      "properties": {
        "tags": {
          "type": "object",
          "additionalProperties": {
            "type": "string"
          },
          "description": "Tags identifying this series.\n\nThe unique combination of group_by tag values that define this series.\nIf group_by is empty, this will be an empty map.\n\nExample: {\"status\": \"success\", \"workspace_id\": \"ws_123\"}",
          "readOnly": true
        },
        "points": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/v1MetricDataPoint"
          },
          "description": "Time series data points for this specific tag combination.\n\nChronologically ordered data points showing the metric value over time.",
          "readOnly": true
        }
      },
      "description": "A single time series for a specific combination of tag values.\n\nEach series represents one unique combination of the group_by dimensions,\ncontaining data points over time for that specific combination.",
      "required": [
        "tags",
        "points"
      ]
    }
  }
}