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

# Query Metric

> Time-bucketed count/sum/avg/min/max for one metric, with optional dimension filters.

Needs `analytics.read` for an unrestricted query. Passing `project_id` also accepts `projects.alarms.read` on that project, so a project-scoped role can read the series behind its own alarms.



## OpenAPI

````yaml GET /orgs/{org_id}/metrics
openapi: 3.1.0
info:
  title: Timbal Platform API
  description: Public API documentation for the Timbal platform
  license:
    name: ''
  version: 2.0.0
servers:
  - url: https://api.timbal.ai
    description: Production
  - url: https://api.dev.timbal.ai
    description: Development
security: []
tags:
  - name: ace
    description: Action Control Engine (ACE) operations
  - name: alarms
    description: Metric series and threshold alarms
  - name: analytics
    description: Org and project analytics
  - name: billing
    description: Subscriptions, usage, and payment-related operations
  - name: channels
    description: Delivery channels alarms notify through
  - name: content
    description: Re-sign stored content URLs
  - name: files
    description: File operations
  - name: iam
    description: IAM — actions, roles, users, and authorization introspection
  - name: k2
    description: Knowledge Bases v2 operations
  - name: orgs
    description: Organization operations
  - name: projects
    description: Project operations
  - name: runs
    description: Execution operations
  - name: templates
    description: Public project template catalog
  - name: users
    description: Authenticated user profile
paths:
  /orgs/{org_id}/metrics:
    get:
      tags:
        - alarms
      summary: Query a metric series
      description: >-
        Time-bucketed count/sum/avg/min/max for one metric, with optional
        dimension filters.


        Needs `analytics.read` for an unrestricted query. Passing `project_id`
        also accepts `projects.alarms.read` on that project, so a project-scoped
        role can read the series behind its own alarms.
      operationId: get_org_metrics
      parameters:
        - name: org_id
          in: path
          required: true
          schema:
            type: string
        - name: name
          in: query
          description: Metric to read, e.g. `app.run.errors`, `deployment.health`.
          required: true
          schema:
            type: string
        - name: period_seconds
          in: query
          description: Bucket size in seconds (multiple of 60). Default 60.
          required: false
          schema:
            type:
              - integer
              - 'null'
            format: int32
        - name: from
          in: query
          description: >-
            Inclusive range start (epoch milliseconds). Default: 100 buckets
            before `to`.
          required: false
          schema:
            type:
              - integer
              - 'null'
            format: int64
        - name: to
          in: query
          description: 'Exclusive range end (epoch milliseconds). Default: now.'
          required: false
          schema:
            type:
              - integer
              - 'null'
            format: int64
        - name: project_id
          in: query
          description: Filter to one project. Omit to aggregate across projects.
          required: false
          schema:
            type:
              - string
              - 'null'
        - name: project_env_id
          in: query
          description: Filter to one environment.
          required: false
          schema:
            type:
              - string
              - 'null'
        - name: deployment_id
          in: query
          description: Filter to one deployment.
          required: false
          schema:
            type:
              - string
              - 'null'
        - name: workforce_id
          in: query
          description: Filter to one agent/workflow app (`OrgsApps.id`).
          required: false
          schema:
            type:
              - string
              - 'null'
        - name: label
          in: query
          description: |-
            Filter to one label — the span name behind a trace-derived metric
            (`llm`, `get_address`). Omit to sum across every label.
          required: false
          schema:
            type:
              - string
              - 'null'
      responses:
        '200':
          description: Metric series
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OrgMetricsResBody'
        '400':
          description: Bad request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorMessage'
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorMessage'
      security:
        - bearer_auth: []
components:
  schemas:
    OrgMetricsResBody:
      type: object
      title: OrgMetricsResponse
      description: Wrapper for **GET** `/orgs/{org_id}/metrics`.
      required:
        - name
        - period_seconds
        - from
        - to
        - bins
      properties:
        bins:
          type: array
          items:
            $ref: '#/components/schemas/MetricBinOut'
          description: Buckets with data, ascending; empty buckets are omitted.
        from:
          type: integer
          format: int64
          description: Range start (epoch milliseconds).
        name:
          type: string
        period_seconds:
          type: integer
          format: int32
        to:
          type: integer
          format: int64
          description: Range end (epoch milliseconds).
    ErrorMessage:
      type: object
      required:
        - code
        - message
      properties:
        code:
          type: string
          description: Machine-readable error code (e.g. `ALREADY_EXISTS`, `BAD_REQUEST`).
        message:
          type: string
          description: Human-readable description.
    MetricBinOut:
      type: object
      description: One aggregated time bucket of a metric series.
      required:
        - ts
        - count
        - sum
      properties:
        avg:
          type:
            - number
            - 'null'
          format: double
        count:
          type: integer
          format: int64
          description: Observations in the bucket.
        max:
          type:
            - number
            - 'null'
          format: double
        min:
          type:
            - number
            - 'null'
          format: double
        sum:
          type: number
          format: double
        ts:
          type: integer
          format: int64
          description: Bucket start (epoch milliseconds).
  securitySchemes:
    bearer_auth:
      type: http
      scheme: bearer
      description: >-
        Timbal API key. Obtain your API key from the Timbal platform settings.
        See [Authentication](/api-reference/authentication) for more
        information.

````